Skip to content
Snippets Groups Projects

Feature/nat 328 site names should be validated

Merged Hakan Calim requested to merge feature/NAT-328-Site-names-should-be-validated into develop
1 file
+ 14
0
Compare changes
  • Side-by-side
  • Inline
  • 70780c81
    NAT-328: Moved the site name validation to this file · 70780c81
    Hakan Calim authored
+ 14
0
@@ -151,3 +151,17 @@ def validate_iptrunk_unique_interface(interfaces: list[LAGMember]) -> list[LAGMe
if len(interface_names) != len(set(interface_names)):
raise ValueError("Interfaces must be unique.")
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
Loading