-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Labels
Description
The schema path /oc-if:interfaces/interface/name is a leafref pointing to /oc-if:interfaces/interface/config/name. Validation should raise an exception if the values do not match in a payload. In the following example, the former has a value of Loopback0 and the latter has a value of Loopback1. Validation testing should cover this scenario.
Script
#!/usr/bin/env python3
from ydk.path import Repository, Capability, Codec
from ydk.types import EncodingFormat
payload = '''
<interfaces xmlns="http://openconfig.net/yang/interfaces">
<interface>
<name>Loopback0</name>
<config>
<name>Loopback1</name>
<description>Lo0 interface description</description>
<mtu>1500</mtu>
</config>
</interface>
</interfaces>
'''
repo = Repository('/home/host/.ydk/router')
caps = [Capability('openconfig-interfaces', '')]
root_schema = repo.create_root_schema(caps)
codec = Codec()
data_node = codec.decode(root_schema, payload, EncodingFormat.XML)
print(codec.encode(data_node, EncodingFormat.JSON, True))Output:
user@host$ ./test.py
{
"openconfig-interfaces:interfaces": {
"interface": [
{
"name": "Loopback0",
"config": {
"name": "Loopback1",
"description": "Lo0 interface description",
"mtu": 1500
}
}
]
}
}
Segmentation fault
user@host$
System:
Ubuntu Bionic running:
user@host$ pip list | grep "ydk "
ydk 0.8.4
user@host$
Reactions are currently unavailable