01-01-2017 08:37 AM
May I know how to "no shutdown" the interface??
I can only find the interface_configuration.shutdown=empty() to explicitly shutdown the interface but can't find a function to explicitly no shutdown the interface.
Many Thanks!
Solved! Go to Solution.
01-01-2017 06:21 PM
Assuming you have the Cisco_IOS_XR_ifmgr_cfg module imported as xr_ifmgr_cfg, this fragment of code shows how to do this:
from ydk.types import DELETE
if __name__ == "__main__":
provider = NetconfServiceProvider(...)
crud = CRUDService()
interface_configurations = xr_ifmgr_cfg.InterfaceConfigurations()
interface_configuration = interface_configurations.InterfaceConfiguration()
interface_configuration.active = "act"
interface_configuration.interface_name = "GigabitEthernet0/0/0/0"
interface_configuration.shutdown = DELETE()
interface_configurations.interface_configuration.append(interface_configuration)
# delete configuration on NETCONF device
crud.update(provider, interface_configurations)
The important points to note are:
Cheers,
Einar
01-01-2017 06:21 PM
Assuming you have the Cisco_IOS_XR_ifmgr_cfg module imported as xr_ifmgr_cfg, this fragment of code shows how to do this:
from ydk.types import DELETE
if __name__ == "__main__":
provider = NetconfServiceProvider(...)
crud = CRUDService()
interface_configurations = xr_ifmgr_cfg.InterfaceConfigurations()
interface_configuration = interface_configurations.InterfaceConfiguration()
interface_configuration.active = "act"
interface_configuration.interface_name = "GigabitEthernet0/0/0/0"
interface_configuration.shutdown = DELETE()
interface_configurations.interface_configuration.append(interface_configuration)
# delete configuration on NETCONF device
crud.update(provider, interface_configurations)
The important points to note are:
Cheers,
Einar
01-02-2017 06:20 AM
Hi Einar,
It works when the interface is "admin shutdown". However, if the interface is up, I can't use this method.
It causes me an additional step to check the interface status first before issuing this.
Is it possible to "no shutdown" the interface without query the interface status??
Many Thanks!!
======================================
ydk.errors.YPYServiceProviderError: Server rejected request.
error-type: application
error-tag: data-missing
error-severity: error
error-path: ns1:interface-configurations/ns1:interface-configuration[active = 'act' and interface-name = 'GigabitEthernet0/0/0/0']/ns1:shutdown
01-02-2017 07:34 AM
Right now, I'm afraid that no, you can't do what you want with the YDK. This is because of how we map operations through to the underlying netconf protocol. DELETE maps to operation='delete' in netconf, which requires that the data to be deleted exists, or an error is generated. Netconf can do this, with operation='remove', but this is not supported today. It would be a fairly simple enhancement if you want to try patching this. You would need to:
elif isinstance(value, REMOVE) and not is_filter:
xc = 'urn:ietf:params:xml:ns:netconf:base:1.0'
member_elem.set('{' + xc + '}operation', 'remove')
Feel free to either http://cs.co/ydk-gen and try this out, or submit an issue. Hope this helps!
Cheers,
Einar
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