Skip to content

Commit cd1256f

Browse files
Copilotqkalsky
andcommitted
Refactor: Extract VLAN 1 pattern to module-level constant
Co-authored-by: qkalsky <[email protected]>
1 parent 114817d commit cd1256f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

cloudshell/networking/cisco/command_actions/iface_actions.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
iface,
1313
)
1414

15+
# Pattern to match VLAN 1 configuration (default state that should be preserved)
16+
VLAN_1_PATTERN = r"^\s*switchport\s+trunk\s+allowed\s+vlan\s+1\s*$"
17+
1518

1619
class IFaceActions:
1720
def __init__(self, cli_service, logger):
@@ -115,11 +118,7 @@ def clean_interface_switchport_config(
115118
for line in current_config.splitlines():
116119
if line.strip(" ").startswith("switchport "):
117120
# Skip removing "switchport trunk allowed vlan 1" as it's the default state
118-
if re.match(
119-
r"^\s*switchport\s+trunk\s+allowed\s+vlan\s+1\s*$",
120-
line,
121-
re.IGNORECASE,
122-
):
121+
if re.match(VLAN_1_PATTERN, line, re.IGNORECASE):
123122
continue
124123
line_to_remove = re.sub(r"\s+\d+[-\d+,]+", "", line).strip(" ")
125124
CommandTemplateExecutor(

0 commit comments

Comments
 (0)