05-16-2017 10:57 PM
Hi Team,
i tried to bring isis neighbour ship using ydk , Could you please help , where i wrong here ?.
>>> crud
<ydk.services.crud_service.CRUDService object at 0x2aad98d244a8>
>>> isis
<ydk.models.cisco_ios_xr.Cisco_IOS_XR_clns_isis_oper.Isis object at 0x2aad99336908>
>>>
>>> obj=crud.read(ncc,isis)
>>> obj
<ydk.models.cisco_ios_xr.Cisco_IOS_XR_clns_isis_oper.Isis object at 0x2aada85694a8>
>>> obj.instances.instance
[<ydk.models.cisco_ios_xr.Cisco_IOS_XR_clns_isis_oper.Isis.Instances.Instance object at 0x2aada85775f8>]
>>>
>>> dir(obj.instances.instance)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'name', 'parent', 'pop', 'remove', 'reverse', 'sort']
>>> obj.instances.instance.HostNames
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'YList' object has no attribute 'HostNames'
>>>
thanks
Bala
05-17-2017 04:02 AM
Bala,
obj.instances.instance is a list (per error message). Try something like:
for inst in obj.instances.instance:
for hostname in i.host_names.host_name:
print(hostname.host_name)
Please note I may have got some of the variable names wrong, but this should give you the general idea
Cheers,
Einar
05-17-2017 08:32 AM
You may find these ISIS config examples useful:
You can also find ISIS oper examples at:
A brief description of these sample apps can be found at:
https://github.com/CiscoDevNet/ydk-py-samples/tree/master/samples/
HTH.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide