cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1179
Views
1
Helpful
7
Replies

Using YDK bgp sessions.session giving output empty list

Hi ,

Using YDK , i am 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$

7 Replies 7

saalvare
Cisco Employee
Cisco Employee

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

HI Santiago,

Thanks for your prompt reply . Have you verified the script in which Router series . We have verified on NCS5500 series router and get the empty list (None value)for the same script

Kindly let us know the details which router model verified the above script

Thanks

Jay

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?

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.

HI Santiago ,

Thank you for your response .

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 .

Please let us know if any inputs

Thanks

Jay

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.  As I mentioned before, the XR engineers will provide a fix.

Hi Santiago,

Thank you  for your prompt response !!! we will consider the feedback given .

Also we would like to know that , is there any defect package needs to  install in router to support YDK models.

"ncs5500-bgp-1.1.0.4-r613113I.CSCvc57253" ---Package


is the above package is mandatory to get the output


Please clarify


Thanks

Jay

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: