Closed jambofun closed 2 years ago
Can you provide the YANG library file that you are using?
Sure - any help is appreciated, thanks
{
"ietf-yang-library:modules-state": {
"module-set-id": "ae4bf1ddf85a67ab94a9ab71593cd1c78b7f231d",
"module": [
{
"name": "openconfig-bgp",
"namespace": "http://openconfig.net/yang/bgp",
"revision": "",
"conformance-type": "implement",
"submodule": [
{
"name": "openconfig-bgp-common-multiprotocol",
"revision": ""
},
{
"name": "openconfig-bgp-common-structure",
"revision": ""
},
{
"name": "openconfig-bgp-peer-group",
"revision": ""
},
{
"name": "openconfig-bgp-neighbor",
"revision": ""
},
{
"name": "openconfig-bgp-global",
"revision": ""
},
{
"name": "openconfig-bgp-common",
"revision": ""
}
]
},
{
"name": "openconfig-policy-forwarding",
"namespace": "http://openconfig.net/yang/policy-forwarding",
"revision": "",
"conformance-type": "implement",
"submodule": [
{
"name": "openconfig-pf-forwarding-policies",
"revision": ""
},
{
"name": "openconfig-pf-path-groups",
"revision": ""
},
{
"name": "openconfig-pf-interfaces",
"revision": ""
}
]
},
{
"name": "openconfig-isis",
"namespace": "http://openconfig.net/yang/openconfig-isis",
"revision": "",
"conformance-type": "implement",
"submodule": [
{
"name": "openconfig-isis-lsp",
"revision": ""
},
{
"name": "openconfig-isis-routing",
"revision": ""
}
]
},
{
"name": "openconfig-isis-types",
"namespace": "http://openconfig.net/yang/isis-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-isis-lsdb-types",
"namespace": "http://openconfig.net/yang/isis-lsdb-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-pim",
"namespace": "http://openconfig.net/yang/pim",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-keychain",
"namespace": "http://openconfig.net/yang/oc-keychain",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-igmp",
"namespace": "http://openconfig.net/yang/igmp",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-igmp-types",
"namespace": "http://openconfig.net/yang/igmp/types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-pim-types",
"namespace": "http://openconfig.net/yang/pim/types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-keychain-types",
"namespace": "http://openconfig.net/yang/oc-keychain-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-acl",
"namespace": "http://openconfig.net/yang/acl",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-packet-match",
"namespace": "http://openconfig.net/yang/packet-match-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-packet-match-types",
"namespace": "http://openconfig.net/yang/header-fields",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-extensions",
"namespace": "http://openconfig.net/yang/openconfig-ext",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-rib-bgp",
"namespace": "http://openconfig.net/yang/rib/bgp",
"revision": "",
"conformance-type": "implement",
"submodule": [
{
"name": "openconfig-rib-bgp-attributes",
"revision": ""
},
{
"name": "openconfig-rib-bgp-shared-attributes",
"revision": ""
},
{
"name": "openconfig-rib-bgp-table-attributes",
"revision": ""
},
{
"name": "openconfig-rib-bgp-tables",
"revision": ""
}
]
},
{
"name": "openconfig-bgp-types",
"namespace": "http://openconfig.net/yang/bgp-types",
"revision": "",
"conformance-type": "implement",
"submodule": [
{
"name": "openconfig-bgp-errors",
"revision": ""
}
]
},
{
"name": "openconfig-types",
"namespace": "http://openconfig.net/yang/openconfig-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "ietf-inet-types",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-inet-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-network-instance",
"namespace": "http://openconfig.net/yang/network-instance",
"revision": "",
"conformance-type": "implement",
"submodule": [
{
"name": "openconfig-network-instance-l2",
"revision": ""
}
]
},
{
"name": "openconfig-network-instance-types",
"namespace": "http://openconfig.net/yang/network-instance-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-local-routing",
"namespace": "http://openconfig.net/yang/local-routing",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-network-instance-l3",
"namespace": "http://openconfig.net/yang/network-instance-l3",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-vlan",
"namespace": "http://openconfig.net/yang/vlan",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-vlan-types",
"namespace": "http://openconfig.net/yang/vlan-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-evpn-types",
"namespace": "http://openconfig.net/yang/evpn-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-evpn",
"namespace": "http://openconfig.net/yang/evpn",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-inet-types",
"namespace": "http://openconfig.net/yang/types/inet",
"revision": "",
"conformance-type": "implement"
},
{
"name": "iana-if-type",
"namespace": "urn:ietf:params:xml:ns:yang:iana-if-type",
"revision": "",
"conformance-type": "implement"
},
{
"name": "ietf-interfaces",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-interfaces",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-platform-types",
"namespace": "http://openconfig.net/yang/platform-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-policy-types",
"namespace": "http://openconfig.net/yang/policy-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "ietf-yang-types",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-yang-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-rib-bgp-types",
"namespace": "http://openconfig.net/yang/rib/bgp-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-segment-routing-types",
"namespace": "http://openconfig.net/yang/segment-routing/srte-policy",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-aft-types",
"namespace": "http://openconfig.net/yang/fib-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-ospf-types",
"namespace": "http://openconfig.net/yang/ospf-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-aft",
"namespace": "http://openconfig.net/yang/aft",
"revision": "",
"conformance-type": "implement",
"submodule": [
{
"name": "openconfig-aft-ipv4",
"revision": ""
},
{
"name": "openconfig-aft-ipv6",
"revision": ""
},
{
"name": "openconfig-aft-mpls",
"revision": ""
},
{
"name": "openconfig-aft-pf",
"revision": ""
},
{
"name": "openconfig-aft-ethernet",
"revision": ""
},
{
"name": "openconfig-aft-common",
"revision": ""
}
]
},
{
"name": "openconfig-ospfv2",
"namespace": "http://openconfig.net/yang/ospfv2",
"revision": "",
"conformance-type": "implement",
"submodule": [
{
"name": "openconfig-ospfv2-global",
"revision": ""
},
{
"name": "openconfig-ospfv2-area",
"revision": ""
},
{
"name": "openconfig-ospfv2-area-interface",
"revision": ""
},
{
"name": "openconfig-ospfv2-common",
"revision": ""
},
{
"name": "openconfig-ospfv2-lsdb",
"revision": ""
}
]
},
{
"name": "openconfig-mpls-sr",
"namespace": "http://openconfig.net/yang/mpls-sr",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-srte-policy",
"namespace": "http://openconfig.net/yang/segment-routing-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-segment-routing",
"namespace": "http://openconfig.net/yang/sr",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-routing-policy",
"namespace": "http://openconfig.net/yang/routing-policy",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-bfd",
"namespace": "http://openconfig.net/yang/bfd",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-yang-types",
"namespace": "http://openconfig.net/yang/types/yang",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-rib-bgp-ext",
"namespace": "http://openconfig.net/yang/rib/bgp-ext",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-8021x",
"namespace": "http://openconfig.net/yang/interfaces/8021x",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-types",
"namespace": "http://openconfig.net/yang/openconfig-if-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-ip-ext",
"namespace": "http://openconfig.net/yang/interfaces/ip-ext",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-tunnel",
"namespace": "http://openconfig.net/yang/interfaces/tunnel",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-bgp-policy",
"namespace": "http://openconfig.net/yang/bgp-policy",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-ethernet",
"namespace": "http://openconfig.net/yang/interfaces/ethernet",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-ip",
"namespace": "http://openconfig.net/yang/interfaces/ip",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-sdn-ext",
"namespace": "http://openconfig.net/interfaces/sdn-ext",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-aggregate",
"namespace": "http://openconfig.net/yang/interfaces/aggregate",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-mpls",
"namespace": "http://openconfig.net/yang/mpls",
"revision": "",
"conformance-type": "implement",
"submodule": [
{
"name": "openconfig-mpls-te",
"revision": ""
},
{
"name": "openconfig-mpls-igp",
"revision": ""
},
{
"name": "openconfig-mpls-static",
"revision": ""
}
]
},
{
"name": "openconfig-mpls-rsvp",
"namespace": "http://openconfig.net/yang/rsvp",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-mpls-ldp",
"namespace": "http://openconfig.net/yang/ldp",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-mpls-types",
"namespace": "http://openconfig.net/yang/mpls-types",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-ethernet-ext",
"namespace": "http://openconfig.net/yang/interfaces/ethernet-ext",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-if-poe",
"namespace": "http://openconfig.net/yang/poe",
"revision": "",
"conformance-type": "implement"
},
{
"name": "openconfig-interfaces",
"namespace": "http://openconfig.net/yang/interfaces",
"revision": "",
"conformance-type": "implement"
}
]
}
}
OK, two trivial fixes in the instance data first:
--- idata.json.old 2022-03-07 11:00:25.479638267 +0100
+++ idata.json 2022-03-07 10:51:56.660236241 +0100
@@ -18,7 +18,7 @@
},
"identifier" : "openconfig-policy-types:BGP",
"name" : "BGP",
- "openconfig-bgp:bgp" : {
+ "openconfig-network-instance:bgp" : {
"global" : {
"config" : {
"as" : 1234
@@ -73,7 +73,7 @@
"neighbor-address" : "1.1.1.1",
"timers" : {
"config" : {
- "hold-time" : 60
+ "hold-time" : "60"
}
}
}
But then I got this schema error:
Schema error: {/openconfig-network-instance:network-instances/network-instance[name="master"]/protocols/protocol[identifier="openconfig-policy-types:BGP"][name="BGP"]} config member-not-allowed: bgp
This is caused by this when statement in openconfig-network-instance.yang
:
when "./config/identifier = 'oc-pol-types:BGP'" {
...
}
This cannot work because the expression relies on literal string equality: in your JSON data you have
"identifier" : "openconfig-policy-types:BGP"
so the value (taken as a plain string) isn't equal to 'oc-pol-types:BGP'
.
This is exactly why YANG 1.1 introduced XPath functions derived-from()
and derived-from-or-self()
, see sec. 10.4 in RFC 7950. I don't know what's the openconfig answer to this issue.
Thanks @llhotka . After swapping out "openconfig-bgp:bgp" with "openconfig-network-instance:bgp", (the previous changes were already in place),
I am getting the following error - yangson.exceptions.SchemaError: {/} missing-data: expected 'openconfig-bgp:bgp'
I am curious as to why is keeps expecting the openconfig-bgp model?
Just guessing, but it looks like the openconfig-bgp
module has some top-level data that are mandatory, which in turn makes the container openconfig-bgp:bgp
mandatory.
@llhotka Thanks, it appears as though changing the conformance type from "implement" to "import" on all BGP models makes this validate correctly.
Will close this issue, thanks for the help so far.
I am getting the following error when trying to validate the below JSON data with openconfig-network-instance model. Yangson seems to be generating the dm object successfuilly, but raising RawMemberError.
Data:
{ "openconfig-network-instance:network-instances": { "network-instance": [ { "name": "master", "config": { "name": "master", "type": "openconfig-network-instance-types:DEFAULT_INSTANCE", "enabled": true }, "protocols": { "protocol": [ { "identifier": "openconfig-policy-types:BGP", "name": "BGP", "config": { "identifier": "openconfig-policy-types:BGP", "name": "BGP", "enabled": true }, "openconfig-bgp:bgp": { "global": { "config": { "as": 1234 } }, "neighbors": { "neighbor": [ { "neighbor-address": "1.1.1.1", "config": { "peer-group": "public-ipv4", "neighbor-address": "1.1.1.1", "enabled": true, "peer-as": 1001, "auth-password": "secret", "description": "ExampleISP" }, "timers": { "config": { "hold-time": 60 } }, "apply-policy": { "config": { "import-policy": [ "asd", "fgh", "abc" ], "export-policy": [ "filter-asd" ] } }, "afi-safis": { "afi-safi": [ { "afi-safi-name": "openconfig-bgp-types:IPV4_UNICAST", "config": { "afi-safi-name": "openconfig-bgp-types:IPV4_UNICAST", "enabled": true }, "ipv4-unicast": { "prefix-limit": { "config": { "max-prefixes": 1000 } } } } ] }, "enable-bfd": { "config": { "enabled": false } } } ] } } } ] } } ] } }
The following error is raised:
raise RawMemberError(npath) yangson.exceptions.RawMemberError: /openconfig-network-instance:network-instances/network-instance=master/protocols/protocol=openconfig-policy-types:BGP,BGP/openconfig-bgp:bgp