Skip to content
Snippets Groups Projects
Commit 21124fe6 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

apply feedback, mostly remove redundant comments

parent 7c8cf514
No related branches found
No related tags found
1 merge request!64new IP trunk migration
...@@ -13,20 +13,15 @@ class RouterVendor(strEnum): ...@@ -13,20 +13,15 @@ class RouterVendor(strEnum):
"""Enumerator for the different product vendors that are supported.""" """Enumerator for the different product vendors that are supported."""
JUNIPER = "juniper" JUNIPER = "juniper"
"""Juniper routers."""
NOKIA = "nokia" NOKIA = "nokia"
"""Nokia routers."""
class RouterRole(strEnum): class RouterRole(strEnum):
"""Enumerator for the different types of routers.""" """Enumerator for the different types of routers."""
P = "p" P = "p"
"""P router."""
PE = "pe" PE = "pe"
"""PE router."""
AMT = "amt" AMT = "amt"
"""AMT router."""
class PortNumber(ConstrainedInt): class PortNumber(ConstrainedInt):
...@@ -36,9 +31,7 @@ class PortNumber(ConstrainedInt): ...@@ -36,9 +31,7 @@ class PortNumber(ConstrainedInt):
""" """
gt = 0 gt = 0
"""The lower bound of the valid port number range."""
le = 49151 le = 49151
"""As mentioned earlier, the ephemeral port range should not be chosen, and is therefore not available."""
class RouterBlockInactive( class RouterBlockInactive(
......
...@@ -33,11 +33,8 @@ class CUDOperation(strEnum): ...@@ -33,11 +33,8 @@ class CUDOperation(strEnum):
""" """
POST = "POST" POST = "POST"
"""Creation is done with a `POST` request."""
PUT = "PUT" PUT = "PUT"
"""Updating is done with a `PUT` request."""
DELETE = "DELETE" DELETE = "DELETE"
"""Removal is done with a `DELETE` request."""
def _send_request(endpoint: str, parameters: dict, process_id: UUIDstr, operation: CUDOperation) -> None: def _send_request(endpoint: str, parameters: dict, process_id: UUIDstr, operation: CUDOperation) -> None:
......
...@@ -16,7 +16,7 @@ from gso.products.product_types import site ...@@ -16,7 +16,7 @@ from gso.products.product_types import site
from gso.workflows.utils import customer_selector from gso.workflows.utils import customer_selector
def initial_input_form_generator(product_name: str) -> FormGenerator: def initial_input_form_generator(product_name: str) -> FormGenerator: # noqa: C901
class CreateSiteForm(FormPage): class CreateSiteForm(FormPage):
class Config: class Config:
title = product_name title = product_name
...@@ -37,24 +37,26 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: ...@@ -37,24 +37,26 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
def country_code_must_exist(cls, country_code: str) -> str | NoReturn: def country_code_must_exist(cls, country_code: str) -> str | NoReturn:
try: try:
_ = pycountry.countries.lookup(country_code) _ = pycountry.countries.lookup(country_code)
# Lookup succeeded, the country code is valid.
return country_code return country_code
except LookupError: except LookupError:
# Lookup failed, the country code is not valid.
raise ValueError("Invalid or non-existent country code, it must be in ISO 3166-1 alpha-2 format.") raise ValueError("Invalid or non-existent country code, it must be in ISO 3166-1 alpha-2 format.")
@validator("site_latitude", allow_reuse=True) @validator("site_latitude", allow_reuse=True)
def latitude_must_be_valid(cls, latitude: str) -> str | NoReturn: def latitude_must_be_valid(cls, latitude: str) -> str | NoReturn:
if -90 <= float(latitude) <= 90: def _is_valid_latitude(degree: float) -> bool:
# Check whether the value is a valid degree of latitude. return -90 <= degree <= 90
if _is_valid_latitude(float(latitude)):
return latitude return latitude
raise ValueError("Entered latitude is not a valid value, must be between -90.0° and 90.0°.") raise ValueError("Entered latitude is not a valid value, must be between -90.0° and 90.0°.")
@validator("site_longitude", allow_reuse=True) @validator("site_longitude", allow_reuse=True)
def longitude_must_be_valid(cls, longitude: str) -> str | NoReturn: def longitude_must_be_valid(cls, longitude: str) -> str | NoReturn:
if -180 <= float(longitude) <= 180: def _is_valid_longitude(degree: float) -> bool:
# Check whether the value is a valid degree of longitude. return -180 <= degree <= 180
if _is_valid_longitude(float(longitude)):
return longitude return longitude
raise ValueError("Entered longitude is not a valid value, must be between -180.0° and 180.0°.") raise ValueError("Entered longitude is not a valid value, must be between -180.0° and 180.0°.")
...@@ -63,7 +65,6 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: ...@@ -63,7 +65,6 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
def ts_address_must_be_valid(cls, ts_address: str) -> str | NoReturn: def ts_address_must_be_valid(cls, ts_address: str) -> str | NoReturn:
try: try:
ipaddress.ip_address(ts_address) ipaddress.ip_address(ts_address)
# The address is valid
return ts_address return ts_address
except ValueError: except ValueError:
raise ValueError("Enter a valid IPv4 or v6 address.") raise ValueError("Enter a valid IPv4 or v6 address.")
......
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