Module yang

Generic Yang Handler

  • License: Inmanta EULA

  • Version: 3.2.2

Typedefs

typedef yang::edit_config_operation
  • Base type string

  • Type constraint (self in ['merge', 'replace'])

typedef yang::positive_neutral_integer
  • Base type int

  • Type constraint (self >= 0)

typedef yang::protocol_operation_t
  • Base type string

  • Type constraint (self in ['get', 'get-config'])

typedef yang::verify_op_t
  • Base type string

  • Type constraint (self in ['eq', 'gt', 'ge', 'le', 'lt', 'exists', 'missing'])

typedef yang::verify_quantifier_t
  • Base type string

  • Type constraint (self in ['all', 'any', 'one-result', 'count'])

typedef yang::types::int16
  • Base type int

  • Type constraint ((self >= -32768) and (self <= 32767))

typedef yang::types::int32
  • Base type int

  • Type constraint ((self >= -2147483648) and (self <= 2147483647))

typedef yang::types::int64
  • Base type int

  • Type constraint ((self >= -9223372036854775808) and (self <= 9223372036854775807))

typedef yang::types::int8
  • Base type int

  • Type constraint ((self >= -128) and (self <= 127))

typedef yang::types::uint16
  • Base type int

  • Type constraint ((self >= 0) and (self <= 65535))

typedef yang::types::uint32
  • Base type int

  • Type constraint ((self >= 0) and (self <= 4294967295))

typedef yang::types::uint64
  • Base type int

  • Type constraint ((self >= 0) and (self <= 18446744073709551615))

typedef yang::types::uint8
  • Base type int

  • Type constraint ((self >= 0) and (self <= 255))

Entities

entity yang::BaseDevice

Parents: std::Entity

Entity representing a device a config should be deployed to

attribute bool auto_agent=false

Automatically start an agent to manage the resources for this device

attribute string backend

The backend type to use for this device instance

attribute bool managed=true

If the resource is managed

attribute string mgmt_ip

Management ip of the device

attribute string[] models=List()

List of the model names this module uses

attribute dict module_mapping={}

Dictionary contraing namespaces definitions. Key - module name. Value - namespace URI.

attribute string name

A name to uniquely identify the device

attribute int port

Management port of the device

relation yang::Root root_container [1]
relation yang::Credentials yang_credentials [1]

The set of credentials to use to connect to the device Peer relation:

relation yang::BaseResource yang_resource [1]

The following implements statements select implementations for this entity:

entity yang::BaseResource

Parents: std::PurgeableResource, std::ManagedResource

Resource representing the yang device. This resource should not be used directly, you should use any of its subentities instead.

This entity represent any yang compatible device, regardless of the protocol that should be used to configure the device.

The protocol that will be used (gnmi, netconf, etc.) to configure depends on the subentity that is used. Using the NetconfResource entity will use netconf, using GnmiResource will use gnmi.

attribute bool purge_on_delete=false
attribute bool send_event=true
attribute string name

Resource name

attribute string device

Device name

attribute string host

Host name

attribute int port

Port

relation yang::Root root [1]
relation yang::Credentials credentials [1]
relation yang::Container containers [0:*]

other end: yang::Container.resource [0:1]

entity yang::Container

Parents: yang::Element

Basic container representing xml container

attribute string? module=null

A reference to the module this container is coming from. The value must be a key in the module_mapping attribute of the Root entity at the root of tree this container is a part of. !Warning! For modules using gnmi as a backend, this value MUST be the actual module name, as defined in the yang model.

attribute string? value=null

if this item is a leaf, it can have a value instead of subs

attribute string name

Xml tag of the container

attribute string[] key_attribute=List()
attribute dict subs={}

Xml direct values of a tag, if it’s not a container

attribute yang::edit_config_operation? operation

NETCONF edit-config operation type used for push the config

attribute bool purged=false

True if the entity is deleted

attribute bool is_actual=true

is this a config node, or just a container for the config. The filter for getting the config from the device is constructed by taking the types of the first nodes in the tree that are actual.

relation yang::BaseResource resource [0:1]

other end: yang::BaseResource.containers [0:*]

The following implements statements select implementations for this entity:

entity yang::Credentials

Parents: std::Entity

Basic credentials When set, environment variables will always overwrite the matching attribute values

attribute string? username=null

username of the user

attribute string? username_env_var=null

environment variable for username of the user

attribute string? password=null

password of the user

attribute string? password_env_var=null

environment variable for password of the user

attribute dict? secret_reference=null

Dictionary containing the necessary query to retrieve the object and its secret from the inventory. If this module is used with Netbox, more information can be found in the ‘Netbox’ module in the ‘build_secret_reference’ plugin documentation

The following implements statements select implementations for this entity:

entity yang::Element

Parents: std::Entity

Basic entity - direct mapping of xml element

relation yang::Element children [0:*]

other end: yang::Element.parent [0:1]

relation yang::Element parent [0:1]

other end: yang::Element.children [0:*]

entity yang::EmptyLeafContainer

Parents: yang::Container

This container can be used to safely represent an empty leaf.

This is required when using the handler with a gnmi device as the json representation of an empty leaf is not an empty container as in netconf but a list containing a unique null element. https://datatracker.ietf.org/doc/html/rfc7951#section-6.9

attribute yang::edit_config_operation? operation='replace'

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity yang::GnmiDevice

Parents: yang::BaseDevice

Entity representing a device that should be configured using gnmi as backend

attribute string backend='gnmi'

Set the correct backend value as default. This must not be changed.

attribute string? certificate_chain=null

The path to the PEM-encoded certificate chain.

attribute bool insecure=false

Use an insecure channel to the device.

attribute int port=57400

Management port of the device

attribute string? private_key=null

The path to the PEM-encoded private key.

attribute string? root_certificates=null

The path to the PEM-encoded root certificates.

attribute bool skip_verify=true

Disable SSL certificate validation on the encrypted gRPC channel.

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity yang::GnmiResource

Parents: yang::BaseResource

Resource representing a yang device that can be configured over gnmi.

If a model is built using an instance of this entity as device, the device will be configured using gnmi. Not all devices support gnmi, check the device specification to know if it can be used.

attribute int port=57400
attribute bool insecure=false

Use an insecure channel to the device.

attribute bool skip_verify=true

Set to disable SSL certificate validation on the encrypted gRPC channel

attribute string? root_certificates=null

The path (on the agent’s host) to the PEM-encoded root certificates.

attribute string? private_key=null

The path (on the agent’s host) to the PEM-encoded private key.

attribute string? certificate_chain=null

The path (on the agent’s host) to the PEM-encoded certificate chain.

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity yang::ListContainer

Parents: yang::Container

This container can be used to safely represent an list container.

This is required when using the handler with a gnmi device as the json representation of list of one element is different from representing a simple container.

The following implements statements select implementations for this entity:

  • constraint true

entity yang::NetconfDevice

Parents: yang::BaseDevice

Entity representing a device that should be configured using netconf as backend

attribute string backend='netconf'

Set the correct backend value as default. This must not be changed.

attribute bool huge_tree=false

If true XML huge tree support will be enabled for this device - important mainly for some cases of long get-schema RPC responses containing YANG model definition (default: false)

attribute bool persist=true

Whether the config should be persisted to a permanent data store on update.

attribute string persist_target='startup'

The target datastore where the config should be persisted (when persist is enabled).

attribute int port=830

Management port of the device

attribute int retry_count=0

A number of retries to be done before a failure.

attribute int retry_interval=0

Number of seconds to wait before a retry is done.

attribute bool use_get_schema_invalid_namespaces_workaround=false

If true get-schema RPC reply processing code of ncclient will be patched for scanning and loading YANG models to accept response with invalid or malformed namespaces. It must be enabled for Juniper devices to avoid failure.

attribute bool ignore_diff_failure=false

Ignore errors during diff calculation and try to push desired config anyway

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity yang::NetconfResource

Parents: yang::BaseResource

Resource representing the yang device that can be configured using netconf.

If a model is built using an instance of this entity as device, the device will be configured using netconf. Not all devices support netconf, check the device specification to know if it can be used.

attribute int port=830
attribute bool persist=false

Defines if the config should persist in the persist_target using a copy netconf call after a commit: copy running-config $persist_target

attribute string persist_target='startup'

Defines persist config target

attribute yang::positive_neutral_integer retry_count=0

Number of retries before a failure.

attribute yang::positive_neutral_integer retry_interval=0

