Skip to content
Snippets Groups Projects

Update regex that validates interface names

Merged Karel van Klink requested to merge feature/update-interface-name-regex into develop
+ 3
3
@@ -252,8 +252,8 @@ def validate_interface_name_list(interface_name_list: list, vendor: str) -> list
@@ -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.
"""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 '-',
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,
then a number between 0 and 19, a forward slash '/', another number between 0 and 99,
another forward slash '/', and ends with a digit between 0 and 9.
another forward slash '/', and ends with a number between 0 and 99.
For example: 'xe-1/0/0'.
For example: 'xe-1/0/0'.
:param list interface_name_list: List of interface names to validate.
: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
@@ -265,7 +265,7 @@ def validate_interface_name_list(interface_name_list: list, vendor: str) -> list
# For Nokia nothing to do
# For Nokia nothing to do
if vendor == Vendor.NOKIA:
if vendor == Vendor.NOKIA:
return interface_name_list
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:
for interface in interface_name_list:
if not bool(pattern.match(interface.interface_name)):
if not bool(pattern.match(interface.interface_name)):
error_msg = (
error_msg = (
Loading