05-26-2020 07:51 AM
Hi all,
I'm new to the ydk-cpp/YANG/NETCONF world. I'm trying to figure out how to shut/noshut a particular interface on an NCS55A2 (cisco-ios-xr 7.0.1)
I'm able to successfully shutdown an interface by querying for all interfaces, then updating the particular interface that the user wants to shutdown. (FYI if Yan is reading this ... I've patched my version of ydk-cpp with a rough hack that allows me to get all interfaces ... I'll remove that once I get your better fix).
Here is a rough snippet of what I'm doing:
auto intf_filter = make_shared<cisco_ios_xr::Cisco_IOS_XR_ifmgr_cfg::InterfaceConfigurations>(); CrudService crud_service{}; auto intf_read = crud_service.read( provider, *intf_filter ); auto intf_read_ptr = dynamic_cast<cisco_ios_xr::Cisco_IOS_XR_ifmgr_cfg::InterfaceConfigurations*>(intf_read.get());
... display a menu of interfaces and save off user selection to "uint16_t intf_id" ... auto& ifcfg = (cisco_ios_xr::Cisco_IOS_XR_ifmgr_cfg::InterfaceConfigurations::InterfaceConfiguration&) (*(intf_read_ptr->interface_configuration[intf_id])); ifcfg.shutdown.is_set = true; crud_service.update( provider, ifcfg );
That appears to work.
However, it's not obvious how to do a "no shut" on the interface. If found this useful article on doing a no-shutdown in the python version of the ydk:
https://community.cisco.com/t5/yang-development-kit-ydk/interface-no-shutdown/td-p/3434869
This tells me we have to delete an attribute associated with the interface rather than just updating attributes. Makes sense.
However, I'm not sure how that translates into ydk-cpp. This is my best guess (but it doesn't work). I do everything the same as the above code block for shutting down the interface, but rather than just setting "shutdown" to false, I set a filter to tell netconf to delete the attribute.
ifcfg.shutdown.is_set = false; ifcfg.set_filter( "shutdown", YFilter::delete_ ); crud_service.update( provider, ifcfg );
Like I said, this is unsuccessful. I can't find any example of how to delete attributes like shutdown. Any help would greatly be appreciated.
Thanks,
Eric
05-26-2020 08:04 AM
Ignore this. It looks like it is working. I'm not sure what I was seeing earlier. Sorry for the confusion.
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