add delay factor

This commit is contained in:
s.mostryukov 2025-06-22 14:23:00 +03:00
parent 86744e5d81
commit df0e4da626
3 changed files with 3 additions and 5 deletions

View File

@ -78,14 +78,10 @@ def connect_to_device(vendor: str, host: str, name: str="") -> ConnectHandler:
def send_command(connection: ConnectHandler, command: str) -> str: def send_command(connection: ConnectHandler, command: str) -> str:
log.info("send command") log.info("send command")
try: try:
result: str = connection.send_command(command, read_timeout=cfg.net_dev.read_timeout) result: str = connection.send_command(command, read_timeout=cfg.net_dev.read_timeout, delay_factor=2)
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

View File

@ -68,6 +68,7 @@ class ConfigNetDev:
pwd: str = os.getenv("NET_DEV_PWD") pwd: str = os.getenv("NET_DEV_PWD")
ssh_port: int = config["net_dev"].getint("ssh_port") ssh_port: int = config["net_dev"].getint("ssh_port")
read_timeout: int = config["net_dev"].getint("read_timeout") read_timeout: int = config["net_dev"].getint("read_timeout")
delay_factor: int = config["net_dev"].getint("delay_factor")
debug: bool = config["net_dev"].getboolean("debug") debug: bool = config["net_dev"].getboolean("debug")

View File

@ -41,6 +41,7 @@ debug: False
# Порт на который подключаться по ssh # Порт на который подключаться по ssh
ssh_port: 22 ssh_port: 22
read_timeout: 30 read_timeout: 30
delay_factor: 2
[log] [log]
# Уровень логов в консоль # Уровень логов в консоль