Interval time in seconds between retries.

attribute bool huge_tree=false

If true XML huge tree support will be enabled - important mainly for some cases of long get-schema RPC responses containing YANG model definition (default: false)

attribute bool use_get_schema_invalid_namespaces_workaround=false

If true get-schema RPC reply processing code of ncclient will be patched for scanning and loading YANG models to accept response with invalid or malformed namespaces. It must be enabled for Juniper devices to avoid failure. Default: false.

attribute bool ignore_diff_failure=false

Ignore errors during diff calculation and try to push desired config anyway

The following implements statements select implementations for this entity:

entity yang::NetconfVerify

Parents: std::PurgeableResource

Base resource for verifying netconf values

2 retry mechanisms are provided:
  • retry_count - used when device is not responding correctly

  • condition_retry_count - used when waiting for specific value (e.g. a session to be established)

attribute bool purge_on_delete=false
attribute bool send_event=true
attribute string name

Resource name

attribute string device

Device name

attribute string host

Host name

attribute int port

Port

attribute yang::protocol_operation_t protocol_operation='get'
attribute string datastore='running'
attribute int retry_count=3

Number of retries to query netconf server (retry for netconf errors)

attribute int retry_interval=5

Time between attempts to query netconf server

attribute int condition_retry_count=0

Number of retries when conditions are not matched

attribute int condition_retry_interval=0

Time between attempts to query netconf server

attribute bool auto_agent=true
attribute bool skip_on_condition_failure=false

Skip a resource instead of failing if all errors are related to unmet conditions

relation yang::VerificationEntry entries [0:*]
relation yang::Credentials credentials [1]

The following implements statements select implementations for this entity:

entity yang::Resource

Parents: yang::NetconfResource

@deprecated Use NetconfResource instead

With the addition of gnmi as possible protocol to configure the yang devices, the naming of this entity doesn’t really makes sense anymore as there is not just-one resource for this module.

This entity is kept for backward compatibility reason. Modules should stop using it, it should be removed in the next major release. The entity NetconfResource is a drop-in replacement for it.

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity yang::ResourceBuilder

Parents: std::Entity

All entities modelled in this module are translated to the correct yang model. Each device creates a global yang resource that collects all containers in the model.

When an entity that inherits from Base is associated with this resource, it will be added to a different yang resource. This can be used to create a distinction between global configuration and service specific configuration and put them in their own failure domain.

attribute string identifier

The identifier to use as yang resource name

attribute bool managed=true

If the resource is managed :rel device: The device this resource should deploy to :rel entities: :rel yang_resource:

relation yang::BaseDevice device [1]

The device this resource should deploy to Peer relation:

relation yang::BaseResource yang_resource [1]

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity yang::Root

Parents: yang::Element

Root element of the config structure

attribute dict module_mapping

Dictionary with namespaces of the module. It provides for each module name, the corresponding namespace. For modules using netconf as a backend, the key SHOULD be the module name. For modules using gnmi as a backend, the key MUST be the module name.

attribute dict compiled_modules={}

A dict containing for each module name, the path to the corresponding compiled (ncdiff) model file (as a FileMarker object).

attribute list models=List()

Names of YANG models to be loaded

The following implements statements select implementations for this entity:

entity yang::VerificationEntry

Parents: std::Entity

Entity describing single condition on specific field

XPath is used to select node in netconf structure. Example xpath for NokiaSR:

‘./state/router[router-name=”management”]/interface’

and corresponding namespaces dict:

{“”: “urn:nokia.com:sros:ns:yang:sr:state”}

Only small subset of XPath functionality is supported, because of restictions in netconf filter structure, which is built from xpath attribute. * XPath must start with current node selector ./, which is a standard data node in netconf namespace * XPath predicates (expressions in square brackets) can only be used to specify exact values for children nodes.

They are used to create content match nodes in netconf filter.

  • Node namespace can be specified as qualified name - namespace prefix in curly brackets, or as a reference to a dictionary namespaces attribute - namespace as a prefix with : separator. Empty string “” can be used in namespaces to define default namespace. Example with all 3 ways namespaces can be specified:

    ‘./state/ns1:router[ns1:router-name=”management”]/{urn:nokia.com:sros:ns:yang:sr:state}interface’

    namespaces dict:

    {“”: “urn:nokia.com:sros:ns:yang:sr:state”, “ns1”: “urn:nokia.com:sros:ns:yang:sr:state”}

Allowed operators: * simple value comparisons: eq, gt, ge, le and lt

Value from netconf reply is compared with value attribute as a first operand. For example, when gt operator is used with value=10, the following condition will be checked: xml_value > 10

  • exists - node with specified xpath must be present in netconf reply

  • missing - node with specified xpath must be missing from netconf reply

Allowed quantifiers: * one-result (default) - expect only one match for xpath.

Resource will immediately fail if multiple nodes match provided xpath

  • any - at least one xpath matching node must meet the condition

  • all - all xpath matching nodes must meet the condition

  • count - use operator and value to ensure number of matches for specified xpath

attribute string xpath

XPath of value to be checked

attribute yang::verify_op_t operator

Condition operator

attribute string? value=null

Condition value - required only for binary operations

attribute yang::verify_quantifier_t quantifier='one-result'

Configure behavior for multiple xpath matches

attribute string condition_failed_message=''

Human-readable message, used when condition is not met. This message will be visible in “diagnose” view in web console

attribute dict namespaces={}

Dictionary with XML namespaces used in XPath

The following implements statements select implementations for this entity:

Implementations

implementation yang::deprecated

Simply log a warning to tell the user he should not use this resource anymore.

implementation yang::emptyLeafContainer

Ensure that the empty leaf container is not misused.

If any of the value enforced below is assigned another value that could result in a misbehaving handler, a double set exception will be raised.

implementation yang::gnmiDevice

Ensure that the backend value can not be changed.

implementation yang::gnmiDeviceResource

Setup the device root resource

implementation yang::gnmiResource
implementation yang::ignored_certificate

Log a warning when a certificate chain is provided but skip_verify option is set. This means that the gnmi client will use the certificates, whitout verifying them, which might not work.

implementation yang::netconfDevice

Ensure that the backend value can not be changed.

implementation yang::netconfDeviceResource

Setup the device root resource

implementation yang::netconfResource

Plugins

yang.as_bool(value: 'any') 'bool'

Converts a value to a boolean, raise a PluginException if it fails to do so.

WARNING: This plugin is used by generated yang modules. Tampering with its interface has consequences.

Parameters:

value – The value to convert

yang.compiled_modules(module_name: 'string', models: 'string[]') 'dict'

For each model name in the provided models list, get the corresponding compiled xml file in the files folder of the module named :attr module_name:

Attr module_name:

The name of the module containing the compiled model files.

Attr models:

The list of model names that are expected to be found in the module files.

yang.deprecation_warning(entity: 'std::Entity', message: 'string')
yang.is_bool(value: 'any') 'bool'

Check whether a value can be converted to a boolean.

WARNING: This plugin is used by generated yang modules. Tampering with its interface has consequences.

Parameters:

value – The value to check

yang.is_int(value: 'any') 'bool'

Check whether a value can be converted to an integer.

WARNING: This plugin is used by generated yang modules. Tampering with its interface has consequences.

Parameters:

value – The value to check

yang.is_number(value: 'any') 'bool'

Check whether a value can be converted to a number (float).

WARNING: This plugin is used by generated yang modules. Tampering with its interface has consequences.

Parameters:

value – The value to check

yang.validate_type(value: 'any', type_ref: 'string') 'bool'

Use the type definition at :param type_ref: to validate :param value: Returns whether the validation was successful.

WARNING: This plugin is used by generated yang modules. Tampering with its interface has consequences.

Parameters:
  • value – The value to validate

  • type_ref – The reference to the type definition to use for validation

yang.warning(entity: 'std::Entity', message: 'string')

Resources

class yang.resources.YangGnmiResource

Resource representing each yang device

class yang.resources.YangNetconfResource

Resource representing each yang device

class yang.ncverify.resource.NetconfVerifyResource

Resource for verification of netconf xml tree

class yang.resources.YangResource

Handlers

class yang.gnmi.handler.GnmiHandler

Yang CRUD Handler

class yang.netconf.handler.YangHandler

Yang CRUD Handler

class yang.netconf.handler.YangHandler

Yang CRUD Handler

class yang.ncverify.handler.NetconfVerifyHandler