Skip to content

Commit

Permalink
Merge pull request #324 from mota-ovhcloud/patch-1
Browse files Browse the repository at this point in the history
Add maintenance mode in cisco_nxos prompt patterns
  • Loading branch information
carlmontanari authored Apr 25, 2024
2 parents a15b713 + 4296fb4 commit f0d0812
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
12 changes: 8 additions & 4 deletions scrapli/driver/core/cisco_nxos/base_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
PRIVS = {
"exec": (
PrivilegeLevel(
pattern=r"^[\w.\-]{1,63}>\s?$",
pattern=r"^[\w.\-]{1,63}(\(maint\-mode\))?>\s?$",
name="exec",
previous_priv="",
deescalate="",
Expand All @@ -19,7 +19,7 @@
),
"privilege_exec": (
PrivilegeLevel(
pattern=r"^[\w.\-]{1,63}#\s?$",
pattern=r"^[\w.\-]{1,63}(\(maint\-mode\))?#\s?$",
name="privilege_exec",
previous_priv="exec",
deescalate="disable",
Expand All @@ -31,7 +31,7 @@
),
"configuration": (
PrivilegeLevel(
pattern=r"^[\w.\-]{1,63}\(config[\w.\-@/:\+]{0,32}\)#\s?$",
pattern=r"^[\w.\-]{1,63}(\(maint\-mode\))?\(config[\w.\-@/:\+]{0,32}\)#\s?$",
name="configuration",
previous_priv="privilege_exec",
deescalate="end",
Expand All @@ -47,7 +47,11 @@
# for now doesnt seem to be a reason to differentiate between them, so just have one
# giant pattern
pattern=(
r"(^[\w.\-]{1,63}\-tcl#\s?$)|" r"(^[\w.\-]{1,63}\(config\-tcl\)#\s?$)|" r"(^>\s?$)"
r"(^[\w.\-]{1,63}\-tcl#\s?$)|"
r"(^[\w.\-]{1,63}\(config\-tcl\)#\s?$)|"
r"(^>\s?$)|"
r"(^[\w.\-]{1,63}\(maint\-mode\-tcl\)#\s?$)|"
r"(^[\w.\-]{1,63}\(maint\-mode\)\(config\-tcl\)#\s?$)"
),
name="tclsh",
previous_priv="privilege_exec",
Expand Down
20 changes: 17 additions & 3 deletions tests/unit/driver/core/cisco_nxos/test_cisco_nxos_base_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@
("configuration", "switch(config-router)# "),
("configuration", "switch(config-tacacs+)# "),
("privilege_exec", "swi_tch# "),
("configuration", "switch(config)# "),
("tclsh", "switch-tcl# "),
("tclsh", "> "),
("privilege_exec", "switch(maint-mode)# "),
("configuration", "switch(maint-mode)(config)# "),
("configuration", "switch(maint-mode)(config-if)# "),
("configuration", "switch(maint-mode)(config-subif)# "),
("configuration", "switch(maint-mode)(config-router)# "),
("configuration", "switch(maint-mode)(config-tacacs+)# "),
("tclsh", "switch(maint-mode-tcl)# "),
("configuration", "switch(maint-mode)(config-tcl)# "),
],
ids=[
"exec",
Expand All @@ -32,9 +39,16 @@
"configuration_routing_protocol",
"configuration_tacacs",
"underscore_privilege_exec",
"configuration",
"tclsh",
"tclsh_privilege_exec",
"tclsh_command_mode",
"maint_mode_privilege_exec",
"maint_mode_configuration",
"maint_mode_configuration_interface",
"maint_mode_configuration_subinterface",
"maint_mode_configuration_routing_protocol",
"maint_mode_configuration_tacacs",
"maint_mode_tclsh_privilege_exec",
"maint_mode_tclsh_configuration",
],
)
def test_prompt_patterns(priv_pattern, sync_nxos_driver):
Expand Down

0 comments on commit f0d0812

Please sign in to comment.