fix: send carriage return as Enter to LANCOM LCOS SX 3.x switches
The CLI only echoes commands terminated with "\n". Auto-detection falls back to "\r" when the first command is not completed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
1bd2d42b5d
commit
411c5446fe
3 files changed
+45
-8
No files matched your search
@@ -14,7 +14,7 @@ from netbox_sync.core.switches import (
|
||||
_interface,
|
||||
_compress_vlans,
|
||||
_membership,
|
||||
_run_cli_command,
|
||||
_run_cli_command as _run_with_newline,
|
||||
clean_output,
|
||||
parse_vlan_list,
|
||||
)
|
||||
@@ -35,6 +35,19 @@ COMMANDS = (
|
||||
)
|
||||
|
||||
|
||||
def _run_cli_command(channel, command, timeout=20):
|
||||
"""This CLI executes a command only on "\r"; "\n" is just echoed."""
|
||||
return _run_with_newline(channel, command, timeout=timeout, newline="\r")
|
||||
|
||||
|
||||
def probe(channel):
|
||||
"""``True`` when the "system" mode shows a LANCOM model; leaves the mode again."""
|
||||
_run_cli_command(channel, "system")
|
||||
system = _run_cli_command(channel, "show", timeout=30)
|
||||
_run_cli_command(channel, "exit")
|
||||
return is_lancom(system)
|
||||
|
||||
|
||||
def is_lancom(text):
|
||||
return bool(re.search(r"(?i)Model Name\s*:\s*LANCOM", text or ""))
|
||||
|
||||
|
||||
Reference in new issue
Block a user