Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating subtree against YANG model #49

Open
stewa02 opened this issue Apr 21, 2020 · 1 comment
Open

Validating subtree against YANG model #49

stewa02 opened this issue Apr 21, 2020 · 1 comment

Comments

@stewa02
Copy link

stewa02 commented Apr 21, 2020

With from_raw() can a data-instance of a YANG model be loaded. In our specific instance we load a data instance of the "ietf-interfaces" model from an IOS-XE device over RESTCONF (https:///restconf/data/ietf-interfaces:interfaces/), like the one below. This works perfectly.

        {
          "ietf-interfaces:interfaces": {
            "interface": [
              {
                "name": "GigabitEthernet1",
                "type": "iana-if-type:ethernetCsmacd",
                "enabled": true,
                "ietf-ip:ipv4": {
                  "address": [
                    {
                      "ip": "192.168.0.40",
                      "netmask": "255.255.255.0"
                    }
                  ]
                },
                "ietf-ip:ipv6": {
                }
              },
              {
                "name": "GigabitEthernet2",
                "type": "iana-if-type:ethernetCsmacd",
                "enabled": false,
                "ietf-ip:ipv4": {
                },
                "ietf-ip:ipv6": {
                }
              }
            ]
          }
        }

When the request is specified to only return one interface from the list (e.g. https:///restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1), the returned JSON representation looks like the second one below:

        {
          "ietf-interfaces:interface": {
            "name": "GigabitEthernet1",
            "type": "iana-if-type:ethernetCsmacd",
            "enabled": true,
            "ietf-ip:ipv4": {
              "address": [
                {
                  "ip": "192.168.0.40",
                  "netmask": "255.255.255.0"
                }
              ]
            },
            "ietf-ip:ipv6": {
            }
          }
        }

If this instance is loaded, an exception is thrown: Illegal object member: /ietf-interfaces:interface. As far as I have seen from the documentation, no such filtered models are loaded. Is this not an intended use-case, a bug, or am I overlooking something?

@llhotka
Copy link
Member

llhotka commented Apr 22, 2020

I assume what you do is something like this:

dm.from_raw(inst)

where the data model dm contains the ietf-interfaces module. This won't work because the schema prescribes ietf-interfaces:interfaces at the top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants