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