Skip to content
Snippets Groups Projects
Commit f5235028 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 d94ff3df
No related branches found
No related tags found
1 merge request!219Update regex that validates interface names
Pipeline #87251 failed
......@@ -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.
Finish editing this message first!
Please register or to comment