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):
"""Enumerator for the different product vendors that are supported."""
JUNIPER = "juniper"
"""Juniper routers."""
NOKIA = "nokia"
"""Nokia routers."""
class RouterRole(strEnum):
"""Enumerator for the different types of routers."""
P = "p"
"""P router."""
PE = "pe"
"""PE router."""
AMT = "amt"
"""AMT router."""
class PortNumber(ConstrainedInt):
......@@ -36,9 +31,7 @@ class PortNumber(ConstrainedInt):
"""
gt = 0
"""The lower bound of the valid port number range."""
le = 49151
"""As mentioned earlier, the ephemeral port range should not be chosen, and is therefore not available."""
class RouterBlockInactive(
......
......@@ -33,11 +33,8 @@ class CUDOperation(strEnum):
"""
POST = "POST"
"""Creation is done with a `POST` request."""
PUT = "PUT"
"""Updating is done with a `PUT` request."""
DELETE = "DELETE"
"""Removal is done with a `DELETE` request."""
def _send_request(endpoint: str, parameters: dict, process_id: UUIDstr, operation: CUDOperation) -> None:
......
......@@ -16,7 +16,7 @@ from gso.products.product_types import site
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 Config:
title = product_name
......@@ -37,24 +37,26 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
def country_code_must_exist(cls, country_code: str) -> str | NoReturn:
try:
_ = pycountry.countries.lookup(country_code)
# Lookup succeeded, the country code is valid.
return country_code
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.")
@validator("site_latitude", allow_reuse=True)
def latitude_must_be_valid(cls, latitude: str) -> str | NoReturn:
if -90 <= float(latitude) <= 90:
# Check whether the value is a valid degree of latitude.
def _is_valid_latitude(degree: float) -> bool:
return -90 <= degree <= 90
if _is_valid_latitude(float(latitude)):
return latitude
raise ValueError("Entered latitude is not a valid value, must be between -90.0° and 90.0°.")
@validator("site_longitude", allow_reuse=True)
def longitude_must_be_valid(cls, longitude: str) -> str | NoReturn:
if -180 <= float(longitude) <= 180:
# Check whether the value is a valid degree of longitude.
def _is_valid_longitude(degree: float) -> bool:
return -180 <= degree <= 180
if _is_valid_longitude(float(longitude)):
return longitude
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:
def ts_address_must_be_valid(cls, ts_address: str) -> str | NoReturn:
try:
ipaddress.ip_address(ts_address)
# The address is valid
return ts_address
except ValueError:
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