diff --git a/gso/api/v1/network.py b/gso/api/v1/network.py index 62983f77f0b2287cb366ba2cb062babc2e972d05..e4a19de9e90475f70261e4bf408498de68a95af9 100644 --- a/gso/api/v1/network.py +++ b/gso/api/v1/network.py @@ -13,9 +13,9 @@ from starlette import status from gso.products.product_blocks.iptrunk import IptrunkType from gso.products.product_blocks.router import RouterRole from gso.services.subscriptions import get_active_iptrunk_subscriptions -from gso.types.coordinates import LatitudeCoordinate, LongitudeCoordinate -from gso.types.interfaces import PhysicalPortCapacity from gso.utils.shared_enums import Vendor +from gso.utils.types.coordinates import LatitudeCoordinate, LongitudeCoordinate +from gso.utils.types.interfaces import PhysicalPortCapacity router = APIRouter(prefix="/networks", tags=["Network"], dependencies=[Depends(authorize)]) diff --git a/gso/cli/imports.py b/gso/cli/imports.py index e71794653f446b25251c11d82cb6c5f0ac68c97e..33a4636a0b5010d57a7f3c06053e468bb37e191b 100644 --- a/gso/cli/imports.py +++ b/gso/cli/imports.py @@ -31,9 +31,10 @@ from gso.services.subscriptions import ( get_active_subscriptions_by_field_and_value, get_subscriptions, ) -from gso.types.base_site import BaseSiteValidatorModel -from gso.types.interfaces import LAGMember, LAGMemberList, PhysicalPortCapacity -from gso.utils.shared_enums import IPv4AddressType, IPv6AddressType, PortNumber, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.base_site import BaseSiteValidatorModel +from gso.utils.types.interfaces import LAGMember, LAGMemberList, PhysicalPortCapacity +from gso.utils.types.ip_address import IPv4AddressType, IPv6AddressType, PortNumber app: typer.Typer = typer.Typer() diff --git a/gso/products/product_blocks/iptrunk.py b/gso/products/product_blocks/iptrunk.py index 1ff4fe4652d6fea6f1a80491976ff3063978f82e..ad83609defc7289d49ff01b9501ce87469e16f5b 100644 --- a/gso/products/product_blocks/iptrunk.py +++ b/gso/products/product_blocks/iptrunk.py @@ -15,7 +15,7 @@ from gso.products.product_blocks.router import ( RouterBlockInactive, RouterBlockProvisioning, ) -from gso.types.interfaces import LAGMemberList, PhysicalPortCapacity +from gso.utils.types.interfaces import LAGMemberList, PhysicalPortCapacity class IptrunkType(strEnum): diff --git a/gso/products/product_blocks/lan_switch_interconnect.py b/gso/products/product_blocks/lan_switch_interconnect.py index 544da1e757c279ca3c16f2e52489dba2624e68aa..e2626de5c680bb983454ed32b523e61f1b78ad6d 100644 --- a/gso/products/product_blocks/lan_switch_interconnect.py +++ b/gso/products/product_blocks/lan_switch_interconnect.py @@ -5,7 +5,7 @@ from orchestrator.types import SubscriptionLifecycle, strEnum from gso.products.product_blocks.router import RouterBlock, RouterBlockInactive, RouterBlockProvisioning from gso.products.product_blocks.switch import SwitchBlock, SwitchBlockInactive, SwitchBlockProvisioning -from gso.types.interfaces import LAGMemberList +from gso.utils.types.interfaces import LAGMemberList class LanSwitchInterconnectAddressSpace(strEnum): diff --git a/gso/products/product_blocks/office_router.py b/gso/products/product_blocks/office_router.py index 65eab0256a073c699f3ea2ef84d96e3352096722..bff50dd3018afd3f2bdee771cd0ca9405ae44b47 100644 --- a/gso/products/product_blocks/office_router.py +++ b/gso/products/product_blocks/office_router.py @@ -8,7 +8,8 @@ from gso.products.product_blocks.site import ( SiteBlockInactive, SiteBlockProvisioning, ) -from gso.utils.shared_enums import IPv4AddressType, IPv6AddressType, PortNumber, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.ip_address import IPv4AddressType, IPv6AddressType, PortNumber class OfficeRouterBlockInactive( diff --git a/gso/products/product_blocks/router.py b/gso/products/product_blocks/router.py index 17deeccb1ac8a5ee9bcfaa14fa25f27360881e7c..6d7dabf9dff3eaded338a420834f9e509d8584a1 100644 --- a/gso/products/product_blocks/router.py +++ b/gso/products/product_blocks/router.py @@ -8,7 +8,8 @@ from gso.products.product_blocks.site import ( SiteBlockInactive, SiteBlockProvisioning, ) -from gso.utils.shared_enums import IPv4AddressType, IPv6AddressType, PortNumber, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.ip_address import IPv4AddressType, IPv6AddressType, PortNumber class RouterRole(strEnum): diff --git a/gso/products/product_blocks/site.py b/gso/products/product_blocks/site.py index 436288c5fad58c79684b73f9892c150875929050..eec868479f49f005aa077242a397a52f94e216b1 100644 --- a/gso/products/product_blocks/site.py +++ b/gso/products/product_blocks/site.py @@ -3,9 +3,9 @@ from orchestrator.domain.base import ProductBlockModel from orchestrator.types import SubscriptionLifecycle, strEnum -from gso.types.coordinates import LatitudeCoordinate, LongitudeCoordinate -from gso.types.ip_address import IPAddress -from gso.types.site_name import SiteName +from gso.utils.types.coordinates import LatitudeCoordinate, LongitudeCoordinate +from gso.utils.types.ip_address import IPAddress +from gso.utils.types.site_name import SiteName class SiteTier(strEnum): diff --git a/gso/products/product_blocks/super_pop_switch.py b/gso/products/product_blocks/super_pop_switch.py index 3335b28cf90ee9d55abe59be528f404d44d905b8..872f37b59042b2534de234d26241cd2792c55c3e 100644 --- a/gso/products/product_blocks/super_pop_switch.py +++ b/gso/products/product_blocks/super_pop_switch.py @@ -8,7 +8,8 @@ from gso.products.product_blocks.site import ( SiteBlockInactive, SiteBlockProvisioning, ) -from gso.utils.shared_enums import IPv4AddressType, PortNumber, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.ip_address import IPv4AddressType, PortNumber class SuperPopSwitchBlockInactive( diff --git a/gso/products/product_blocks/switch.py b/gso/products/product_blocks/switch.py index f0aa0414e11409b58341fc2648f3066fa91c5aee..bdf2b4657f8d8674a5c4e19c192f455ef1e31524 100644 --- a/gso/products/product_blocks/switch.py +++ b/gso/products/product_blocks/switch.py @@ -9,7 +9,8 @@ from gso.products.product_blocks.site import ( SiteBlockInactive, SiteBlockProvisioning, ) -from gso.utils.shared_enums import PortNumber, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.ip_address import PortNumber class SwitchModel(strEnum): diff --git a/gso/services/infoblox.py b/gso/services/infoblox.py index 22e56ab5a7215ed8026d1a3a80e7d72ee1ba916e..8e06be865a43b36474649a1cda3fc697a330e1f7 100644 --- a/gso/services/infoblox.py +++ b/gso/services/infoblox.py @@ -10,7 +10,7 @@ from infoblox_client.exceptions import ( ) from gso.settings import IPAMParams, load_oss_params -from gso.utils.shared_enums import IPv4AddressType, IPv6AddressType +from gso.utils.types.ip_address import IPv4AddressType, IPv6AddressType logger = getLogger(__name__) NULL_MAC = "00:00:00:00:00:00" diff --git a/gso/services/librenms_client.py b/gso/services/librenms_client.py index 4d8e4b197f647aadf829648a01e056cf8b199068..ae3fcac67aa075db10f66682e2a53543864c3fb1 100644 --- a/gso/services/librenms_client.py +++ b/gso/services/librenms_client.py @@ -10,7 +10,7 @@ from requests import HTTPError, Response from requests.adapters import HTTPAdapter from gso.settings import load_oss_params -from gso.types.snmp import SNMPVersion +from gso.utils.types.snmp import SNMPVersion logger = logging.getLogger(__name__) diff --git a/gso/settings.py b/gso/settings.py index d2a845f3e96b526675d8d0de57972a15218a43ce..f7d40de73c73cdb75ee7c6348210fb12c543100e 100644 --- a/gso/settings.py +++ b/gso/settings.py @@ -16,7 +16,7 @@ from pydantic_forms.types import UUIDstr, strEnum from pydantic_settings import BaseSettings from typing_extensions import Doc -from gso.utils.shared_enums import PortNumber +from gso.utils.types.ip_address import PortNumber logger = logging.getLogger(__name__) diff --git a/gso/types/ip_address.py b/gso/types/ip_address.py deleted file mode 100644 index 2a71b64e0ece87d8cf9f784ecd12bdb197d7b345..0000000000000000000000000000000000000000 --- a/gso/types/ip_address.py +++ /dev/null @@ -1,20 +0,0 @@ -"""IP addresses.""" - -import ipaddress -from typing import Annotated - -from pydantic import AfterValidator - - -def validate_ipv4_or_ipv6(value: str) -> str: - """Validate that a value is a valid IPv4 or IPv6 address.""" - try: - ipaddress.ip_address(value) - except ValueError as e: - msg = "Enter a valid IPv4 or IPv6 address." - raise ValueError(msg) from e - else: - return value - - -IPAddress = Annotated[str, AfterValidator(validate_ipv4_or_ipv6)] diff --git a/gso/utils/helpers.py b/gso/utils/helpers.py index f1063cecd97209247ecd950a49de95bf46f5c0e0..4a78b989d41ddd49e2ee99b5f703a9dd519a7a07 100644 --- a/gso/utils/helpers.py +++ b/gso/utils/helpers.py @@ -11,8 +11,9 @@ from gso.products.product_blocks.router import RouterRole from gso.products.product_types.router import Router from gso.services import subscriptions from gso.services.netbox_client import NetboxClient -from gso.types.interfaces import PhysicalPortCapacity -from gso.utils.shared_enums import IPv4AddressType, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.interfaces import PhysicalPortCapacity +from gso.utils.types.ip_address import IPv4AddressType if TYPE_CHECKING: from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlock diff --git a/gso/utils/shared_enums.py b/gso/utils/shared_enums.py index 94538f78463821bf266bdd15d379ec61b0371d4b..929e5b0bc2c2553c90b36ce8f056c1f22fed74cc 100644 --- a/gso/utils/shared_enums.py +++ b/gso/utils/shared_enums.py @@ -1,16 +1,6 @@ """Shared choices for the different models.""" -import ipaddress -from typing import Annotated, Any - -from pydantic import Field, PlainSerializer from pydantic_forms.types import strEnum -from typing_extensions import Doc - - -def convert_to_str(value: Any) -> str: - """Convert the value to a string.""" - return str(value) class Vendor(strEnum): @@ -20,24 +10,6 @@ class Vendor(strEnum): NOKIA = "nokia" -PortNumber = Annotated[ - int, - Field( - gt=0, - le=49151, - ), - Doc( - "Constrained integer for valid port numbers. The range from 49152 to 65535 is marked as ephemeral, " - "and can therefore not be selected for permanent allocation." - ), -] - - -IPv4AddressType = Annotated[ipaddress.IPv4Address, PlainSerializer(convert_to_str, return_type=str, when_used="always")] - -IPv6AddressType = Annotated[ipaddress.IPv6Address, PlainSerializer(convert_to_str, return_type=str, when_used="always")] - - class ConnectionStrategy(strEnum): """An enumerator for the connection Strategies.""" diff --git a/gso/types/__init__.py b/gso/utils/types/__init__.py similarity index 100% rename from gso/types/__init__.py rename to gso/utils/types/__init__.py diff --git a/gso/types/base_site.py b/gso/utils/types/base_site.py similarity index 69% rename from gso/types/base_site.py rename to gso/utils/types/base_site.py index 3184e174304bfc3e3b3e0f0cb2008ddb0e81d205..c5af009ad460e56619752688f52dc2bdfa5f9e46 100644 --- a/gso/types/base_site.py +++ b/gso/utils/types/base_site.py @@ -3,11 +3,11 @@ from pydantic import BaseModel from gso.products.product_blocks.site import SiteTier -from gso.types.coordinates import LatitudeCoordinate, LongitudeCoordinate -from gso.types.country_code import CountryCode -from gso.types.ip_address import IPAddress -from gso.types.site_name import SiteName -from gso.types.unique_field import UniqueField +from gso.utils.types.coordinates import LatitudeCoordinate, LongitudeCoordinate +from gso.utils.types.country_code import CountryCode +from gso.utils.types.ip_address import IPAddress +from gso.utils.types.site_name import SiteName +from gso.utils.types.unique_field import UniqueField class BaseSiteValidatorModel(BaseModel): diff --git a/gso/types/coordinates.py b/gso/utils/types/coordinates.py similarity index 100% rename from gso/types/coordinates.py rename to gso/utils/types/coordinates.py diff --git a/gso/types/country_code.py b/gso/utils/types/country_code.py similarity index 100% rename from gso/types/country_code.py rename to gso/utils/types/country_code.py diff --git a/gso/types/interfaces.py b/gso/utils/types/interfaces.py similarity index 100% rename from gso/types/interfaces.py rename to gso/utils/types/interfaces.py diff --git a/gso/utils/types/ip_address.py b/gso/utils/types/ip_address.py new file mode 100644 index 0000000000000000000000000000000000000000..94cb8beaf498900e4785d3e222a73685f5d35bf6 --- /dev/null +++ b/gso/utils/types/ip_address.py @@ -0,0 +1,38 @@ +"""IP addresses.""" + +import ipaddress +from typing import Annotated, Any + +from pydantic import AfterValidator, Field, PlainSerializer +from typing_extensions import Doc + + +def validate_ipv4_or_ipv6(value: str) -> str: + """Validate that a value is a valid IPv4 or IPv6 address.""" + try: + ipaddress.ip_address(value) + except ValueError as e: + msg = "Enter a valid IPv4 or IPv6 address." + raise ValueError(msg) from e + else: + return value + + +def _str(value: Any) -> str: + return str(value) + + +IPv4AddressType = Annotated[ipaddress.IPv4Address, PlainSerializer(_str, return_type=str, when_used="always")] +IPv6AddressType = Annotated[ipaddress.IPv6Address, PlainSerializer(_str, return_type=str, when_used="always")] +IPAddress = Annotated[str, AfterValidator(validate_ipv4_or_ipv6)] +PortNumber = Annotated[ + int, + Field( + gt=0, + le=49151, + ), + Doc( + "Constrained integer for valid port numbers. The range from 49152 to 65535 is marked as ephemeral, " + "and can therefore not be selected for permanent allocation." + ), +] diff --git a/gso/types/netbox_router.py b/gso/utils/types/netbox_router.py similarity index 100% rename from gso/types/netbox_router.py rename to gso/utils/types/netbox_router.py diff --git a/gso/types/site_name.py b/gso/utils/types/site_name.py similarity index 100% rename from gso/types/site_name.py rename to gso/utils/types/site_name.py diff --git a/gso/types/snmp.py b/gso/utils/types/snmp.py similarity index 100% rename from gso/types/snmp.py rename to gso/utils/types/snmp.py diff --git a/gso/types/tt_number.py b/gso/utils/types/tt_number.py similarity index 100% rename from gso/types/tt_number.py rename to gso/utils/types/tt_number.py diff --git a/gso/types/unique_field.py b/gso/utils/types/unique_field.py similarity index 100% rename from gso/types/unique_field.py rename to gso/utils/types/unique_field.py diff --git a/gso/workflows/iptrunk/create_imported_iptrunk.py b/gso/workflows/iptrunk/create_imported_iptrunk.py index 18f76a7f93d30e7bc082bb2696ac9daf8448ce86..4d75437504ac6536cf56c8b2f5231bea0a937db8 100644 --- a/gso/workflows/iptrunk/create_imported_iptrunk.py +++ b/gso/workflows/iptrunk/create_imported_iptrunk.py @@ -19,8 +19,8 @@ from gso.products.product_types.iptrunk import ImportedIptrunkInactive from gso.products.product_types.router import Router from gso.services import subscriptions from gso.services.partners import get_partner_by_name -from gso.types.interfaces import LAGMember, LAGMemberList, PhysicalPortCapacity from gso.utils.helpers import active_router_selector +from gso.utils.types.interfaces import LAGMember, LAGMemberList, PhysicalPortCapacity def initial_input_form_generator() -> FormGenerator: diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index c62ca920e595cf945c3a9a456e442e6300da4a5f..9cab8df3078d8c8cfb2eab746d863b429a6434d4 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -34,9 +34,6 @@ from gso.services.partners import get_partner_by_name from gso.services.sharepoint import SharePointClient from gso.services.subscriptions import get_non_terminated_iptrunk_subscriptions from gso.settings import load_oss_params -from gso.types.interfaces import JuniperLAGMember, LAGMember, LAGMemberList, PhysicalPortCapacity -from gso.types.netbox_router import NetboxEnabledRouter -from gso.types.tt_number import TTNumber from gso.utils.helpers import ( available_interfaces_choices, available_lags_choices, @@ -44,6 +41,9 @@ from gso.utils.helpers import ( get_router_vendor, ) from gso.utils.shared_enums import Vendor +from gso.utils.types.interfaces import JuniperLAGMember, LAGMember, LAGMemberList, PhysicalPortCapacity +from gso.utils.types.netbox_router import NetboxEnabledRouter +from gso.utils.types.tt_number import TTNumber from gso.utils.workflow_steps import prompt_sharepoint_checklist_url diff --git a/gso/workflows/iptrunk/deploy_twamp.py b/gso/workflows/iptrunk/deploy_twamp.py index feb7100a46360f5c9fb14ef28f98b6bb4cb165ac..11dce53ba260fd8c8dae08611ae66e4069619d49 100644 --- a/gso/workflows/iptrunk/deploy_twamp.py +++ b/gso/workflows/iptrunk/deploy_twamp.py @@ -13,7 +13,7 @@ from orchestrator.workflows.utils import wrap_modify_initial_input_form from gso.products.product_types.iptrunk import Iptrunk from gso.services.lso_client import execute_playbook, lso_interaction -from gso.types.tt_number import TTNumber +from gso.utils.types.tt_number import TTNumber def _initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: diff --git a/gso/workflows/iptrunk/migrate_iptrunk.py b/gso/workflows/iptrunk/migrate_iptrunk.py index 0ed107a6fb9aab243887a6af3fdf88a355e7b887..c7021875a1d7f2e2fde5424b5493de028b209d58 100644 --- a/gso/workflows/iptrunk/migrate_iptrunk.py +++ b/gso/workflows/iptrunk/migrate_iptrunk.py @@ -33,14 +33,14 @@ from gso.services.netbox_client import NetboxClient from gso.services.sharepoint import SharePointClient from gso.services.subscriptions import get_active_router_subscriptions from gso.settings import load_oss_params -from gso.types.interfaces import JuniperAEInterface, JuniperLAGMember, LAGMember, LAGMemberList -from gso.types.tt_number import TTNumber from gso.utils.helpers import ( available_interfaces_choices, available_lags_choices, get_router_vendor, ) from gso.utils.shared_enums import Vendor +from gso.utils.types.interfaces import JuniperAEInterface, JuniperLAGMember, LAGMember, LAGMemberList +from gso.utils.types.tt_number import TTNumber from gso.utils.workflow_steps import prompt_sharepoint_checklist_url, set_isis_to_max diff --git a/gso/workflows/iptrunk/modify_isis_metric.py b/gso/workflows/iptrunk/modify_isis_metric.py index 493f0eb98c5db0b5edc1d3b20269ef50019d4432..da14d078cea88f0c52256e02ef3dce0429cf7374 100644 --- a/gso/workflows/iptrunk/modify_isis_metric.py +++ b/gso/workflows/iptrunk/modify_isis_metric.py @@ -12,7 +12,7 @@ from orchestrator.workflows.utils import wrap_modify_initial_input_form from gso.products.product_types.iptrunk import Iptrunk from gso.services.lso_client import execute_playbook, lso_interaction -from gso.types.tt_number import TTNumber +from gso.utils.types.tt_number import TTNumber def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: diff --git a/gso/workflows/iptrunk/modify_trunk_interface.py b/gso/workflows/iptrunk/modify_trunk_interface.py index 6ec7d59a83ef272dc63837d8d01b59c81fac07b2..300763826692530abc7c29b0557a4376969b8646 100644 --- a/gso/workflows/iptrunk/modify_trunk_interface.py +++ b/gso/workflows/iptrunk/modify_trunk_interface.py @@ -23,15 +23,16 @@ from gso.products.product_blocks.iptrunk import ( from gso.products.product_types.iptrunk import Iptrunk from gso.services.lso_client import execute_playbook, lso_interaction from gso.services.netbox_client import NetboxClient -from gso.types.interfaces import JuniperLAGMember, LAGMember, LAGMemberList, PhysicalPortCapacity -from gso.types.tt_number import TTNumber from gso.utils.helpers import ( available_interfaces_choices, available_interfaces_choices_including_current_members, calculate_recommended_minimum_links, get_router_vendor, ) -from gso.utils.shared_enums import IPv4AddressType, IPv6AddressType, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.interfaces import JuniperLAGMember, LAGMember, LAGMemberList, PhysicalPortCapacity +from gso.utils.types.ip_address import IPv4AddressType, IPv6AddressType +from gso.utils.types.tt_number import TTNumber from gso.workflows.iptrunk.migrate_iptrunk import check_ip_trunk_optical_levels_pre from gso.workflows.iptrunk.validate_iptrunk import check_ip_trunk_isis diff --git a/gso/workflows/iptrunk/terminate_iptrunk.py b/gso/workflows/iptrunk/terminate_iptrunk.py index fec1c48bb59142d51b6a65f5a1bcfada4d69ee28..ac628d393a9c6dd52880ee28ceb39d403f023fd2 100644 --- a/gso/workflows/iptrunk/terminate_iptrunk.py +++ b/gso/workflows/iptrunk/terminate_iptrunk.py @@ -22,9 +22,9 @@ from gso.products.product_types.iptrunk import Iptrunk from gso.services import infoblox from gso.services.lso_client import execute_playbook, lso_interaction from gso.services.netbox_client import NetboxClient -from gso.types.tt_number import TTNumber from gso.utils.helpers import get_router_vendor from gso.utils.shared_enums import Vendor +from gso.utils.types.tt_number import TTNumber from gso.utils.workflow_steps import set_isis_to_max diff --git a/gso/workflows/lan_switch_interconnect/create_lan_switch_interconnect.py b/gso/workflows/lan_switch_interconnect/create_lan_switch_interconnect.py index 29dd38e479aa7e3efe752081569de0f1cf7304d9..973cf1d88495b4343e390c258d16c3c9f78f65c9 100644 --- a/gso/workflows/lan_switch_interconnect/create_lan_switch_interconnect.py +++ b/gso/workflows/lan_switch_interconnect/create_lan_switch_interconnect.py @@ -21,15 +21,6 @@ from gso.products.product_types.lan_switch_interconnect import LanSwitchIntercon from gso.products.product_types.router import Router from gso.products.product_types.switch import Switch from gso.services.partners import get_partner_by_name -from gso.types.interfaces import ( - JuniperAEInterface, - JuniperLAGMember, - JuniperPhyInterface, - LAGMember, - PhysicalPortCapacity, - validate_interface_names_are_unique, -) -from gso.types.tt_number import TTNumber from gso.utils.helpers import ( active_router_selector, active_switch_selector, @@ -37,6 +28,15 @@ from gso.utils.helpers import ( available_lags_choices, ) from gso.utils.shared_enums import Vendor +from gso.utils.types.interfaces import ( + JuniperAEInterface, + JuniperLAGMember, + JuniperPhyInterface, + LAGMember, + PhysicalPortCapacity, + validate_interface_names_are_unique, +) +from gso.utils.types.tt_number import TTNumber def _initial_input_form(product_name: str) -> FormGenerator: diff --git a/gso/workflows/office_router/create_imported_office_router.py b/gso/workflows/office_router/create_imported_office_router.py index e82f69cbcb31ecc7eadfbd16c757232a3d47bb2a..8b8306343f6dcc29ae97ef7526c8d399e0b6e444 100644 --- a/gso/workflows/office_router/create_imported_office_router.py +++ b/gso/workflows/office_router/create_imported_office_router.py @@ -13,7 +13,8 @@ from gso.products.product_types.office_router import ImportedOfficeRouterInactiv from gso.services import subscriptions from gso.services.partners import get_partner_by_name from gso.services.subscriptions import get_site_by_name -from gso.utils.shared_enums import IPv4AddressType, IPv6AddressType, PortNumber, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.ip_address import IPv4AddressType, IPv6AddressType, PortNumber @step("Create subscription") diff --git a/gso/workflows/opengear/create_imported_opengear.py b/gso/workflows/opengear/create_imported_opengear.py index e7699986018efc53ddd6254c2d827a47ee791cfd..ce4bd3cf039e7323ce861c11feea41f87e647947 100644 --- a/gso/workflows/opengear/create_imported_opengear.py +++ b/gso/workflows/opengear/create_imported_opengear.py @@ -12,7 +12,7 @@ from gso.products import ProductName from gso.products.product_types.opengear import ImportedOpengearInactive from gso.services.partners import get_partner_by_name from gso.services.subscriptions import get_product_id_by_name, get_site_by_name -from gso.utils.shared_enums import IPv4AddressType +from gso.utils.types.ip_address import IPv4AddressType @step("Create subscription") diff --git a/gso/workflows/router/create_imported_router.py b/gso/workflows/router/create_imported_router.py index c8ba442bc30bf8d26b563e83f35b7d4fb1573774..12a71c79b51e0166d976a175d9833870300af1f5 100644 --- a/gso/workflows/router/create_imported_router.py +++ b/gso/workflows/router/create_imported_router.py @@ -14,7 +14,8 @@ from gso.products.product_types.router import ImportedRouterInactive from gso.services.partners import get_partner_by_name from gso.services.subscriptions import get_product_id_by_name, get_site_by_name from gso.utils.helpers import generate_fqdn -from gso.utils.shared_enums import IPv4AddressType, IPv6AddressType, PortNumber, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.ip_address import IPv4AddressType, IPv6AddressType, PortNumber @step("Create subscription") diff --git a/gso/workflows/router/create_router.py b/gso/workflows/router/create_router.py index 68c55cf0909e9781864b14348cc5e47ccd6a3bf0..04d38b750f5fa4ca87591f7affe04674208685bf 100644 --- a/gso/workflows/router/create_router.py +++ b/gso/workflows/router/create_router.py @@ -23,9 +23,10 @@ from gso.services.netbox_client import NetboxClient from gso.services.partners import get_partner_by_name from gso.services.sharepoint import SharePointClient from gso.settings import load_oss_params -from gso.types.tt_number import TTNumber from gso.utils.helpers import generate_fqdn, iso_from_ipv4 -from gso.utils.shared_enums import PortNumber, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.ip_address import PortNumber +from gso.utils.types.tt_number import TTNumber from gso.utils.workflow_steps import ( deploy_base_config_dry, deploy_base_config_real, diff --git a/gso/workflows/router/promote_p_to_pe.py b/gso/workflows/router/promote_p_to_pe.py index f294bd99468942094016687e93937c093788b074..0f0b31da1fcf7efe8049e9d24cd1e20726bff9c0 100644 --- a/gso/workflows/router/promote_p_to_pe.py +++ b/gso/workflows/router/promote_p_to_pe.py @@ -21,9 +21,9 @@ from gso.services import lso_client from gso.services.kentik_client import KentikClient, NewKentikDevice from gso.services.lso_client import lso_interaction from gso.services.subscriptions import get_all_active_sites -from gso.types.tt_number import TTNumber from gso.utils.helpers import generate_inventory_for_active_routers from gso.utils.shared_enums import Vendor +from gso.utils.types.tt_number import TTNumber def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: diff --git a/gso/workflows/router/redeploy_base_config.py b/gso/workflows/router/redeploy_base_config.py index eef8b6e74fe3db1c5d5d292fc498a1872955c622..48348abb6757ff38b40f650c88cb920bc3fda95c 100644 --- a/gso/workflows/router/redeploy_base_config.py +++ b/gso/workflows/router/redeploy_base_config.py @@ -10,7 +10,7 @@ from orchestrator.workflows.utils import wrap_modify_initial_input_form from gso.products.product_types.router import Router from gso.services.lso_client import lso_interaction -from gso.types.tt_number import TTNumber +from gso.utils.types.tt_number import TTNumber from gso.utils.workflow_steps import deploy_base_config_dry, deploy_base_config_real diff --git a/gso/workflows/router/terminate_router.py b/gso/workflows/router/terminate_router.py index 60895ab33d7fc0c40a5d8df58db7d6a543c3361d..f7caa6c9936154f3afff8320f5942504f9477414 100644 --- a/gso/workflows/router/terminate_router.py +++ b/gso/workflows/router/terminate_router.py @@ -28,9 +28,9 @@ from gso.services.librenms_client import LibreNMSClient from gso.services.lso_client import execute_playbook, lso_interaction from gso.services.netbox_client import NetboxClient from gso.settings import load_oss_params -from gso.types.tt_number import TTNumber from gso.utils.helpers import generate_inventory_for_active_routers from gso.utils.shared_enums import Vendor +from gso.utils.types.tt_number import TTNumber logger = logging.getLogger(__name__) diff --git a/gso/workflows/router/update_ibgp_mesh.py b/gso/workflows/router/update_ibgp_mesh.py index f8f17a4829060c6654782a342e0380415e01336c..a506e625ae15014439c538070fb0cf074c605309 100644 --- a/gso/workflows/router/update_ibgp_mesh.py +++ b/gso/workflows/router/update_ibgp_mesh.py @@ -17,9 +17,9 @@ from gso.products.product_types.router import Router from gso.services import librenms_client, lso_client from gso.services.lso_client import lso_interaction from gso.services.subscriptions import get_trunks_that_terminate_on_router -from gso.types.snmp import SNMPVersion -from gso.types.tt_number import TTNumber from gso.utils.helpers import generate_inventory_for_active_routers +from gso.utils.types.snmp import SNMPVersion +from gso.utils.types.tt_number import TTNumber def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: diff --git a/gso/workflows/site/create_imported_site.py b/gso/workflows/site/create_imported_site.py index 297761dbffff46f52851a96dcee65323b016fd30..8a9b3d9eaf3160e47a810a56f5c95d1421f36130 100644 --- a/gso/workflows/site/create_imported_site.py +++ b/gso/workflows/site/create_imported_site.py @@ -14,9 +14,9 @@ from gso.products.product_blocks.site import SiteTier from gso.products.product_types.site import ImportedSiteInactive from gso.services import subscriptions from gso.services.partners import get_partner_by_name -from gso.types.base_site import BaseSiteValidatorModel -from gso.types.coordinates import LatitudeCoordinate, LongitudeCoordinate -from gso.types.ip_address import IPAddress +from gso.utils.types.base_site import BaseSiteValidatorModel +from gso.utils.types.coordinates import LatitudeCoordinate, LongitudeCoordinate +from gso.utils.types.ip_address import IPAddress @step("Create subscription") diff --git a/gso/workflows/site/create_site.py b/gso/workflows/site/create_site.py index ec80732cebfce3edfc79a9a689a8faa6a6e718c4..eb5409d778c019e41ae82c85376ec48fcf4bdcc6 100644 --- a/gso/workflows/site/create_site.py +++ b/gso/workflows/site/create_site.py @@ -12,9 +12,9 @@ from pydantic_forms.validators import ReadOnlyField from gso.products.product_blocks import site as site_pb from gso.products.product_types import site from gso.services.partners import get_partner_by_name -from gso.types.base_site import BaseSiteValidatorModel -from gso.types.coordinates import LatitudeCoordinate, LongitudeCoordinate -from gso.types.ip_address import IPAddress +from gso.utils.types.base_site import BaseSiteValidatorModel +from gso.utils.types.coordinates import LatitudeCoordinate, LongitudeCoordinate +from gso.utils.types.ip_address import IPAddress def initial_input_form_generator(product_name: str) -> FormGenerator: diff --git a/gso/workflows/site/modify_site.py b/gso/workflows/site/modify_site.py index b68626b1db05f4a7548581818aefbe0ea087d66d..9c94e55032ae9712856603463b71299cf8e37fe7 100644 --- a/gso/workflows/site/modify_site.py +++ b/gso/workflows/site/modify_site.py @@ -18,9 +18,9 @@ from pydantic_forms.validators import ReadOnlyField from gso.products.product_blocks.site import SiteTier from gso.products.product_types.site import Site -from gso.types.coordinates import LatitudeCoordinate, LongitudeCoordinate -from gso.types.ip_address import IPAddress -from gso.types.unique_field import UniqueField +from gso.utils.types.coordinates import LatitudeCoordinate, LongitudeCoordinate +from gso.utils.types.ip_address import IPAddress +from gso.utils.types.unique_field import UniqueField def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: diff --git a/gso/workflows/super_pop_switch/create_imported_super_pop_switch.py b/gso/workflows/super_pop_switch/create_imported_super_pop_switch.py index 1cdb7d09d996baae8d1c186db35bfbf3fd27f676..da99dd68249318c5f2931d6196e08c0ae6140737 100644 --- a/gso/workflows/super_pop_switch/create_imported_super_pop_switch.py +++ b/gso/workflows/super_pop_switch/create_imported_super_pop_switch.py @@ -14,7 +14,8 @@ from gso.services import subscriptions from gso.services.partners import get_partner_by_name from gso.services.subscriptions import get_site_by_name from gso.utils.helpers import generate_fqdn -from gso.utils.shared_enums import IPv4AddressType, PortNumber, Vendor +from gso.utils.shared_enums import Vendor +from gso.utils.types.ip_address import IPv4AddressType, PortNumber @step("Create subscription") diff --git a/test/cli/test_imports.py b/test/cli/test_imports.py index 89933fc8de3f9b4860f60d387867dedc2ed99371..d794d0f0a63dd55f97f5ac98ec49774de574d31d 100644 --- a/test/cli/test_imports.py +++ b/test/cli/test_imports.py @@ -16,9 +16,9 @@ from gso.products import Router, Site from gso.products.product_blocks.iptrunk import IptrunkType from gso.products.product_blocks.router import RouterRole from gso.products.product_blocks.site import SiteTier -from gso.types.interfaces import PhysicalPortCapacity from gso.utils.helpers import iso_from_ipv4 from gso.utils.shared_enums import Vendor +from gso.utils.types.interfaces import PhysicalPortCapacity ############## diff --git a/test/conftest.py b/test/conftest.py index 8cfea9d28eacfd24c6397c514245024cb15b5f6d..2eb7e6a28089c621b620fa56d9a55b293c75b099 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -34,7 +34,7 @@ from urllib3_mock import Responses from gso.main import init_gso_app from gso.services.partners import PartnerSchema, create_partner -from gso.types.interfaces import LAGMember, LAGMemberList +from gso.utils.types.interfaces import LAGMember, LAGMemberList from test.fixtures import ( # noqa: F401 iptrunk_side_subscription_factory, iptrunk_subscription_factory, diff --git a/test/fixtures.py b/test/fixtures.py index 4fa5a2a0ec30f416ae4ecbae274e6fa5fa39a843..0bb920c0cfb98e7387d5c9766df77c36a503bf88 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -36,8 +36,8 @@ from gso.products.product_types.router import ImportedRouterInactive, Router, Ro from gso.products.product_types.site import ImportedSiteInactive, Site, SiteInactive from gso.products.product_types.super_pop_switch import ImportedSuperPopSwitchInactive, SuperPopSwitchInactive from gso.services import subscriptions -from gso.types.interfaces import PhysicalPortCapacity from gso.utils.shared_enums import Vendor +from gso.utils.types.interfaces import PhysicalPortCapacity from test.workflows import WorkflowInstanceForTests diff --git a/test/schemas/test_types.py b/test/schemas/test_types.py index 33c3f20937232b75b92c9db5813462b5f0a5c57c..d34f35d78fe148bcaf7edc4753d27620a4a73253 100644 --- a/test/schemas/test_types.py +++ b/test/schemas/test_types.py @@ -1,7 +1,7 @@ import pytest from pydantic import BaseModel, ValidationError -from gso.types.coordinates import LatitudeCoordinate, LongitudeCoordinate +from gso.utils.types.coordinates import LatitudeCoordinate, LongitudeCoordinate class LatitudeModel(BaseModel): diff --git a/test/services/test_librenms_client.py b/test/services/test_librenms_client.py index 1bd14b9b65c06dcc8d1ad3785b575b11de3bfc54..c64b5933ba2f4b845fe34c288cd2be34c8655aca 100644 --- a/test/services/test_librenms_client.py +++ b/test/services/test_librenms_client.py @@ -5,7 +5,7 @@ import pytest from requests import HTTPError from gso.services.librenms_client import LibreNMSClient -from gso.types.snmp import SNMPVersion +from gso.utils.types.snmp import SNMPVersion @pytest.fixture() diff --git a/test/utils/test_helpers.py b/test/utils/test_helpers.py index 5f9476096ea070d3c8856e623e3dc1301f001941..28779cd706a2eb8f5e12caf1f5bd003ebcd8474f 100644 --- a/test/utils/test_helpers.py +++ b/test/utils/test_helpers.py @@ -6,12 +6,12 @@ from orchestrator.types import SubscriptionLifecycle from gso.products import Router from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlock from gso.products.product_blocks.router import RouterRole -from gso.types.tt_number import validate_tt_number from gso.utils.helpers import ( available_interfaces_choices_including_current_members, generate_inventory_for_active_routers, ) from gso.utils.shared_enums import Vendor +from gso.utils.types.tt_number import validate_tt_number @pytest.fixture() diff --git a/test/workflows/iptrunk/test_create_imported_iptrunk.py b/test/workflows/iptrunk/test_create_imported_iptrunk.py index 263c4f161d99985b48da258d1660925e58c24157..d172dc8d7ec3d38c5e35ca6d61b7ec1cdcc0db12 100644 --- a/test/workflows/iptrunk/test_create_imported_iptrunk.py +++ b/test/workflows/iptrunk/test_create_imported_iptrunk.py @@ -4,7 +4,7 @@ from orchestrator.types import SubscriptionLifecycle from gso.products import ProductName from gso.products.product_blocks.iptrunk import IptrunkType from gso.products.product_types.iptrunk import ImportedIptrunk -from gso.types.interfaces import PhysicalPortCapacity +from gso.utils.types.interfaces import PhysicalPortCapacity from test.workflows import ( assert_complete, extract_state, diff --git a/test/workflows/iptrunk/test_create_iptrunk.py b/test/workflows/iptrunk/test_create_iptrunk.py index cd33943ce75887824d73ac2a810cef2a75edfa04..0b7e00e638db87ddb27674d524bcbdde990d6067 100644 --- a/test/workflows/iptrunk/test_create_iptrunk.py +++ b/test/workflows/iptrunk/test_create_iptrunk.py @@ -7,8 +7,8 @@ from infoblox_client.objects import HostRecord from gso.products import Iptrunk, ProductName from gso.products.product_blocks.iptrunk import IptrunkType from gso.services.subscriptions import get_product_id_by_name -from gso.types.interfaces import PhysicalPortCapacity from gso.utils.shared_enums import Vendor +from gso.utils.types.interfaces import PhysicalPortCapacity from test import USER_CONFIRM_EMPTY_FORM from test.services.conftest import MockedNetboxClient, MockedSharePointClient from test.workflows import ( diff --git a/test/workflows/iptrunk/test_modify_trunk_interface.py b/test/workflows/iptrunk/test_modify_trunk_interface.py index b784d262a75533e5e46945763c76c06e391cd269..85c395e8bff7491b700cc7cda33219a25c69a9ab 100644 --- a/test/workflows/iptrunk/test_modify_trunk_interface.py +++ b/test/workflows/iptrunk/test_modify_trunk_interface.py @@ -4,8 +4,8 @@ import pytest from gso.products import Iptrunk from gso.products.product_blocks.iptrunk import IptrunkType -from gso.types.interfaces import LAGMemberList, PhysicalPortCapacity from gso.utils.shared_enums import Vendor +from gso.utils.types.interfaces import LAGMemberList, PhysicalPortCapacity from test.conftest import UseJuniperSide from test.workflows import ( assert_complete,