cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Who Me Too'd this topic

Having Problemas Editing a File NETCONF

Hi I'm having some trouble running this script. I'm trying to edit the configuration I have but I encounter this:

 

CODE

============================================================

from ncclient import manager

HOST = "ios-xe-mgmt.cisco.com"
NETCONF_PORT = 10000
USER = "developer"
PASS = "C1sco12345"

netconf_template = """
<config>
  <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>
"""

if __name__ == "__main__":

    netconf_payload = netconf_template.format(int_name="GigabitEthernet2",
                                            int_desc="Configured on real time",
                                            ip_address="10.255.255.1",
                                            subnet_mask="255.255.255.0"
                                            )

    print("Configuration Payload:")
    print("==========================")
    print(netconf_payload)

    with manager.connect(
        host=HOST,
        port=NETCONF_PORT,
        username=USER,
        password=PASS,
        hostkey_verify=False
        ) as m:

        netconf_reply = m.edit_config(netconf_payload, target="running")

        print(netconf_reply)
===========================================================
ERROR
File "c:/Users/Administrator/OneDrive/Documentos/Visual Studio Code/config_try1.py", line 47, in <module>
netconf_reply = m.edit_config(netconf_payload, target="running")
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ncclient\manager.py", line 231, in execute
return cls(self._session,
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ncclient\operations\edit.py", line 67, in request
return self._request(node)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ncclient\operations\rpc.py", line 349, in _request
raise self._reply.error
ncclient.operations.rpc.RPCError: Unsupported capability :writable-running
 
I guess it's because I can't edit a file when its actually running, what could be the other option for target
 
Thanks!!
Who Me Too'd this topic