Help with pyangbind error: Loading json instance errors out
Hello,
Can someone please guide me. Following the below link. Intent is to load the received json object from the network element into the pyangbind class. It is erroring out.
https://github.com/robshakir/pyangbind
Steps followed
step-1
pyang --lax-quote-checks --plugindir $PYBINDPLUGIN -f pybind -o openconfig_interfaces.py openconfig-interfaces.yang openconfig-if-aggregate.yang openconfig-if-ethernet.yang openconfig-if-ip-ext.yang openconfig-if-ip.yang openconfig-vlan.yang iana-if-type.yang
content of a.json file
cat a.json { "openconfig-interfaces:interfaces": { "interface": [ { "name": "eth1/1", "config": { "description": "SE1", "enabled": false, "name": "eth1/1", "mtu": 1500, "type": "iana-if-type:ethernetCsmacd" } } ] } }
In [1]: from openconfig_interfaces import openconfig_interfaces
In [2]: oclr = openconfig_interfaces()
In [3]: In [10]: import pyangbind.lib.pybindJSON as pyb
In [35]: binding = openconfig_interfaces
In [36]: new_oclr = pyb.load("a.json",binding,"openconfig_interfaces")
AttributeError Traceback (most recent call last)
/ws/mgangaia-sjc/pyats-latest/lib/python3.6/site-packages/pyangbind/lib/pybindJSON.py in load(fn, parent_pymod, yang_module, path_helper, extmethods, overwrite) 76 raise pybindJSONIOError("could not open file to read: %s" % m) 77 return loads(f, parent_pymod, yang_module, path_helper=path_helper, ---> 78 extmethods=extmethods, overwrite=overwrite) 79 80
/ws/mgangaia-sjc/pyats-latest/lib/python3.6/site-packages/pyangbind/lib/pybindJSON.py in loads(d, parent_pymod, yang_base, path_helper, extmethods, overwrite) 56 d = json.loads(d, object_pairs_hook=OrderedDict) 57 return pybindJSONDecoder.load_json(d, parent_pymod, yang_base, ---> 58 path_helper=path_helper, extmethods=extmethods, overwrite=overwrite) 59 60
/ws/mgangaia-sjc/pyats-latest/lib/python3.6/site-packages/pyangbind/lib/serialise.py in load_json(d, parent, yang_base, obj, path_helper, extmethods, overwrite, skip_unknown) 222 if obj is None: 223 # we need to find the class to create, as one has not been supplied. --> 224 base_mod_cls = getattr(parent, safe_name(yang_base)) 225 tmp = base_mod_cls(path_helper=False) 226
AttributeError: type object 'openconfig_interfaces' has no attribute 'openconfig_interfaces'
In [37]:
Thanjkis,