ncdiff.Config class¶
-
class
ncdiff.
Config
(ncdevice, config=None, validate=True)[source]¶ Bases:
object
Abstraction of a config state of a device.
-
device
¶ An instance of yang.ncdiff.ModelDevice, which represents a modeled device.
Type: object
-
ele
¶ A lxml Element which contains the config.
Type: Element
-
xml
¶ A string presentation of self.ele, not in pretty-print.
Type: str
-
ns
¶ A dictionary of namespaces used by the config. Keys are prefixes and values are URLs.
Type: dict
-
models
¶ A list of model names that self.roots belong to.
Type: list
-
roots
¶ A dictionary of roots of self.ele. Dictionary keys are tags of roots in
{url}tagname
notation, and values are corresponding model names.Type: dict
__init__ instantiates a Config instance.
-
get_schema_node
(node)[source]¶ High-level api: Return schema node of a config node.
Parameters: node ( Element
) – An Element node in config tree.Returns: A schema node of the config node. Return type: Element
-
get_model_name
(node)[source]¶ High-level api: Return model name of a config node.
Parameters: node ( Element
) – An Element node in config tree.Returns: Model name the config node belongs to. Return type: Element
-
validate_config
()[source]¶ High-level api: Validate config against models. ConfigError is raised if the config has issues.
Returns: There is no return of this method. Return type: None Raises: ConfigError
– If config contains error.
-
ns_help
()[source]¶ High-level api: Print known namespaces to make writing xpath easier.
Returns: There is no return of this method. Return type: None
-
xpath
(*args, **kwargs)[source]¶ High-level api: It is a wrapper of xpath method in lxml package. If namespaces is not given, self.ns is used by default.
Returns: Refer to http://lxml.de/xpathxslt.html#xpath-return-values Return type: boolean or float or str or list
-