From 1b94b0ae3133617a2c0b2a034ceffa5cb63c1206 Mon Sep 17 00:00:00 2001 From: Fedor Suchkov Date: Sat, 30 Nov 2024 09:04:48 -0500 Subject: [PATCH] Fix regex to catch Juniper SRX multichassis node status prompt parts. --- scrapli/driver/core/juniper_junos/base_driver.py | 8 ++++---- .../core/juniper_junos/test_juniper_junos_base_driver.py | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scrapli/driver/core/juniper_junos/base_driver.py b/scrapli/driver/core/juniper_junos/base_driver.py index ef6627b5..7371bef3 100644 --- a/scrapli/driver/core/juniper_junos/base_driver.py +++ b/scrapli/driver/core/juniper_junos/base_driver.py @@ -5,7 +5,7 @@ PRIVS = { "exec": ( PrivilegeLevel( - pattern=r"^({\w+(:\d){0,1}}\n){0,1}[\w\-@()/:\.]{1,63}>\s?$", + pattern=r"^({\w+(:(\w+){0,1}\d){0,1}}\n){0,1}[\w\-@()/:\.]{1,63}>\s?$", name="exec", previous_priv="", deescalate="", @@ -16,7 +16,7 @@ ), "configuration": ( PrivilegeLevel( - pattern=r"^({\w+(:\d){0,1}}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", + pattern=r"^({\w+(:(\w+){0,1}\d){0,1}}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", name="configuration", previous_priv="exec", deescalate="exit configuration-mode", @@ -27,7 +27,7 @@ ), "configuration_exclusive": ( PrivilegeLevel( - pattern=r"^({\w+(:\d){0,1}}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", + pattern=r"^({\w+(:(\w+){0,1}\d){0,1}}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", name="configuration_exclusive", previous_priv="exec", deescalate="exit configuration-mode", @@ -38,7 +38,7 @@ ), "configuration_private": ( PrivilegeLevel( - pattern=r"^({\w+(:\d){0,1}}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", + pattern=r"^({\w+(:(\w+){0,1}\d){0,1}}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", name="configuration_private", previous_priv="exec", deescalate="exit configuration-mode", diff --git a/tests/unit/driver/core/juniper_junos/test_juniper_junos_base_driver.py b/tests/unit/driver/core/juniper_junos/test_juniper_junos_base_driver.py index bdfb6779..35652290 100644 --- a/tests/unit/driver/core/juniper_junos/test_juniper_junos_base_driver.py +++ b/tests/unit/driver/core/juniper_junos/test_juniper_junos_base_driver.py @@ -14,9 +14,11 @@ ("exec", "rancid@router2.xyz6> "), ("exec", "{master}\nusername@MX-960-PE1>"), ("exec", "{backup}\nusername@MX-480-PE2>"), + ("exec", "{primary:node0}\nusername@SRX-4600-FW1>"), ("configuration", "rancid@router2.xyz6# "), ("configuration", "{master}[edit]\nusername@MX-960-PE1#"), ("configuration", "{backup}[edit]\nusername@MX-480-PE2#"), + ("configuration", "{primary:node0}\nusername@SRX-4600-FW1#"), ("shell", "asdfklsdjlf\n%"), ("shell", "[vrf:foo] regress@EVOvFOOBAR_RE0-re0:~$"), ("root_shell", "root@%"), @@ -30,9 +32,11 @@ "exec_w_period", "exec-mx-master-re", "exec-mx-backup-re", + "exec-srx-primary-node", "configuration_w_period", "configuration-mx-master-re", "configuration-mx-backup-re", + "configuration-srx-primary-node", "shell", "shell-re0", "root",