- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Labels:
-
YANG Development Kit (YDK)
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- The import of the special type "DELETE"
- The use of the special type "DELETE", an instance of which is assigned to "interface_configuration.shutdown".
- Using "crud.update" to update the field inside the object.
Cheers,
Einar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- The import of the special type "DELETE"
- The use of the special type "DELETE", an instance of which is assigned to "interface_configuration.shutdown".
- Using "crud.update" to update the field inside the object.
Cheers,
Einar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- Introduce a new class "REMOVE" in the file ydk-gen/types.py at master · CiscoDevNet/ydk-gen · GitHub
- Modify _encoder.py (near ydk-gen/_encoder.py at master · CiscoDevNet/ydk-gen · GitHub) to have an elif clause for the new "REMOVE" class to generate the correct netconf binding. Probably something like:
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
