cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1855
Views
2
Helpful
10
Replies

bgp_oper error

 

Hi,

want to READ just extended communites and networks from bgp_oper model. Nothing more. But I face some problem with vrf.vrf_name = READ() object. It works for one VRF if I put the name explicitly but it doesnt work with READ() object. Can you please help me?

thanks

 

1 Accepted Solution

Accepted Solutions

Thanks. Currently, YDK does not support read filters for nested lists with no keys. We only support not providing the key for the deepest list in the nested hierarchy. We will be adding support for this in the future. This issue is tracking it.

View solution in original post

10 Replies 10

abhirame
Cisco Employee
Cisco Employee

Can you please add the script which you are trying to run?

Thanks

Hi, pls check attached bgp_oper.py in original post.

Thanks! The READ object can be used with non-key leafs. If you want to read only the networks under a BGP instance, please try the below:

bgp = Cisco_IOS_XR_ipv4_bgp_oper.Bgp()

instance = Cisco_IOS_XR_ipv4_bgp_oper.Bgp.Instances.Instance()

instance.instance_name = 'default'

vrf = Cisco_IOS_XR_ipv4_bgp_oper.Bgp.Instances.Instance.InstanceActive.Vrfs.Vrf()

vrf.vrf_name = 'default'

af = Cisco_IOS_XR_ipv4_bgp_oper.Bgp.Instances.Instance.InstanceActive.Vrfs.Vrf.Afs.Af()

af.af_name = Cisco_IOS_XR_ipv4_bgp_datatypes.BgpAddressFamilyEnum.ipv4_unicast

network = Cisco_IOS_XR_ipv4_bgp_oper.Bgp.Instances.Instance.InstanceActive.Vrfs.Vrf.Afs.Af.Networks.Network()


af.networks.network.append(network)

vrf.afs.af.append(af)

instance.instance_active.vrfs.vrf.append(vrf)

bgp.instances.instance.append(instance)

bgp_networks = crud.read(provider, network)

hi,

same error also with network object for vrf default. I think it's due to common_attributes was part of network object too.


Traceback (most recent call last):

  File "CAD/bgp_oper.py", line 42, in <module>

    bgp_routes = crud.read(provider, network)

  File "/usr/local/lib/python3.5/dist-packages/ydk/services/crud_service.py", line 150, in read

    payload = self._execute_crud_operation_on_provider(provider, read_filter, 'READ', only_config)

  File "/usr/local/lib/python3.5/dist-packages/ydk/services/crud_service.py", line 167, in _execute_crud_operation_on_provider

    operation

  File "/usr/local/lib/python3.5/dist-packages/ydk/services/service.py", line 36, in execute_payload

    reply = provider.execute(payload, operation)

  File "/usr/local/lib/python3.5/dist-packages/ydk/providers/netconf_provider.py", line 94, in execute

    return self.sp_instance.execute_operation(payload, operation)

  File "/usr/local/lib/python3.5/dist-packages/ydk/providers/_provider_plugin.py", line 224, in execute_operation

    return self._handle_rpc_reply(operation, payload, reply.xml)

  File "/usr/local/lib/python3.5/dist-packages/ydk/providers/_provider_plugin.py", line 246, in _handle_rpc_reply

    self._handle_rpc_error(payload, reply_str, pathlist)

  File "/usr/local/lib/python3.5/dist-packages/ydk/providers/_provider_plugin.py", line 259, in _handle_rpc_error

    raise YPYServiceProviderError(error_code=YPYErrorCode.SERVER_REJ, error_msg=reply_str)

ydk.errors.YPYServiceProviderError: Server rejected request.

error-type: application

error-tag: operation-failed

error-severity: error

error-path: ns1:bgp/ns1:instances/ns1:instance[instance-name = 'default']/ns1:instance-active/ns1:vrfs/ns1:vrf[vrf-name = 'default']/ns1:afs/ns1:af[af-name = 'ipv4-unicast']/ns1:networks/ns1:network

error-message: 'YANG framework' detected the 'fatal' condition 'Operation failed'

OK. Are you able to run a <get> RPC for the same data using netconf? If so do you have the XML snippet for this?

Hi, not sure if doing it right with ncclient, as I am not very familiar with it and also not with rpc, but I am able to get list of vrfs, but list of networks is empty, details in attachment. thanks a lot

Michal,

You're using ncclient correctly (BTW, I can also suggest that you may want to take a look at GitHub - CiscoDevNet/ncc: ncclient scripts and helpers; the script ncc.py provides a way to work with "snippets" of lower-level XML config)

However, the request may not be quite correct. The form you have used only asks the platform to return the element <vrf-name>. Can you instead try something like:

                    <bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-oper">

                        <instances>

                            <instance>

                                <instance-active>

                                    <vrfs>

                                        <vrf>

                                            <afs>

                                              <af>

                                                <networks>

                                                  <network>

                                                    <network/>

                                                  </network>

                                                </networks>

                                              </af>

                                            </afs>

                                        </vrf>

                                    </vrfs>

                                </instance-active>

                            </instance>

                        </instances>

                    </bgp>

This should return the inet:ip-prefix for all AFs and networks under all VRFs.

Cheers,

Einar

Thanks. Currently, YDK does not support read filters for nested lists with no keys. We only support not providing the key for the deepest list in the nested hierarchy. We will be adding support for this in the future. This issue is tracking it.

Hello again,

I was trying to retrieve the networks from BGP in the default vrf table . I understand that because of the bug Need to support read filters for nested lists with no keys · Issue #399 · CiscoDevNet/ydk-gen · GitHub I cannot set the value in the last nested class. But even with this workaround I am unable to retrieve the list of networks.

This is the test code

#!/usr/bin/env python

from ydk.services import CRUDService, CodecService, NetconfService, Datastore

from ydk.providers import CodecServiceProvider, NetconfServiceProvider

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_bgp_oper \

    as xr_ipv4_bgp_oper

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_bgp_datatypes \

    as xr_ipv4_bgp_datatypes

from ydk.types import Empty, YList, YLeafList, DELETE, Decimal64, FixedBitsDict, READ

import logging

#get operational data for BGP -option 1

bgp1 = xr_ipv4_bgp_oper.Bgp()

instance = bgp1.instances.Instance()

instance.instance_name = "default"

default_vrf = instance.instance_active.default_vrf

af = default_vrf.afs.Af()

af.af_name = xr_ipv4_bgp_datatypes.BgpAddressFamilyEnum.ipv4_unicast

network1 = af.networks.Network()

#network1.network = "192.168.0.100/32"

af.networks.network.append(network1)

default_vrf.afs.af.append(af)

bgp1.instances.instance.append(instance)

# create NETCONF provider

provider = NetconfServiceProvider(address="172.16.1.1",

                                  port="830",

                                  username="cisco",

                                  password="cisco",

                                  protocol="ssh")

# create codec provider

codec_provider = CodecServiceProvider(type="xml")

#creating crud & codec service

crud = CRUDService()

codec = CodecService()

#read operational data

networks = crud.read(provider,network1)

print codec.encode(codec_provider,networks)

#close session

provider.close()

codec_provider.close()

Hi Mufaddal,

Can you try the below?

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_bgp_oper as xr_ipv4_bgp_oper

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_bgp_datatypes as xr_ipv4_bgp_datatypes

bgp = xr_ipv4_bgp_oper.Bgp()

i = xr_ipv4_bgp_oper.Bgp.Instances.Instance()

i.instance_name='default'

af = xr_ipv4_bgp_oper.Bgp.Instances.Instance.InstanceActive.DefaultVrf.Afs.Af()

af.af_name = xr_ipv4_bgp_datatypes.BgpAddressFamilyEnum.ipv4_unicast

n = xr_ipv4_bgp_oper.Bgp.Instances.Instance.InstanceActive.DefaultVrf.Afs.Af.Networks.Network()

af.networks.network.append(n)

i.instance_active.default_vrf.afs.af.append(af)

bgp.instances.instance.append(i)

result=crud.read(provider,n)

Results in below RPC:

2017-07-25 15:11:02,575 - ydk.services.crud_service - INFO - READ operation initiated

2017-07-25 15:11:02,576 - ydk.providers._provider_plugin - DEBUG -

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:b177072e-68d9-442a-a9c7-1fe478a762ba">

  <get>

    <filter type="subtree">

      <bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-oper">

        <instances>

          <instance>

            <instance-name>default</instance-name>

            <instance-active>

              <default-vrf>

                <afs>

                  <af>

                    <af-name>ipv4-unicast</af-name>

                    <networks>

                      <network/>

                    </networks>

                  </af>

                </afs>

              </default-vrf>

            </instance-active>

          </instance>

        </instances>

      </bgp>

    </filter>

  </get>

</rpc>

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: