Using YDK,trying to get output of bgp sessions.session (equivalent CLI - show bgp sessions)
Script
--------
from ydk.services import CRUDService,CodecService
from ydk.providers import NetconfServiceProvider,CodecServiceProvider
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_shellutil_oper as xr_shellutil_oper
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_bgp_oper
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_bgp_datatypes
from datetime import timedelta
from ydk.types import READ
provider = NetconfServiceProvider(address="192.168.10.10",
username="user1",
password="pass1",
protocol="ssh")
crud = CRUDService()
q_instance = Cisco_IOS_XR_ipv4_bgp_oper.Bgp.Instances.Instance()
q_instance.instance_name = 'default'
q_instances = Cisco_IOS_XR_ipv4_bgp_oper.Bgp.Instances()
q_instances.instance.append(q_instance)
instances = crud.read(provider, q_instances)
for inst in instances.instance:
print('Instance: %s' % inst.instance_name)
default_vrf = inst.instance_active.default_vrf
print dir(default_vrf)
print dir(default_vrf.sessions.session)
for n in default_vrf.sessions.session:
print "done"
node=n.neighbor_address
print(' neighbor %s' % n.neighbor_address)
print(' remote-as: %s' % n.remote_as)
provider.close()
Script output after executing
----------------------------------------
fabric@FabricAutomation:~/jay$ sudo python bgp_einar.py
Instance: default []
----------------------------------------------------------------------------------------------------> Empty list we are getting.
fabric@FabricAutomation:~/jay$
What XR version are you using on the device? What YDK version are you using (pip list | grep ydk)? Your script provides this output for me on a device running XR 6.2.1:
Instance: default
['Afs', 'Bmp', 'GlobalProcessInfo', 'Information', 'MessageLogs', 'NeighborRanges', 'Neighbors', 'NextHopVrf', 'Postits', 'ProcessInfo', 'Sessions', 'UpdateInboundErrorNeighbors', 'UpdateInboundErrorVrf', 'UpdateInboundFilterNeighbors', 'UpdateInboundFilterVrf', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_common_path', '_has_data', '_meta_info', '_prefix', '_revision', 'afs', 'bmp', 'global_process_info', 'i_meta', 'information', 'is_config', 'message_logs', 'neighbor_ranges', 'neighbors', 'next_hop_vrf', 'parent', 'postits', 'process_info', 'sessions', 'update_inbound_error_neighbors', 'update_inbound_error_vrf', 'update_inbound_filter_neighbors', 'update_inbound_filter_vrf'] ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__dict__', '__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__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'append', 'count', 'extend', 'index', 'insert', 'name', 'parent', 'pop', 'remove', 'reverse', 'sort'] done neighbor 172.16.255.2 remote-as: 65001
It was run against an XRv9K (virtual) router running XR 6.2.1.
What version of software are you using on your device. What is your BGP CLI configuration.
Have verified on NCS5500 series router and get the empty list (None value)for the same script. Want to know the details which router model verified the above script.
The issue here isn't really related to YDK. It seems to be specific to the hardware/software combination on your router. The XR engineering team should be able to provide a fix.
Our NCS 5500 router version is below .
RP/0/RP0/CPU0:l1#show version
Thu Apr 20 00:33:14.841 EDT
Cisco IOS XR Software, Version 6.1.31.13I
Copyright (c) 2013-2016 by Cisco Systems, Inc.
Build Information:
Built By : hlo
Built On : Thu Apr 13 23:56:37 PDT 2017
Build Host : iox-lnx-049
Workspace : /auto/iox-lnx-049-san1/production/6.1.31.13I.DT_IMAGE/ncs5500/workspace
Version : 6.1.31.13I
Location : /opt/cisco/XR/packages/
cisco NCS-5500 () processor
System uptime is 5 hours, 14 minutes
RP/0/RP0/CPU0:#
YDK version is 6.2.1
Here router version is 6.1.31 and YDK version is 6.2.1 .
Is it due to version mismatch , because our script is working with your virtual router .
No, it's not due to version difference. It's related to a software defect in your version of Cisco IOS XR. That defect isn't present in 6.2.1. Asmentioned before, the XR engineers will provide a fix.
Comments
0 comments
Please sign in to leave a comment.