Skip to content
Snippets Groups Projects
Commit 70780c81 authored by Hakan Calim's avatar Hakan Calim
Browse files

NAT-328: Moved the site name validation to this file

parent d67e1d6d
No related branches found
No related tags found
No related merge requests found
...@@ -151,3 +151,17 @@ def validate_iptrunk_unique_interface(interfaces: list[LAGMember]) -> list[LAGMe ...@@ -151,3 +151,17 @@ def validate_iptrunk_unique_interface(interfaces: list[LAGMember]) -> list[LAGMe
if len(interface_names) != len(set(interface_names)): if len(interface_names) != len(set(interface_names)):
raise ValueError("Interfaces must be unique.") raise ValueError("Interfaces must be unique.")
return interfaces return interfaces
def validate_site_name(site_name: str) -> str:
"""Accepts only three capital letters and optional a digit after the capital letters for the sitename.
The site names can have the format like this: AMS, LON, LON0...LON9
"""
# Accept 3 chapital letters and only one ditigt after capital letters.
pattern = re.compile(r"^[A-Z]{3}[0-9]?$")
if not bool(pattern.match(site_name)):
raise ValueError(f"Enter a valid site name similar looks like AMS, AMS1or LON9. Get: {site_name}")
return site_name
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment