dev1.2.0 #8
|
@ -104,6 +104,8 @@ def send_command(connection: ConnectHandler, command: str) -> str:
|
||||||
result = "NetmikoTimeoutException"
|
result = "NetmikoTimeoutException"
|
||||||
except exceptions.ReadTimeout:
|
except exceptions.ReadTimeout:
|
||||||
result = "ReadTimeout"
|
result = "ReadTimeout"
|
||||||
|
if len(result.split("\n")) < cfg.bcp.min_string_count:
|
||||||
|
result = 'NotEnoughLines'
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,6 +127,9 @@ 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
|
||||||
|
elif result == "NotEnoughLines":
|
||||||
|
log.warning("Small number of lines %r", name)
|
||||||
|
return
|
||||||
result = "\n".join(result.split("\n")[1:])
|
result = "\n".join(result.split("\n")[1:])
|
||||||
bcp_file_name, file_folder = get_bcp_file_path(name)
|
bcp_file_name, file_folder = get_bcp_file_path(name)
|
||||||
with open(bcp_file_name, "w") as f:
|
with open(bcp_file_name, "w") as f:
|
||||||
|
@ -150,6 +155,9 @@ def save_snr_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
|
||||||
|
elif result == "NotEnoughLines":
|
||||||
|
log.warning("Small number of lines %r", name)
|
||||||
|
return
|
||||||
bcp_file_name, file_folder = get_bcp_file_path(name)
|
bcp_file_name, file_folder = get_bcp_file_path(name)
|
||||||
with open(bcp_file_name, "w") as f:
|
with open(bcp_file_name, "w") as f:
|
||||||
f.write(result)
|
f.write(result)
|
||||||
|
@ -174,6 +182,9 @@ def save_cisco_sb_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
|
||||||
|
elif result == "NotEnoughLines":
|
||||||
|
log.warning("Small number of lines %r", name)
|
||||||
|
return
|
||||||
bcp_file_name, file_folder = get_bcp_file_path(name)
|
bcp_file_name, file_folder = get_bcp_file_path(name)
|
||||||
with open(bcp_file_name, "w") as f:
|
with open(bcp_file_name, "w") as f:
|
||||||
f.write(result)
|
f.write(result)
|
||||||
|
@ -198,6 +209,9 @@ def save_cisco_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
|
||||||
|
elif result == "NotEnoughLines":
|
||||||
|
log.warning("Small number of lines %r", name)
|
||||||
|
return
|
||||||
bcp_file_name, file_folder = get_bcp_file_path(name)
|
bcp_file_name, file_folder = get_bcp_file_path(name)
|
||||||
with open(bcp_file_name, "w") as f:
|
with open(bcp_file_name, "w") as f:
|
||||||
f.write(result)
|
f.write(result)
|
||||||
|
|
|
@ -62,6 +62,7 @@ class ConfigBcp:
|
||||||
in_folder: bool = config["bcp"].getboolean("in_folder")
|
in_folder: bool = config["bcp"].getboolean("in_folder")
|
||||||
if in_folder:
|
if in_folder:
|
||||||
folder_name_pattern: str = config["bcp"].get("folder_name_pattern")
|
folder_name_pattern: str = config["bcp"].get("folder_name_pattern")
|
||||||
|
min_string_count: int = config["bcp"].getint("min_string_count")
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
|
@ -41,7 +41,8 @@ start_at: 18:59
|
||||||
in_folder: True
|
in_folder: True
|
||||||
# Регулярное выражение по которому будет парситься имя папки из названия девайса
|
# Регулярное выражение по которому будет парситься имя папки из названия девайса
|
||||||
folder_name_pattern: ^(.*?)-
|
folder_name_pattern: ^(.*?)-
|
||||||
|
# Если количество строк в конфиге меньше указанного значения - ошибка, изменения не записываются.
|
||||||
|
min_string_count: 50
|
||||||
|
|
||||||
[net_dev]
|
[net_dev]
|
||||||
debug: False
|
debug: False
|
||||||
|
|
Loading…
Reference in New Issue