cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
564
Views
6
Helpful
1
Replies

resource denied: Sync is in progress</error-message>

joedelapaz
Level 1
Level 1

I am trying to write a python script that will revert switchports back to default configuration. I have split the procedure into two separate files.

This file holds the code for the payload and calls the file below - NC_default_interface.py.

This contains the ncclient manager.connect section - NC_connect_to_device.py.

Whenever I run this code, interface G1/0/1 successfully gets reverted back to default configuration. However, on port G1/0/2, I get this error message.

</error-path><error-message xml:lang="en">resource denied: Sync is in progress</error-message><error-info><bad-element>default</bad-element>
</error-info>

I think the session needs to be closed and restarted for each port, but that is just a guess on my part.

I tried m.close and m.session_close(), but those just threw up different error messages. 

I have attached the files in question. Thanks in advance.

1 Reply 1

Marcel Zehnder
Spotlight
Spotlight

Hi 

Lock/unlock the datastore for each rpc call. In my case this code is working:

 

    for i in range(1,5):
      m.lock(target="running")
      rpc_content = f"""
      <default xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-rpc">
        <interface>GigabitEthernet1/0/{i}</interface>
      </default>
      """
      
      result = m.rpc(xml_.to_ele(rpc_content))
      print(result.xml)
      m.unlock(target="running")

 


In your case you need something like this:

 

# snipp 
for rpc in payload:
            try:
                m.lock(target="running")
                response = m.dispatch(et.fromstring(rpc))
                data = response.xml
                m.unlock(target="running")
            except RPCError as e:
                data = e.xml
                pass
# snipp

 



HTH
Marcel