cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
123
Views
0
Helpful
2
Replies

Issue with editing configurations using IOS XE on Cat8kV Sandbox

GJG
Level 1
Level 1

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

<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
          <interface>
                 <name>{int_name}</name>
                 <description>{int_desc}</description>
                 <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>
                 <enabled>true</enabled>
                 <ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
                     <address>
                        <ip>{ip_address}</ip>
                        <netmask>{subnet_mask}</netmask>
                    </address>
                 </ipv4>
            </interface>
      </interfaces>
</config>

(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

 

1 Accepted Solution

Accepted Solutions

GJG
Level 1
Level 1

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

View solution in original post

2 Replies 2

Marcel Zehnder
Spotlight
Spotlight

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

 

Details: https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/prog/configuration/179/b_179_programmability_cg/m_179_prog_yang_netconf.html#id_78218

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

GJG
Level 1
Level 1

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