12-20-2024 05:53 AM
Hi,
I am executing https://github.com/CiscoDevNet/BRKDEV-1368/blob/master/netconf/example4.py on the Always On sandbox
I have amended the following
(1) device_info.py
ios_xe1 = {
"address": "devnetsandboxiosxe.cisco.com",
"port": 830,
"username": "admin",
"password": "C1sco12345"
}
(2) config-temp-ietf-interfaces.xml
(3) exampl4.py
from device_info import ios_xe1
from ncclient import manager
if __name__ == '__main__':
# NETCONF Config Template to use
netconf_template = open("config-temp-ietf-interfaces.xml").read()
# Build the XML Configuration to Send
netconf_payload = netconf_template.format(int_name="GigabitEthernet2",
int_desc="Configured by NETCONF",
ip_address="10.255.255.1",
subnet_mask="255.255.255.0"
)
print("Configuration Payload:")
print("----------------------")
print(netconf_payload)
with manager.connect(host=ios_xe1["address"], port=ios_xe1["port"],
username=ios_xe1["username"],
password=ios_xe1["password"],
hostkey_verify=False) as m:
result = m.edit_config(netconf_payload, 'candidate')
print(result)
reply = m.commit()
print(reply)
Errors encountered are as follows:
result = m.edit_config(netconf_payload, 'candidate')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gayathri/Downloads/test/lib/python3.12/site-packages/ncclient/manager.py", line 270, in execute
return cls(self._session,
^^^^^^^^^^^^^^^^^^
File "/home/gayathri/Downloads/test/lib/python3.12/site-packages/ncclient/operations/edit.py", line 76, in request
return self._request(node)
^^^^^^^^^^^^^^^^^^^
File "/home/gayathri/Downloads/test/lib/python3.12/site-packages/ncclient/operations/rpc.py", line 375, in _request
raise self._reply.error
ncclient.operations.rpc.RPCError: Unsupported capability :candidate
Please assist to rectify
GG
Solved! Go to Solution.
12-21-2024 05:52 AM
Hi Marcel,
Thank you for the support
I have adopted the following
(1) Enabled the candidate datastore by accessing the sandbox via SSH
(2) The code modification done is as follows:
result = m.edit_config(netconf_payload)
print(result)
reply = m.commit()
print(reply)
Successfully executed the code with the support given
GJG
12-20-2024 06:44 AM - edited 12-20-2024 06:48 AM
Hi, the candidate datastore is not enabled by default, to enable it you need to configure it on the IOS-XE device using the command netconf-yang feature candidate-datastore:
1) SSH to you IOS-XE box and enter
conf t
netconf-yang feature candidate-datastore
do copy running-config startup-config
If you want to use the script without candidate datastore you need to edit the running datastore:
from device_info import ios_xe1
from ncclient import manager
if __name__ == '__main__':
# NETCONF Config Template to use
netconf_template = open("config-temp-ietf-interfaces.xml").read()
# Build the XML Configuration to Send
netconf_payload = netconf_template.format(int_name="GigabitEthernet2",
int_desc="Configured by NETCONF",
ip_address="10.255.255.1",
subnet_mask="255.255.255.0"
)
print("Configuration Payload:")
print("----------------------")
print(netconf_payload)
with manager.connect(host=ios_xe1["address"], port=ios_xe1["port"],
username=ios_xe1["username"],
password=ios_xe1["password"],
hostkey_verify=False) as m:
result = m.edit_config(netconf_payload, 'running')
print(result.data)
HTH
12-21-2024 05:52 AM
Hi Marcel,
Thank you for the support
I have adopted the following
(1) Enabled the candidate datastore by accessing the sandbox via SSH
(2) The code modification done is as follows:
result = m.edit_config(netconf_payload)
print(result)
reply = m.commit()
print(reply)
Successfully executed the code with the support given
GJG
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