Commit 6263bc7b authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Migrate profile re patterns to binary form part 3.

parent 2e7c185c
......@@ -15,7 +15,7 @@ class Profile(BaseProfile):
pattern_username = rb"^Username:"
pattern_password = rb"^(Password:|Please input password:)"
pattern_more = [
(rb"^\s+---- More ----$", " "),
(rb"^\s+---- More ----$", b" "),
(rb"The current configuration will be written to the device. Are you sure? [Y/N]:", b"Y"),
(rb"(To leave the existing filename unchanged, press the enter key):", b"\n"),
(rb"flash:/startup.cfg exists, overwrite? [Y/N]:", b"Y"),
......
......@@ -13,7 +13,7 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "3Com.SuperStack3_4500"
pattern_more = [
(rb"^\s+---- More ----$", " "),
(rb"^\s+---- More ----$", b" "),
(rb"The current configuration will be written to the device. Are you sure? [Y/N]:", b"Y"),
(rb"(To leave the existing filename unchanged, press the enter key):", b"\n"),
(rb"flash:/startup.cfg exists, overwrite? [Y/N]:", b"Y"),
......
......@@ -15,21 +15,23 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Cisco.IOS"
pattern_more = [
(r"^ --More-- ", " "),
(r"(?:\?|interfaces)\s*\[confirm\]", "\n"),
(r"^Destination filename \[\S+\]", "\n"),
(r"^Proceed with reload\?\s*\[confirm\]", "y\n"),
(rb"^ --More-- ", b" "),
(rb"(?:\?|interfaces)\s*\[confirm\]", b"\n"),
(rb"^Destination filename \[\S+\]", b"\n"),
(rb"^Proceed with reload\?\s*\[confirm\]", b"y\n"),
]
pattern_unprivileged_prompt = r"^\S+?>"
pattern_syntax_error = r"% Invalid input detected at|% Ambiguous command:|% Incomplete command."
pattern_operation_error = "Command authorization failed."
pattern_unprivileged_prompt = rb"^\S+?>"
pattern_syntax_error = (
rb"% Invalid input detected at|% Ambiguous command:|% Incomplete command."
)
pattern_operation_error = rb"Command authorization failed."
command_disable_pager = "terminal length 0"
command_super = "enable"
command_super = b"enable"
command_enter_config = "configure terminal"
command_leave_config = "end"
command_exit = "exit"
command_save_config = "copy running-config startup-config\n"
pattern_prompt = r"^(?P<hostname>[a-zA-Z0-9/.]\S{0,35})(?:[-_\d\w]+)?(?:\(config[^\)]*\))?#"
pattern_prompt = rb"^(?P<hostname>[a-zA-Z0-9/.]\S{0,35})(?:[-_\d\w]+)?(?:\(config[^\)]*\))?#"
can_strip_hostname_to = 20
requires_netmask_conversion = True
convert_mac = BaseProfile.convert_mac_to_cisco
......
......@@ -18,7 +18,7 @@ class Profile(BaseProfile):
name = "Cisco.IOSXR"
pattern_more = [(rb"^ --More--", b"\r")]
pattern_unprivileged_prompt = r"^\S+?>"
pattern_unprivileged_prompt = rb"^\S+?>"
pattern_syntax_error = rb"% Invalid input detected at"
command_disable_pager = "terminal length 0"
command_super = b"enable"
......
......@@ -12,19 +12,20 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.ESR"
pattern_more = [
(r"^More: <space>, Quit: q, One line: <return>$", " "),
(r"^More\? Enter - next line; Space - next page; Q - quit; R - show the rest.", "r"),
(r"\[Yes/press any key for no\]", "Y"),
(rb"^More: <space>, Quit: q, One line: <return>$", b" "),
(rb"^More\? Enter - next line; Space - next page; Q - quit; R - show the rest.", b"r"),
(rb"\[Yes/press any key for no\]", b"Y"),
]
pattern_unprivileged_prompt = r"^\S+> "
pattern_syntax_error = r"^% (Unrecognized command|Incomplete command|Wrong number of parameters or invalid range, size or characters entered)$"
pattern_unprivileged_prompt = rb"^\S+> "
pattern_syntax_error = rb"^% (Unrecognized command|Incomplete command|Wrong number of parameters or invalid range, size or characters entered)$"
command_disable_pager = "terminal datadump"
command_super = "enable"
command_super = b"enable"
command_enter_config = "configure"
command_leave_config = "end"
command_save_config = "copy running-config startup-config"
pattern_prompt = r"^\S+#"
pattern_prompt = rb"^\S+#"
convert_interface_name = BaseProfile.convert_interface_name_cisco
INTERFACE_TYPES = {
......
......@@ -12,18 +12,19 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.LTE"
pattern_username = r"(?<!Last )login: "
pattern_more = [(r"\[Yes/press any key for no\]", "Y")]
pattern_username = rb"(?<!Last )login: "
pattern_more = [(rb"\[Yes/press any key for no\]", b"Y")]
# pattern_unprivileged_prompt = r"^\S+>"
pattern_syntax_error = r"\n(Command not found|Incomplete command|Invalid argument)"
pattern_operation_error = r"Data verify failed, bad MAC!"
username_submit = "\r"
password_submit = "\r"
command_submit = "\r"
pattern_syntax_error = rb"\n(Command not found|Incomplete command|Invalid argument)"
pattern_operation_error = rb"Data verify failed, bad MAC!"
username_submit = b"\r"
password_submit = b"\r"
command_submit = b"\r"
command_enter_config = "configure"
command_leave_config = "exit"
command_save_config = "save"
pattern_prompt = r"^\S+[#>]"
pattern_prompt = rb"^\S+[#>]"
class switch(object):
"""Switch context manager to use with "with" statement"""
......
......@@ -15,24 +15,25 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.LTP"
pattern_username = r"(?<!Last>)([Uu]ser ?[Nn]ame|[Ll]ogin): ?"
pattern_more = [(r"--More-- ", " "), (r"\[Yes/press any key for no\]", "Y")]
pattern_unprivileged_prompt = r"^\S+>"
pattern_username = rb"(?<!Last>)([Uu]ser ?[Nn]ame|[Ll]ogin): ?"
pattern_more = [(rb"--More-- ", b" "), (rb"\[Yes/press any key for no\]", b"Y")]
pattern_unprivileged_prompt = rb"^\S+>"
pattern_syntax_error = (
r"(Command not found. Use '?' to view available commands|"
r"Incomplete command\s+|Invalid argument\s+|Unknown command)"
rb"(Command not found. Use '?' to view available commands|"
rb"Incomplete command\s+|Invalid argument\s+|Unknown command)"
)
# command_disable_pager = "terminal datadump"
# command_super = "enable"
username_submit = "\r"
password_submit = "\r"
command_submit = "\r"
username_submit = b"\r"
password_submit = b"\r"
command_submit = b"\r"
command_enter_config = "configure"
command_leave_config = "exit"
command_save_config = "save"
pattern_prompt = r"^\S+#"
pattern_prompt = rb"^\S+#"
class switch(object):
"""Switch context manager to use with "with" statement"""
......
......@@ -15,15 +15,16 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.MA4000"
pattern_username = r"^\S+ login: "
pattern_more = [(r"^--More-- ", " "), (r"\[Yes/press any key for no\]", "Y")]
pattern_username = rb"^\S+ login: "
pattern_more = [(rb"^--More-- ", b" "), (rb"\[Yes/press any key for no\]", b"Y")]
rogue_chars = [
re.compile(br"\r\s{9}\r"),
re.compile(br"^\s+VLAN Table\r\n\s+\~+\r\n", re.MULTILINE),
b"\r",
]
pattern_syntax_error = r"^Unknown command"
pattern_prompt = r"^(?P<hostname>\S+)# "
pattern_syntax_error = rb"^Unknown command"
pattern_prompt = rb"^(?P<hostname>\S+)# "
command_exit = "exit"
telnet_naws = b"\x00\x7f\x00\x7f"
......
......@@ -18,27 +18,28 @@ from noc.core.snmp.render import render_mac
class Profile(BaseProfile):
name = "Eltex.MES"
pattern_more = [
(r"^More: <space>, Quit: q, One line: <return>$", " "),
(r"\[Yes/press any key for no\]", "Y"),
(r"<return>, Quit: q or <ctrl>", " "),
(r"q or <ctrl>+z", " "),
(r"Overwrite file \[startup-config\].... \(Y\/N\)", "Y"),
(r"Would you like to continue \? \(Y\/N\)\[N\]", "Y"),
(r"Clear Logging File \? \(Y\/N\)\[N\]", "Y"),
(rb"^More: <space>, Quit: q, One line: <return>$", b" "),
(rb"\[Yes/press any key for no\]", b"Y"),
(rb"<return>, Quit: q or <ctrl>", b" "),
(rb"q or <ctrl>+z", b" "),
(rb"Overwrite file \[startup-config\].... \(Y\/N\)", b"Y"),
(rb"Would you like to continue \? \(Y\/N\)\[N\]", b"Y"),
(rb"Clear Logging File \? \(Y\/N\)\[N\]", b"Y"),
]
pattern_unprivileged_prompt = r"^(?P<hostname>\S+)>\s*"
pattern_unprivileged_prompt = rb"^(?P<hostname>\S+)>\s*"
pattern_syntax_error = (
r"% (Unrecognized command|Incomplete command|"
r"Wrong number of parameters or invalid range, size or "
r"characters entered)"
rb"% (Unrecognized command|Incomplete command|"
rb"Wrong number of parameters or invalid range, size or "
rb"characters entered)"
)
command_disable_pager = "terminal datadump"
command_super = "enable"
command_super = b"enable"
command_enter_config = "configure"
command_leave_config = "end"
command_save_config = "copy running-config startup-config"
pattern_prompt = r"^(?P<hostname>[A-Za-z0-9-_ \:\.\*\'\,\(\)\/]+)?" r"(?:\(config[^\)]*\))?#"
pattern_prompt = rb"^(?P<hostname>[A-Za-z0-9-_ \:\.\*\'\,\(\)\/]+)?(?:\(config[^\)]*\))?#"
rogue_chars = [re.compile(rb"\d+-\w+-\d+\s\d+:\d+:\d+\s\%\S+\:.+"), b"\r"]
# to one SNMP GET request
snmp_metrics_get_chunk = 10
......
......@@ -16,15 +16,14 @@ from noc.core.validators import is_int
class Profile(BaseProfile):
name = "Eltex.MES24xx"
pattern_more = [(r"--More--", " ")]
pattern_prompt = r"(?P<hostname>\S+)(?:\(config[^\)]*\))?#\s*"
pattern_unprivileged_prompt = r"^(?P<hostname>\S+)>\s*"
pattern_syntax_error = r"^% Invalid (?:Command|input detected at)$"
pattern_more = [(rb"--More--", b" ")]
pattern_prompt = rb"(?P<hostname>\S+)(?:\(config[^\)]*\))?#\s*"
pattern_unprivileged_prompt = rb"^(?P<hostname>\S+)>\s*"
pattern_syntax_error = rb"^% Invalid (?:Command|input detected at)$"
# command_disable_pager = "set cli pagination off" - need conf t mode
config_tokenizer = "line"
config_tokenizer_settings = {"line_comment": "!"}
command_submit = "\r"
command_super = "enable"
command_submit = b"\r"
command_super = b"enable"
command_enter_config = "configure"
command_leave_config = "end"
rogue_chars = [
......
......@@ -25,14 +25,15 @@ def render_regexp(oid, value):
class Profile(BaseProfile):
name = "Eltex.MES5448"
pattern_more = [(r"--More-- or \(q\)uit", " ")]
pattern_unprivileged_prompt = r"^(?P<hostname>\S+)>"
pattern_prompt = r"^(?P<hostname>\S+)#"
pattern_more = [(rb"--More-- or \(q\)uit", b" ")]
pattern_unprivileged_prompt = rb"^(?P<hostname>\S+)>"
pattern_prompt = rb"^(?P<hostname>\S+)#"
pattern_syntax_error = (
r"^% (Unrecognized command|Incomplete command|"
r"Wrong number of parameters or invalid range, size or "
r"characters entered)$"
rb"^% (Unrecognized command|Incomplete command|"
rb"Wrong number of parameters or invalid range, size or "
rb"characters entered)$"
)
command_super = "enable"
command_super = b"enable"
command_disable_pager = "terminal length 0"
snmp_display_hints = {"1.3.6.1.4.1.4413.1.1.1.1.4.9.0": render_regexp}
......@@ -12,19 +12,17 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.PON"
pattern_username = r"(?<!Last) login: "
pattern_more = [(r"\[Yes/press any key for no\]", "Y")]
pattern_unprivileged_prompt = r"^\S+>"
pattern_syntax_error = (
r"^(Command not found. Use '?' to view available commands|"
+ r"Incomplete command\s+|Invalid argument\s+)"
)
pattern_username = rb"(?<!Last) login: "
pattern_more = [(rb"\[Yes/press any key for no\]", b"Y")]
pattern_unprivileged_prompt = rb"^\S+>"
pattern_syntax_error = rb"^(Command not found. Use '?' to view available commands|Incomplete command\s+|Invalid argument\s+)"
# command_disable_pager = "terminal datadump"
# command_super = "enable"
command_enter_config = "configure"
command_leave_config = "exit"
command_save_config = "save"
pattern_prompt = r"^\S+#"
pattern_prompt = rb"^\S+#"
# convert_interface_name = BaseProfile.convert_interface_name_cisco
class switch(object):
......
......@@ -12,13 +12,13 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.RG"
pattern_username = r"^\S+ [Ll]ogin:"
pattern_password = r"^[Pp]assword:"
pattern_syntax_error = r"Permission denied"
pattern_unprivileged_prompt = r"^\S+@(?P<hostname>\S+):~\$"
pattern_prompt = r"^\S+@(?P<hostname>\S+):~#"
pattern_username = rb"^\S+ [Ll]ogin:"
pattern_password = rb"^[Pp]assword:"
pattern_syntax_error = rb"Permission denied"
pattern_unprivileged_prompt = rb"^\S+@(?P<hostname>\S+):~\$"
pattern_prompt = rb"^\S+@(?P<hostname>\S+):~#"
command_exit = "exit"
command_more = "\n"
PLATFORMS = {"46": "RG-1404GF-W"}
......
......@@ -12,7 +12,8 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.SMG"
# pattern_username = r"^\S+ login: "
# pattern_prompt = r"^(?P<hostname>\S+)# "
pattern_prompt = r"(SMG2016> )|(/[\w/]+ # )"
pattern_prompt = rb"(SMG2016> )|(/[\w/]+ # )"
command_exit = "exit"
......@@ -15,19 +15,19 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.TAU"
pattern_username = r"^\S+ [Ll]ogin:"
pattern_password = r"^[Pp]assword:"
pattern_unprivileged_prompt = r"^(?P<hostname>\S+)>\s*"
pattern_prompt = r"^(\S+# |> |config> |\[\S+\]\s*|root@\S+:(~|/\S+)\$)"
pattern_more = (
r'Press any key to continue|\| Press any key to continue \| Press "q" to exit \| '
)
pattern_syntax_error = r"Syntax error: Unknown command|-sh: .+: not found"
pattern_username = rb"^\S+ [Ll]ogin:"
pattern_password = rb"^[Pp]assword:"
pattern_unprivileged_prompt = rb"^(?P<hostname>\S+)>\s*"
pattern_prompt = rb"^(\S+# |> |config> |\[\S+\]\s*|root@\S+:(~|/\S+)\$)"
pattern_more = [
(rb'Press any key to continue|\| Press any key to continue \| Press "q" to exit \| ', b"\n")
]
pattern_syntax_error = rb"Syntax error: Unknown command|-sh: .+: not found"
command_exit = "exit"
command_more = "\n"
command_enter_config = "config"
command_leave_config = "exit"
command_super = "enable"
command_super = b"enable"
rogue_chars = [re.compile(rb"\^J"), b"\r"]
matchers = {
......
......@@ -12,11 +12,12 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.WOP"
pattern_prompt = r"^(?P<hostname>\S+)\s*#|~ #"
command_more = "\n"
command_submit = "\n"
pattern_prompt = rb"^(?P<hostname>\S+)\s*#|~ #"
command_more = b"\n"
command_submit = b"\n"
command_exit = "exit"
pattern_syntax_error = r"Invalid command\."
pattern_syntax_error = rb"Invalid command\."
INTERFACE_TYPES = {
"lo": "loopback", # Loopback
......
......@@ -15,9 +15,10 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Eltex.WOPLR"
pattern_prompt = r"^(?P<hostname>\S+)\s*#|~ #"
pattern_prompt = rb"^(?P<hostname>\S+)\s*#|~ #"
command_exit = "exit"
pattern_syntax_error = r"Invalid command\."
pattern_syntax_error = rb"Invalid command\."
rx_physical = re.compile(r"^(wlan|eth|br|tun|gre)\d+$")
......
......@@ -13,7 +13,7 @@ from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Force10.SFTOS"
pattern_more = rb"^--More-- or \(q\)uit"
pattern_more = [(rb"^--More-- or \(q\)uit", b"\n")]
pattern_unprivileged_prompt = rb"^(?P<host>\S+?)>"
pattern_prompt = rb"^(?P<host>\S+?)#"
pattern_syntax_error = rb"% Invalid input detected at "
......
......@@ -46,7 +46,7 @@ class Profile(BaseProfile):
re.compile(br"\n\r\s+Line \d+ operating, attempt of the Line -\d+ denied!\n\r"),
re.compile(br"\r\n\s+Note: Terminal users login \(IP: \S+ \)"),
re.compile(br"\r\nWarning: Battery is low power!"),
"\r",
b"\r",
]
# to one SNMP GET request
snmp_metrics_get_chunk = 30
......
......@@ -33,7 +33,7 @@ class Profile(BaseProfile):
(rb"Is this ok \[y/N\]: ", b"y\n"),
]
command_disable_pager = "LANG=en_US.UTF-8; PATH=$PATH:/sbin:/usr/sbin; PROMPT_COMMAND=''"
command_super = "sudo bash"
command_super = b"sudo bash"
command_exit = "exit"
INTERFACE_TYPES = {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment