Trying to use Python to print out the result of a CRUD read in xml format. The following works perfectly:
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_l2vpn_oper as L2VpnOper
def get_xconnect(provider, crud):
base_obj = L2VpnOper.L2Vpn.Xconnects.Xconnect()
base_data = crud.read(provider, base_obj)
When the value of “base_obj” is changed to the following, a proper read request is sent but getting a timeout (possibly because the resulting object has too much information to populate in the allotted time – is this the case.):
def get_xconnect(provider, crud):
base_obj = L2VpnOper.L2VpnForwarding.Nodes.Node()
base_data = crud.read(provider, base_obj)
output:
READ operation initiated
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:a18cbaf9-c8b9-4af9-b775-08ee13c96a62">
<get>
<filter type="subtree">
<l2vpn-forwarding xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-l2vpn-oper">
<nodes>
<node/>
</nodes>
</l2vpn-forwarding>
</filter>
</get>
</rpc>
after some time …
READ operation completed
Traceback (most recent call last):
. . .
. . .
File "/auto/cafy_dev/cafykit/exec/lib/python3.4/site-packages/ncclient/operations/rpc.py", line 345, in _request
raise TimeoutExpiredError('ncclient timed out while waiting for an rpc reply.')
ncclient.operations.errors.TimeoutExpiredError: ncclient timed out while waiting for an rpc reply.
Tried to initialize “base_obj” to a child class of L2VpnForwarding.Nodes.Node to see if the timeout would still occur, but got an INVALID_HIERARCHY_PARENT error instead.
def get_xconnect(provider, crud):
base_obj = L2VpnOper.L2VpnForwarding.Nodes.Node.L2FibBridgeDomains.L2FibBridgeDomain()
base_data = crud.read(provider, base_obj)
output:
READ operation initiated
YPYErrorCode.INVALID_HIERARCHY_PARENT
READ operation completed
Traceback (most recent call last):
File "mpls_te_demo.py", line 588, in <module>
get_xconnect_output = get_xconnect(provider, crud)
File "mpls_te_demo.py", line 466, in get_xconnect
base_data = crud.read(provider, base_obj)
File "/auto/cafy_dev/cafykit/exec/lib/python3.4/site-packages/ydk/services/crud_service.py", line 150, in read
payload = self._execute_crud_operation_on_provider(provider, read_filter, 'READ', only_config)
File "/auto/cafy_dev/cafykit/exec/lib/python3.4/site-packages/ydk/services/crud_service.py", line 166, in _execute_crud_operation_on_provider
-----
self._raise_parent_hierarchy_error()
File "/auto/cafy_dev/cafykit/exec/lib/python3.4/site-packages/ydk/providers/_provider_plugin.py", line 520, in _raise_parent_hierarchy_error
raise YPYServiceProviderError(error_code=YPYErrorCode.INVALID_HIERARCHY_PARENT)
ydk.errors.YPYServiceProviderError: Parent is not set.
Parent Hierarchy cannot be determined.
This has happened with every child class of L2VpnForwarding.Nodes.Node . Copied straight from the YDK documentation, so the class names are correct.
How to deal with this INVALID_HIERARCHY_PARENT error..
You can specify your timeout (default 60s) for the NETCONF service provider. For instance:
provider = NetconfServiceProvider(address=10.0.0.1, port=830, username='admin', password='admin', protocol='ssh', timeout=120)
This is very helpful for the timeout issue. Any idea about the INVALID_HIERARCHY_PARENT error discussed below it.
ydk.errors.YPYServiceProviderError: Parent is not set. Parent Hierarchy cannot be determined
It seems like it complains about missing key value for L2VpnOper.L2VpnForwarding.Nodes.Node. Maybe an issue related to #399.
A related discussion could be found here.
And as suggested in the issue and the discussion, you might need to instantiate L2VpnForwarding.Nodes.Node and append base_obj to the corresponding attribute for this object.
Comments
0 comments
Please sign in to leave a comment.