Closed dasomeom closed 5 years ago
The script sends to CRUD service non-top-level container entity on delete operation. The YDK fails due to two reasons:
The corrected script for 'mpls' container delete operation should mark the mpls entity with YFiletr.delete and send to the CRUD the top-level entity, which is 'network-instance':
import argparse
import logging
from urllib.parse import urlparse
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.models.ydktest_oc_nis import openconfig_network_instance as oc_network_instance
from ydk.filters import YFilter
from test_utils import enable_logging
def config_nis():
"""Build network instance configuration"""
# configure default network instance
nis = oc_network_instance.NetworkInstances()
network_instance = oc_network_instance.NetworkInstances.NetworkInstance()
network_instance.name = "default"
network_instance.config.name = "default"
nis.network_instance.append(network_instance)
return nis
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", help="print debugging messages",
action="store_true")
parser.add_argument("device",
help="NETCONF device (ssh://user:password@host:port)")
args = parser.parse_args()
device = urlparse(args.device)
if args.verbose:
enable_logging(logging.INFO)
# create NETCONF provider
provider = NetconfServiceProvider(address=device.hostname,
port=device.port,
username=device.username,
password=device.password,
protocol=device.scheme)
# create CRUD service
crud = CRUDService()
# NIS configuration
network_instances = config_nis() # configuration
# execute CRUD operation
network_instances.network_instance['default'].mpls.yfilter = YFilter.delete
crud.update(provider, network_instances)
Runing results:
/home/yan/.virtualenvs/ydk81/bin/python /home/yan/ydk-workspace/ydk-gen/scripts/tests/issues/test_931.py -v ssh://admin:admin@10.30.110.84:830
2019-07-17 17:24:07,327 - ydk - INFO - Path where models are to be downloaded: /home/yan/.ydk/10.30.110.84
2019-07-17 17:24:07,338 - ydk - INFO - Connected to 10.30.110.84 on port 830 using ssh with timeout of -1
2019-07-17 17:24:07,356 - ydk - INFO - Executing CRUD update operation on [openconfig-network-instance:network-instances]
2019-07-17 17:24:07,356 - ydk - INFO - Executing 'edit-config' RPC on [openconfig-network-instance:network-instances]
2019-07-17 17:24:07,457 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Reached limit (65535) for storing typedefs.
2019-07-17 17:24:07,457 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "cisco-xr-openconfig-network-instance-deviations" parsing failed.
2019-07-17 17:24:07,474 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Reached limit (65535) for storing typedefs.
2019-07-17 17:24:07,474 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "cisco-xr-openconfig-network-instance-deviations" parsing failed.
2019-07-17 17:24:07,482 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<target>
<candidate/>
</target>
<config><network-instances xmlns="http://openconfig.net/yang/network-instance" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge">
<network-instance>
<name>default</name>
<config>
<name>default</name>
</config>
<mpls nc:operation="delete"/>
</network-instance>
</network-instances>
</config>
</edit-config>
</rpc>
2019-07-17 17:24:07,848 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
<ok/>
</rpc-reply>
2019-07-17 17:24:07,848 - ydk - INFO - Executing 'commit' RPC
2019-07-17 17:24:07,848 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
</rpc>
2019-07-17 17:24:14,403 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<ok/>
</rpc-reply>
2019-07-17 17:24:14,403 - ydk - INFO - Operation succeeded
2019-07-17 17:24:14,403 - ydk - INFO - Disconnected from device
Process finished with exit code 0
Fixed in this commit to 0.8.4 branch.
/home/yan/.virtualenvs/ydk81/bin/python /home/yan/ydk-workspace/ydk-gen/scripts/issues/test_931.py -v ssh://admin:admin@10.30.110.84:830
2019-07-18 15:24:42,598 - ydk - INFO - Path where models are to be downloaded: /home/yan/.ydk/10.30.110.84
2019-07-18 15:24:42,610 - ydk - INFO - Connected to 10.30.110.84 on port 830 using ssh with timeout of -1
2019-07-18 15:24:42,629 - ydk - INFO - Executing CRUD delete operation on [mpls]
2019-07-18 15:24:42,629 - ydk - INFO - Executing 'edit-config' RPC on [mpls]
2019-07-18 15:24:42,734 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Reached limit (65535) for storing typedefs.
2019-07-18 15:24:42,734 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "cisco-xr-openconfig-network-instance-deviations" parsing failed.
2019-07-18 15:24:42,751 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Reached limit (65535) for storing typedefs.
2019-07-18 15:24:42,751 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "cisco-xr-openconfig-network-instance-deviations" parsing failed.
2019-07-18 15:24:42,759 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<target>
<candidate/>
</target>
<config><network-instances xmlns="http://openconfig.net/yang/network-instance" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<network-instance>
<name>default</name>
<config>
<name>default</name>
</config>
<mpls nc:operation="delete"/>
</network-instance>
</network-instances>
</config>
</edit-config>
</rpc>
2019-07-18 15:24:43,099 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
<ok/>
</rpc-reply>
2019-07-18 15:24:43,100 - ydk - INFO - Executing 'commit' RPC
2019-07-18 15:24:43,103 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
</rpc>
2019-07-18 15:24:43,522 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<ok/>
</rpc-reply>
2019-07-18 15:24:43,523 - ydk - INFO - Operation succeeded
2019-07-18 15:24:43,524 - ydk - INFO - Disconnected from device
Process finished with exit code 0
Expected Behavior
crud.delete
should allow you to delete a container in an element list.Current Behavior
Execution fails with the following error:
Your Script
Logs
Enable logging and post the logs below
System Information