From f5235028d63b2b522b8239ead8575f689be8409f Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Thu, 6 Jun 2024 11:06:02 +0200 Subject: [PATCH] Update regex that validates interface names --- gso/utils/helpers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gso/utils/helpers.py b/gso/utils/helpers.py index 28269a3d..d27e7c6d 100644 --- a/gso/utils/helpers.py +++ b/gso/utils/helpers.py @@ -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 = ( -- GitLab