NAPALM YANG basic operations.
New in version 2017.7.0.
Return the compliance report using YANG objects.
Dictionary structured with respect to the models referenced.
A list of models to be used when generating the config.
The absolute path to the validation file.
CLI Example:
salt '*' napalm_yang.compliance_report {} models.openconfig_interfaces filepath=~/validate.yml
Output Example:
{
"skipped": [],
"complies": true,
"get_interfaces_ip": {
"missing": [],
"complies": true,
"present": {
"ge-0/0/0.0": {
"complies": true,
"nested": true
}
},
"extra": []
}
}
Returns the difference between two configuration entities structured according to the YANG model.
Note
This function is recommended to be used mostly as a state helper.
First model to compare.
Second model to compare.
A list of models to be used when comparing.
CLI Example:
salt '*' napalm_yang.diff {} {} models.openconfig_interfaces
Output Example:
{
"interfaces": {
"interface": {
"both": {
"Port-Channel1": {
"config": {
"mtu": {
"first": "0",
"second": "9000"
}
}
}
},
"first_only": [
"Loopback0"
],
"second_only": [
"Loopback1"
]
}
}
}
Return the native config.
Dictionary structured with respect to the models referenced.
A list of models to be used when generating the config.
NoneUse certain profiles to generate the config. If not specified, will use the platform default profile(s).
CLI Example:
salt '*' napalm_yang.get_config {} models.openconfig_interfaces
Output Example:
interface et1
ip address 192.168.1.1/24
description Uplink1
mtu 9000
interface et2
ip address 192.168.2.1/24
description Uplink2
mtu 9000
Generate and load the config on the device using the OpenConfig or IETF models and device profiles.
Dictionary structured with respect to the models referenced.
A list of models to be used when generating the config.
NoneUse certain profiles to generate the config. If not specified, will use the platform default profile(s).
FalseDry run? If set as True, will apply the config, discard
and return the changes. Default: False and will commit
the changes on the device.
TrueCommit? Default: True.
FalseDebug mode. Will insert a new key under the output dictionary,
as loaded_config containing the raw configuration loaded on the device.
FalseShould replace the config with the new generate one?
CLI Example:
salt '*' napalm_yang.load_config {} models.openconfig_interfaces test=True debug=True
Output Example:
device1:
----------
already_configured:
False
comment:
diff:
[edit interfaces ge-0/0/0]
- mtu 1400;
[edit interfaces ge-0/0/0 unit 0 family inet]
- dhcp;
[edit interfaces lo0]
- unit 0 {
- description lo0.0;
- }
+ unit 1 {
+ description "new loopback";
+ }
loaded_config:
<configuration>
<interfaces replace="replace">
<interface>
<name>ge-0/0/0</name>
<unit>
<name>0</name>
<family>
<inet/>
</family>
<description>ge-0/0/0.0</description>
</unit>
<description>management interface</description>
</interface>
<interface>
<name>ge-0/0/1</name>
<disable/>
<description>ge-0/0/1</description>
</interface>
<interface>
<name>ae0</name>
<unit>
<name>0</name>
<vlan-id>100</vlan-id>
<family>
<inet>
<address>
<name>192.168.100.1/24</name>
</address>
<address>
<name>172.20.100.1/24</name>
</address>
</inet>
</family>
<description>a description</description>
</unit>
<vlan-tagging/>
<unit>
<name>1</name>
<vlan-id>1</vlan-id>
<family>
<inet>
<address>
<name>192.168.101.1/24</name>
</address>
</inet>
</family>
<disable/>
<description>ae0.1</description>
</unit>
<vlan-tagging/>
<unit>
<name>2</name>
<vlan-id>2</vlan-id>
<family>
<inet>
<address>
<name>192.168.102.1/24</name>
</address>
</inet>
</family>
<description>ae0.2</description>
</unit>
<vlan-tagging/>
</interface>
<interface>
<name>lo0</name>
<unit>
<name>1</name>
<description>new loopback</description>
</unit>
<description>lo0</description>
</interface>
</interfaces>
</configuration>
result:
True
Parse configuration from the device.
A list of models to be used when parsing.
FalseParse config.
FalseParse state.
NoneUse certain profiles to parse. If not specified, will use the device default profile(s).
CLI Example:
salt '*' napalm_yang.parse models.openconfig_interfaces
Output Example:
{
"interfaces": {
"interface": {
".local.": {
"name": ".local.",
"state": {
"admin-status": "UP",
"counters": {
"in-discards": 0,
"in-errors": 0,
"out-errors": 0
},
"enabled": True,
"ifindex": 0,
"last-change": 0,
"oper-status": "UP",
"type": "softwareLoopback"
},
"subinterfaces": {
"subinterface": {
".local..0": {
"index": ".local..0",
"state": {
"ifindex": 0,
"name": ".local..0"
}
}
}
}
},
"ae0": {
"name": "ae0",
"state": {
"admin-status": "UP",
"counters": {
"in-discards": 0,
"in-errors": 0,
"out-errors": 0
},
"enabled": True,
"ifindex": 531,
"last-change": 255203,
"mtu": 1518,
"oper-status": "DOWN"
},
"subinterfaces": {
"subinterface": {
"ae0.0": {
"index": "ae0.0",
"state": {
"description": "ASDASDASD",
"ifindex": 532,
"name": "ae0.0"
}
}
"ae0.32767": {
"index": "ae0.32767",
"state": {
"ifindex": 535,
"name": "ae0.32767"
}
}
}
}
},
"dsc": {
"name": "dsc",
"state": {
"admin-status": "UP",
"counters": {
"in-discards": 0,
"in-errors": 0,
"out-errors": 0
},
"enabled": True,
"ifindex": 5,
"last-change": 0,
"oper-status": "UP"
}
},
"ge-0/0/0": {
"name": "ge-0/0/0",
"state": {
"admin-status": "UP",
"counters": {
"in-broadcast-pkts": 0,
"in-discards": 0,
"in-errors": 0,
"in-multicast-pkts": 0,
"in-unicast-pkts": 16877,
"out-broadcast-pkts": 0,
"out-errors": 0,
"out-multicast-pkts": 0,
"out-unicast-pkts": 15742
},
"description": "management interface",
"enabled": True,
"ifindex": 507,
"last-change": 258467,
"mtu": 1400,
"oper-status": "UP"
},
"subinterfaces": {
"subinterface": {
"ge-0/0/0.0": {
"index": "ge-0/0/0.0",
"state": {
"description": "ge-0/0/0.0",
"ifindex": 521,
"name": "ge-0/0/0.0"
}
}
}
}
}
"irb": {
"name": "irb",
"state": {
"admin-status": "UP",
"counters": {
"in-discards": 0,
"in-errors": 0,
"out-errors": 0
},
"enabled": True,
"ifindex": 502,
"last-change": 0,
"mtu": 1514,
"oper-status": "UP",
"type": "ethernetCsmacd"
}
},
"lo0": {
"name": "lo0",
"state": {
"admin-status": "UP",
"counters": {
"in-discards": 0,
"in-errors": 0,
"out-errors": 0
},
"description": "lo0",
"enabled": True,
"ifindex": 6,
"last-change": 0,
"oper-status": "UP",
"type": "softwareLoopback"
},
"subinterfaces": {
"subinterface": {
"lo0.0": {
"index": "lo0.0",
"state": {
"description": "lo0.0",
"ifindex": 16,
"name": "lo0.0"
}
},
"lo0.16384": {
"index": "lo0.16384",
"state": {
"ifindex": 21,
"name": "lo0.16384"
}
},
"lo0.16385": {
"index": "lo0.16385",
"state": {
"ifindex": 22,
"name": "lo0.16385"
}
},
"lo0.32768": {
"index": "lo0.32768",
"state": {
"ifindex": 248,
"name": "lo0.32768"
}
}
}
}
}
}
}
}