CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
137 stars 74 forks source link

Try to delete one specific interface but all are deleted with CRUD delete and Cisco_IOS_XR_ifmgr_cfg model #1039

Closed icarus78 closed 3 years ago

icarus78 commented 3 years ago

Hi

I have successfully applied the "nc-create-xr-ifmgr-cfg-32-ydk.py" example to create a loopback interface on an XR device https://github.com/CiscoDevNet/ydk-py-samples/blob/master/samples/basic/crud/models/cisco-ios-xr/Cisco-IOS-XR-ifmgr-cfg/nc-create-xr-ifmgr-cfg-32-ydk.py

Now, I want to remove that specific loopback interface, but when using the same model with the "crud.delete" operation, all interfaces on the devices are deleted, although the XML output shows that only Loopback200 is on the RPC message sent to the device.

What I am missing here to delete only the specific loopback interface?.

Thanks

Configuration commited on the device via NETCONF

RP/0/RSP0/CPU0:F241.03.19-ASR9001-1#show configuration commit changes last 1 Mon Dec 28 23:31:38.556 UTC Building configuration... !! IOS XR Configuration 6.4.2 no interface Loopback0 no interface Loopback200 no interface MgmtEth0/RSP0/CPU0/0 no interface MgmtEth0/RSP0/CPU0/1 no interface GigabitEthernet0/0/0/0 no interface GigabitEthernet0/0/0/1 no interface GigabitEthernet0/0/0/2 no interface GigabitEthernet0/0/0/3 no interface GigabitEthernet0/0/0/4 no interface GigabitEthernet0/0/0/5 no interface GigabitEthernet0/0/0/6 no interface GigabitEthernet0/0/0/7 no interface GigabitEthernet0/0/0/8 no interface GigabitEthernet0/0/0/9 no interface GigabitEthernet0/0/0/10 no interface GigabitEthernet0/0/0/11 no interface GigabitEthernet0/0/0/12 no interface GigabitEthernet0/0/0/13 no interface GigabitEthernet0/0/0/14 no interface GigabitEthernet0/0/0/15 no interface GigabitEthernet0/0/0/16 no interface GigabitEthernet0/0/0/17 no interface GigabitEthernet0/0/0/18 no interface GigabitEthernet0/0/0/19 no interface TenGigE0/0/2/0 no interface TenGigE0/0/2/1 no interface TenGigE0/0/2/2 no interface TenGigE0/0/2/3 end

Your Script

from ydk.services import CRUDService from ydk.providers import NetconfServiceProvider from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ifmgr_cfg \ as xr_ifmgr_cfg

provider = NetconfServiceProvider( ... ) crud = CRUDService()

interface_configurations = xr_ifmgr_cfg.InterfaceConfigurations() # create object

interface_configuration = interface_configurations.InterfaceConfiguration() interface_configuration.active = "act" interface_configuration.interface_name = "Loopback200" interface_configurations.interface_configuration.append(interface_configuration) crud.delete(provider, interface_configurations)

Logging

Enable logging and post the logs below

2020-12-28 15:44:57,807 - ydk - INFO - Path where models are to be downloaded: /home/jnombert/.ydk/10.82.140.196 2020-12-28 15:44:57,813 - ydk - INFO - Connected to 10.82.140.196 on port 830 using ssh with timeout of -1 2020-12-28 15:44:57,858 - ydk - INFO - Executing CRUD delete operation on [Cisco-IOS-XR-ifmgr-cfg:interface-configurations] 2020-12-28 15:44:57,859 - ydk - INFO - Executing 'edit-config' RPC on [Cisco-IOS-XR-ifmgr-cfg:interface-configurations] 2020-12-28 15:44:57,877 - ydk - INFO - ============= Sending RPC to device =============

act Loopback200

2020-12-28 15:44:58,360 - ydk - INFO - ============= Received RPC from device ============= <?xml version="1.0"?>

2020-12-28 15:44:58,360 - ydk - INFO - Executing 'commit' RPC 2020-12-28 15:44:58,361 - ydk - INFO - ============= Sending RPC to device =============

System Information

jnombert@ubuntu:~/Documents/ydk/ydk-py-env/ydk-jc-samples$ pip3 list | grep ydk

ydk (0.8.4) ydk-models-cisco-ios-xr (6.6.3) ydk-models-ietf (0.1.5.post2) ydk-models-openconfig (0.1.8)

ygorelik commented 3 years ago

RPCs are not visible in the description. Could you please correct the description or/and attach full log file

icarus78 commented 3 years ago

Hi ygorelik

I´m not sure why it is not visible, although I can see them when editing the comment.

I´m attaching a screen shot with the RPC outputs.

Screen Shot 2020-12-31 at 15 00 57

Thanks

ygorelik commented 3 years ago

Here you can see that delete operation is set on the container interface-configurations. Hence it was applied to all the interfaces. The YDK-0.8.5 documentation explicitly gives you an example on how to delete list element. Please follow the recommendations.

ygorelik commented 3 years ago

This is not a bug. Could you please close the issue and move the discussion to Cisco Community.

icarus78 commented 3 years ago

Hi ygorelik

Thanks for your feedback. I manage to make the script work by following your recommendation and link provided. I´ll proceed to close the discussion

Regards

Jose Carlos