napalm-automation-community / napalm-sros

NAPALM driver for Nokia SR OS
Apache License 2.0
17 stars 17 forks source link

The driver hangs in case of errors #27

Closed omron93 closed 3 years ago

omron93 commented 3 years ago

We're using this napalms driver to replace config file (we're using xml format)

driver = napalm.get_network_driver('sros’)
driver.load_replace_candidate(filename=candidate_conf_path)

but the switch config is locked from CLI, so we get

Traceback (most recent call last):
  File "/Users/riccardo/Projects/NCA/pysros/pysros/command_line.py", line 189, in <module>
    main()
  File "/Users/riccardo/Projects/NCA/pysros/pysros/command_line.py", line 16, in wrapper
    func()
  File "/Users/riccardo/Projects/NCA/pysros/pysros/command_line.py", line 177, in main
    device.load_replace_candidate(filename=candidate_conf_path)
  File "/Users/riccardo/virtualenvs/pysros/lib/python3.6/site-packages/napalm_sros/sros.py", line 471, in load_replace_candidate
    self._lock_config()
  File "/Users/riccardo/virtualenvs/pysros/lib/python3.6/site-packages/napalm_sros/sros.py", line 199, in _lock_config
    self.conn.lock()
  File "/Users/riccardo/virtualenvs/pysros/lib/python3.6/site-packages/ncclient/manager.py", line 231, in execute
    huge_tree=self._huge_tree).request(*args, **kwds)
  File "/Users/riccardo/virtualenvs/pysros/lib/python3.6/site-packages/ncclient/operations/lock.py", line 35, in request
    return self._request(node)
  File "/Users/riccardo/virtualenvs/pysros/lib/python3.6/site-packages/ncclient/operations/rpc.py", line 360, in _request
    raise self._reply.error
ncclient.operations.rpc.RPCError: 
            MINOR: MGMT_CORE #2052: Exclusive datastore access unavailable - the MD-CLI has exclusive lock on configuration

but the function hangs there instead of returning back to python prompt. Please check why this call hangs.

Also in the driver it seems to be ready to raise "standard" napalm exceptions https://github.com/napalm-automation-community/napalm-sros/blob/master/napalm_sros/sros.py#L500 , but this doesn't seem to be working in this case as well.

JonLundstrom commented 3 years ago

Per the fixes add this month, better exception handling has been implemented. Unless we hear this continues to be a problem, we'll close this issue soon.