03-08-2017 04:14 AM
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
Solved! Go to Solution.
03-10-2017 09:54 AM
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.
03-08-2017 07:55 AM
Can you please add the script which you are trying to run?
Thanks
03-08-2017 08:42 AM
Hi, pls check attached bgp_oper.py in original post.
03-08-2017 09:48 AM
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)
03-09-2017 04:36 AM
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'
03-09-2017 01:54 PM
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?
03-09-2017 03:15 PM
03-10-2017 04:03 AM
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
03-10-2017 09:54 AM
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.
07-17-2017 08:23 AM
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()
07-25-2017 03:14 PM
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>
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