11-01-2020 11:04 PM
hi,
I need to get only vrf operational data under BGP, but am getting an error when I try to read it. Please guide me on how I can get the required output
Traceback (most recent call last):
File "assurance_master.py", line 149, in <module>
bgp_oper_main(device_netconf ,device_input)
File "assurance_master.py", line 108, in bgp_oper_main
crud_service.read(device_netconf,bgp_oper_active_instance_vrf_list_obj)
File "/usr/local/lib/python3.5/dist-packages/ydk/services/crud_service.py", line 63, in read
top_filters = _get_top_level_entity(filters, provider.get_session().get_root_schema())
File "/usr/local/lib/python3.5/dist-packages/ydk/entity_utils/entity_utils.py", line 216, in _get_top_level_entity
data_node = get_data_node_from_entity(top_entity, root_schema)
RuntimeError: YInvalidArgumentError: ancestor for entity cannot be nullptr as one of the ancestors is a list. Path: vrfs
Disconnected from device
11-02-2020 08:20 PM
Hello arynair
1. When building model objects you have to keep in mind that all container and list related objects are already initialized in the parent object instances. As example for your script, the instances container object under bgp_oper_obj has already been instantiated and can be referenced as bgp_oper_obj.instances.
2. When building a list you have to instantiate list element objects and explicitly set all keys of the element. Then you add the list element object to the list object, which is automatically instantiated as container objects.
Considering the above notes your object building would look like this:
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_bgp_oper as xr_ipv4_bgp_oper
import logging
def enable_logging(level):
log = logging.getLogger('ydk')
log.setLevel(level)
handler = logging.StreamHandler()
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
log.addHandler(handler)
def build_bgp_vrf_obj():
bgp_oper_obj = xr_ipv4_bgp_oper.Bgp()
bgp_oper_instance_list_obj = xr_ipv4_bgp_oper.Bgp.Instances.Instance()
bgp_oper_instance_list_obj.instance_name = 'default'
bgp_oper_obj.instances.instance.append(bgp_oper_instance_list_obj)
bgp_oper_active_instance_vrf_list_obj = xr_ipv4_bgp_oper.Bgp.Instances.Instance.InstanceActive.Vrfs.Vrf()
bgp_oper_active_instance_vrf_list_obj.vrf_name = "TEST-VRF"
bgp_oper_instance_list_obj.instance_active.vrfs.vrf.append(bgp_oper_active_instance_vrf_list_obj)
return bgp_oper_instance_list_obj
if __name__ == '__main__':
enable_logging(logging.INFO)
provider = NetconfServiceProvider(
address='sbx-iosxr-mgmt.cisco.com',
port=10000,
username='admin',
password='C1sco12345')
crud = CRUDService()
bgp_vrf_obj = build_bgp_vrf_obj()
vrf_oper = crud.read(provider, bgp_vrf_obj)
11-03-2020 06:27 PM - edited 11-03-2020 08:10 PM
Hi Yan,
Facing Ycode error when trying to read all bgp oper info with top level object. (No filter)
The code breaks with same error.
bgp_oper_obj = xr_ipv4_bgp_oper.Bgp()
I mean when only this line is in the code, not including others.
Couldn't fetch child entity extended-nh-encoding-capability-suppressed-info in parent /Cisco-IOS-XR-ipv4-bgp-oper:bgp/config-instances/config-instance[instance-name='default']/config-instance-default-vrf/entity-configurations/entity-configuration[1]/af-independent-config!
Traceback (most recent call last):
File "assurance_master.py", line 165, in <module>
bgp_oper_main(device_netconf ,device_input)
File "assurance_master.py", line 122, in bgp_oper_main
a = crud_service.read(device_netconf,bgp_oper_instance_list_obj)
File "/usr/local/lib/python3.5/dist-packages/ydk/services/crud_service.py", line 65, in read
read_top_entity = self._crud.read(provider, top_filters)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.5/dist-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
_raise(_exc)
File "/usr/local/lib/python3.5/dist-packages/ydk/errors/error_handler.py", line 54, in _raise
exec("raise exc from None")
File "<string>", line 1, in <module>
ydk.errors.YCoreError: Couldn't fetch child entity 'extended-nh-encoding-capability-suppressed-info' in parent /Cisco-IOS-XR-ipv4-bgp-oper:bgp/config-instances/config-instance[instance-name='default']/config-instance-default-vrf/entity-configurations/entity-configuration[1]/af-independent-config
Thanks
11-04-2020 09:18 AM
Sorry, I cannot help you being outside Cisco, because I do not have access to your router and public XR sandbox does not have BGP configuration.
11-06-2020 02:53 PM
What XR bundle version are you using? What XR version is running on the device?
11-08-2020 07:40 PM - edited 11-08-2020 08:04 PM
xr version on device is 7.0.2, xr bundle version on ydk is 6.6.2
I am having similar trouble with the rib-ipv4-oper module as well:
attaching log for the filter, and output received before the code breaks. I am trying to retrieve the route information, so it would be great if could get help in bypassing the error
11-09-2020 09:06 AM
I could not reproduce your issue with YDK-0.8.5. PFA my script and log files.
Please note that there were multiple bug fixes since 0.8.3, which potentially could affect the results.
I suggest you upgrade your YDK (currently available only on GitHub) and repeat your tests. Alternatively you can try the tests on Docker.
11-09-2020 09:36 PM
Hi Yang,
I am facing the same issue when running the script on docker for ydk 0.8.5
ydk (0.8.5)
ydk-models-cisco-ios-xr (6.6.3.post1)
ydk-models-ietf (0.1.5.post2)
ydk-models-openconfig (0.1.8)
ydk-service-gnmi (0.4.0.post5)
this is the current environment
and error is :ydk.errors.YCoreError: Couldn't fetch child entity 'l2-info' in parent /Cisco-IOS-XR-ip-rib-ipv4-oper:rib/vrfs/vrf[vrf-name='default']/afs/af[af-name='IPv4']/safs/saf[saf-name='Unicast']/ip-rib-route-table-names/ip-rib-route-table-name[route-table-name='default']/routes/route[address='0.0.0.0'][prefix-length='0']/route-path/ipv4-rib-edm-path[1]
PFA the logs
11-11-2020 10:26 AM
11-30-2020 01:08 AM
hi Yan,
i was not able to resolve the issue and used alternate method using ncclient
Thanks,
Arya
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