Skip to content
Snippets Groups Projects
Commit 12c44fd2 authored by Karel van Klink's avatar Karel van Klink :smiley_cat: Committed by Neda Moeini
Browse files

Update regex that validates interface names

parent 1bd37205
No related branches found
No related tags found
No related merge requests found
Pipeline #87246 canceled
This commit is part of merge request !219. Comments created here will be created in the context of that merge request.
......@@ -252,8 +252,8 @@ def validate_interface_name_list(interface_name_list: list, vendor: str) -> list
"""Validate that the provided interface name matches the expected pattern.
The expected pattern for the interface name is one of 'ge', 'et', 'xe' followed by a dash '-',
then a digit between 0 and 9, a forward slash '/', another digit between 0 and 9,
another forward slash '/', and ends with a digit between 0 and 9.
then a number between 0 and 19, a forward slash '/', another number between 0 and 99,
another forward slash '/', and ends with a number between 0 and 99.
For example: 'xe-1/0/0'.
:param list interface_name_list: List of interface names to validate.
......@@ -265,7 +265,7 @@ def validate_interface_name_list(interface_name_list: list, vendor: str) -> list
# For Nokia nothing to do
if vendor == Vendor.NOKIA:
return interface_name_list
pattern = re.compile(r"^(ge|et|xe)-[0-9]/[0-9]/[0-9]$")
pattern = re.compile(r"^(ge|et|xe)-1?[0-9]/[0-9]{1,2}/[0-9]{1,2}$")
for interface in interface_name_list:
if not bool(pattern.match(interface.interface_name)):
error_msg = (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment