add debug connection in template
This commit is contained in:
parent
fced69656e
commit
86744e5d81
|
@ -82,6 +82,10 @@ def send_command(connection: ConnectHandler, command: str) -> str:
|
||||||
log.info('command send success')
|
log.info('command send success')
|
||||||
except exceptions.NetmikoTimeoutException:
|
except exceptions.NetmikoTimeoutException:
|
||||||
result = "NetmikoTimeoutException"
|
result = "NetmikoTimeoutException"
|
||||||
|
except exceptions.ReadTimeout:
|
||||||
|
try:
|
||||||
|
result: str = connection.send_command(command, read_timeout=cfg.net_dev.read_timeout)
|
||||||
|
log.info('the second time command send success')
|
||||||
except exceptions.ReadTimeout:
|
except exceptions.ReadTimeout:
|
||||||
result = "ReadTimeout"
|
result = "ReadTimeout"
|
||||||
return result
|
return result
|
||||||
|
@ -105,7 +109,6 @@ def save_mikrotik_bcp(host: str, name: str) -> None:
|
||||||
elif result == "ReadTimeout":
|
elif result == "ReadTimeout":
|
||||||
log.warning("Timeout read config from %r", name)
|
log.warning("Timeout read config from %r", name)
|
||||||
return
|
return
|
||||||
|
|
||||||
result = "\n".join(result.split("\n")[1:])
|
result = "\n".join(result.split("\n")[1:])
|
||||||
with open(os.path.join(cfg.bcp.dir, name), "w") as f:
|
with open(os.path.join(cfg.bcp.dir, name), "w") as f:
|
||||||
f.write(result)
|
f.write(result)
|
||||||
|
@ -125,7 +128,10 @@ def save_snr_bcp(host: str, name: str) -> None:
|
||||||
connection.disconnect()
|
connection.disconnect()
|
||||||
log.info("disconnected from %r", name)
|
log.info("disconnected from %r", name)
|
||||||
if result == "NetmikoTimeoutException":
|
if result == "NetmikoTimeoutException":
|
||||||
log.warning("Timeout read config from %s", name)
|
log.warning("Timeout error %r", name)
|
||||||
|
return
|
||||||
|
elif result == "ReadTimeout":
|
||||||
|
log.warning("Timeout read config from %r", name)
|
||||||
return
|
return
|
||||||
with open(os.path.join(cfg.bcp.dir, name), "w") as f:
|
with open(os.path.join(cfg.bcp.dir, name), "w") as f:
|
||||||
f.write(result)
|
f.write(result)
|
||||||
|
@ -145,7 +151,10 @@ def save_cisco_sb_bcp(host: str, name: str) -> None:
|
||||||
connection.disconnect()
|
connection.disconnect()
|
||||||
log.info("disconnected from %s", name)
|
log.info("disconnected from %s", name)
|
||||||
if result == "NetmikoTimeoutException":
|
if result == "NetmikoTimeoutException":
|
||||||
log.warning("Timeout read config from %s", name)
|
log.warning("Timeout error %r", name)
|
||||||
|
return
|
||||||
|
elif result == "ReadTimeout":
|
||||||
|
log.warning("Timeout read config from %r", name)
|
||||||
return
|
return
|
||||||
with open(os.path.join(cfg.bcp.dir, name), "w") as f:
|
with open(os.path.join(cfg.bcp.dir, name), "w") as f:
|
||||||
f.write(result)
|
f.write(result)
|
||||||
|
@ -164,6 +173,9 @@ def save_cisco_bcp(host: str, name: str) -> None:
|
||||||
connection.disconnect()
|
connection.disconnect()
|
||||||
log.info("disconnected from %r", name)
|
log.info("disconnected from %r", name)
|
||||||
if result == "NetmikoTimeoutException":
|
if result == "NetmikoTimeoutException":
|
||||||
|
log.warning("Timeout error %r", name)
|
||||||
|
return
|
||||||
|
elif result == "ReadTimeout":
|
||||||
log.warning("Timeout read config from %r", name)
|
log.warning("Timeout read config from %r", name)
|
||||||
return
|
return
|
||||||
with open(os.path.join(cfg.bcp.dir, name), "w") as f:
|
with open(os.path.join(cfg.bcp.dir, name), "w") as f:
|
||||||
|
|
Loading…
Reference in New Issue