cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
424
Views
10
Helpful
2
Replies

no shutdown of an interface with ydk-py

DrikusBrits
Level 1
Level 1

I'm trying to perform a 'no shutdown' on interfaces using NETCONF and YANG......

i stumbled on this post https://community.cisco.com/t5/yang-tools/interface-no-shutdown/td-p/3434869 which is obviously now outdated somewhat....

Anybody know to perform an unshut/ no shutdown of an interface using ydk models?

I've looked around but to no avail.  I'm able to shutdown an interface and completely delete/remove an interface and its contents, but can't seem to filter it to just the shutdown portion.

Config:


Interface = xr_intf.InterfaceConfigurations()
interface_configuration_instance = Interface.InterfaceConfiguration()
interface_configuration_instance.interface_name = "GigabitEthernet0/0/0/2"
interface_configuration_instance.link_status = Empty()
interface_configuration_instance.active = "act"

Interface.interface_configuration.append(interface_configuration_instance)
crud_service.update(device_netconf,Interface)

 

1 Accepted Solution

Accepted Solutions

ygorelik
Cisco Employee
Cisco Employee

To delete the empty leaf 'shutdown' from the configuration you nee to use YFilter.delete:

from ydk.filters import YFilter

Interfaces = xr_intf.InterfaceConfigurations()
interface_configuration_instance = Interface.InterfaceConfiguration()
interface_configuration_instance.interface_name = "GigabitEthernet0/0/0/2"
interface_configuration_instance.active = "act"

interface_configuration_instance.shutdown = Yfilter.delete

Interfaces.interface_configuration.append(interface_configuration_instance)

crud_service.update(device_netconf, Interfaces)

Yan @cisco

View solution in original post

2 Replies 2

ygorelik
Cisco Employee
Cisco Employee

To delete the empty leaf 'shutdown' from the configuration you nee to use YFilter.delete:

from ydk.filters import YFilter

Interfaces = xr_intf.InterfaceConfigurations()
interface_configuration_instance = Interface.InterfaceConfiguration()
interface_configuration_instance.interface_name = "GigabitEthernet0/0/0/2"
interface_configuration_instance.active = "act"

interface_configuration_instance.shutdown = Yfilter.delete

Interfaces.interface_configuration.append(interface_configuration_instance)

crud_service.update(device_netconf, Interfaces)

Yan @cisco

DrikusBrits
Level 1
Level 1

urgh, you gotta be kidding me.....somewhere between all my trying I came to the wrong conclusion that .shutdown can only accept Empty() and consequently didn't try anything else...... thanks.....the YFilter.delete works like a charm.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: