diff --git a/gso/api/v1/imports.py b/gso/api/v1/imports.py index de160e2a4c4808104268620f8d5c40233243f8c1..242deb5ed47df089ebcf1c41b21a70f56dc4c0af 100644 --- a/gso/api/v1/imports.py +++ b/gso/api/v1/imports.py @@ -7,7 +7,7 @@ from orchestrator.security import opa_security_default from orchestrator.services import processes, subscriptions from sqlalchemy.exc import MultipleResultsFound -from utils.types.imports import ImportResponseModel, IptrunkImportModel, RouterImportModel, SiteImportModel +from gso.utils.types.imports import ImportResponseModel, IptrunkImportModel, RouterImportModel, SiteImportModel router = APIRouter(prefix="/imports", tags=["Imports"], dependencies=[Depends(opa_security_default)]) diff --git a/gso/products/product_blocks/iptrunk.py b/gso/products/product_blocks/iptrunk.py index 3efd0824abbc7d281ec7a0a764884d95dc7e9e39..52d28ebf47c8bb507374b65b990e2520115d7f90 100644 --- a/gso/products/product_blocks/iptrunk.py +++ b/gso/products/product_blocks/iptrunk.py @@ -8,8 +8,8 @@ from orchestrator.forms.validators import UniqueConstrainedList from orchestrator.types import SubscriptionLifecycle, strEnum from pydantic import Field -from gso.products.product_blocks import PhyPortCapacity from gso.products.product_blocks.router import RouterBlock, RouterBlockInactive, RouterBlockProvisioning +from gso.utils.types.phy_port import PhyPortCapacity class IptrunkType(strEnum): diff --git a/gso/services/netbox_client.py b/gso/services/netbox_client.py index 3ed80592139bb5b0d2c8588664f9fded5caf8382..d583448ce5cffa35b575c6eacccfded55b804664 100644 --- a/gso/services/netbox_client.py +++ b/gso/services/netbox_client.py @@ -5,7 +5,7 @@ import pydantic import pynetbox from pynetbox.models.dcim import Devices, DeviceTypes, Interfaces -from gso.products import Router +from gso.products.product_types.router import Router from gso.settings import load_oss_params from gso.utils.device_info import DEFAULT_SITE, FEASIBLE_IP_TRUNK_LAG_RANGE, ROUTER_ROLE, TierInfo diff --git a/gso/utils/types/imports.py b/gso/utils/types/imports.py index da1e242aab47d85abb7bc01d18cf1a51eaf034d8..d0ce27c0866817ae6e8cded76a87a426802a2a33 100644 --- a/gso/utils/types/imports.py +++ b/gso/utils/types/imports.py @@ -4,12 +4,12 @@ from uuid import UUID from pydantic import BaseModel, root_validator, validator -from gso.products.product_blocks import PhyPortCapacity from gso.products.product_blocks.iptrunk import IptrunkType from gso.products.product_blocks.router import RouterRole, RouterVendor from gso.products.product_blocks.site import SiteTier from gso.services import subscriptions from gso.services.crm import CustomerNotFoundError, get_customer_by_name +from gso.utils.types.phy_port import PhyPortCapacity class ImportResponseModel(BaseModel): diff --git a/gso/utils/types/phy_port.py b/gso/utils/types/phy_port.py index 50592c9aa401467c81935ed60b746dd688e38a49..0d55eecec1116ec25e7a5c5ef842ed7a0f62c286 100644 --- a/gso/utils/types/phy_port.py +++ b/gso/utils/types/phy_port.py @@ -10,4 +10,4 @@ class PhyPortCapacity(strEnum): ONE_GIGABIT_PER_SECOND = "1G" TEN_GIGABIT_PER_SECOND = "10G" HUNDRED_GIGABIT_PER_SECOND = "100G" - FOUR_HUNDRED_GIGABIT_PER_SECOND = "400G" \ No newline at end of file + FOUR_HUNDRED_GIGABIT_PER_SECOND = "400G" diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index b08da1292fc6f34459a8af0419cc14d21c251eb6..a8331d06593b59a127b5799c0d30d948195807cf 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -8,7 +8,6 @@ from orchestrator.workflows.utils import wrap_create_initial_input_form from pydantic import validator from pynetbox.models.dcim import Interfaces -from gso.products.product_blocks import PhyPortCapacity from gso.products.product_blocks.iptrunk import IptrunkType from gso.products.product_blocks.router import RouterVendor from gso.products.product_types.iptrunk import IptrunkInactive, IptrunkProvisioning @@ -167,7 +166,7 @@ def initialize_subscription( geant_s_sid: str, iptrunk_type: IptrunkType, iptrunk_description: str, - iptrunk_speed: str, + iptrunk_speed: PhyPortCapacity, iptrunk_minimum_links: int, iptrunk_sideA_node_id: str, iptrunk_sideA_ae_iface: str, diff --git a/gso/workflows/iptrunk/modify_trunk_interface.py b/gso/workflows/iptrunk/modify_trunk_interface.py index 87e3b8f52108b4dca6fd6f4aaba81127f6a3a2e4..0dcdbe96ea901c676552c30a9f17b8d5aaf7b329 100644 --- a/gso/workflows/iptrunk/modify_trunk_interface.py +++ b/gso/workflows/iptrunk/modify_trunk_interface.py @@ -8,11 +8,11 @@ from orchestrator.workflow import StepList, done, init, step, workflow from orchestrator.workflows.steps import resync, store_process_subscription, unsync from orchestrator.workflows.utils import wrap_modify_initial_input_form -from gso.products.product_blocks import PhyPortCapacity from gso.products.product_blocks.iptrunk import IptrunkType from gso.products.product_types.iptrunk import Iptrunk from gso.services import provisioning_proxy from gso.services.provisioning_proxy import pp_interaction +from gso.utils.types.phy_port import PhyPortCapacity def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: @@ -23,7 +23,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: geant_s_sid: str = subscription.iptrunk.geant_s_sid iptrunk_description: str = subscription.iptrunk.iptrunk_description iptrunk_type: IptrunkType = subscription.iptrunk.iptrunk_type - iptrunk_speed: PhyPortCapacity = subscription.iptrunk.iptrunk_speed # type: ignore[assignment] + iptrunk_speed: PhyPortCapacity = subscription.iptrunk.iptrunk_speed iptrunk_minimum_links: int = subscription.iptrunk.iptrunk_minimum_links iptrunk_isis_metric: int = ReadOnlyField(subscription.iptrunk.iptrunk_isis_metric) iptrunk_ipv4_network: ipaddress.IPv4Network = ReadOnlyField(subscription.iptrunk.iptrunk_ipv4_network) @@ -75,7 +75,7 @@ def modify_iptrunk_subscription( geant_s_sid: str, iptrunk_type: IptrunkType, iptrunk_description: str, - iptrunk_speed: str, + iptrunk_speed: PhyPortCapacity, iptrunk_minimum_links: int, iptrunk_sideA_ae_geant_a_sid: str, iptrunk_sideA_ae_members: list[str], diff --git a/gso/workflows/router/create_router.py b/gso/workflows/router/create_router.py index 72d7d5e982958cd19e5af0cf0d2af0d79be4142d..ca9b4868c9178edcf522ca2181b90db0ee9a8926 100644 --- a/gso/workflows/router/create_router.py +++ b/gso/workflows/router/create_router.py @@ -14,10 +14,10 @@ from pydantic import validator from gso.products.product_blocks.router import RouterRole, RouterVendor, generate_fqdn from gso.products.product_types.router import RouterInactive, RouterProvisioning from gso.products.product_types.site import Site -from utils.types.ip_port import PortNumber from gso.services import infoblox, provisioning_proxy, subscriptions from gso.services.netbox_client import NetboxClient from gso.services.provisioning_proxy import pp_interaction +from gso.utils.types.ip_port import PortNumber from gso.workflows.utils import customer_selector, iso_from_ipv4 diff --git a/gso/workflows/site/create_site.py b/gso/workflows/site/create_site.py index f5642b73f7d869ba4afa54dbf32ab123474de6a8..18aada8f52472b8e103bd9ab7bc88f01474ba979 100644 --- a/gso/workflows/site/create_site.py +++ b/gso/workflows/site/create_site.py @@ -12,8 +12,8 @@ from pydantic import validator from gso.products.product_blocks import site as site_pb from gso.products.product_types import site -from gso.workflows.utils import customer_selector from gso.utils.types.snmp import LatitudeCoordinate, LongitudeCoordinate +from gso.workflows.utils import customer_selector def initial_input_form_generator(product_name: str) -> FormGenerator: # noqa: C901 diff --git a/gso/workflows/tasks/import_iptrunk.py b/gso/workflows/tasks/import_iptrunk.py index fc03382e80dc0b0793ef29015e6b8193df8ff61d..f3769aacf23b91d6a06731fd237730b4ff784f6e 100644 --- a/gso/workflows/tasks/import_iptrunk.py +++ b/gso/workflows/tasks/import_iptrunk.py @@ -8,12 +8,12 @@ from orchestrator.types import FormGenerator, State, SubscriptionLifecycle from orchestrator.workflow import StepList, done, init, step from orchestrator.workflows.steps import resync, set_status, store_process_subscription -from gso.products.product_blocks import PhyPortCapacity +from gso.products import ProductType from gso.products.product_blocks.iptrunk import IptrunkType from gso.products.product_types.iptrunk import IptrunkInactive, IptrunkProvisioning -from gso.products import ProductType from gso.services import subscriptions from gso.services.crm import get_customer_by_name +from gso.utils.types.phy_port import PhyPortCapacity from gso.workflows.iptrunk.create_iptrunk import initialize_subscription diff --git a/gso/workflows/tasks/import_router.py b/gso/workflows/tasks/import_router.py index 1a9c065629abd4a79c94a801967babe249ae06eb..272f2750119d20a06e6d00abdf8d5fcc8d80cb98 100644 --- a/gso/workflows/tasks/import_router.py +++ b/gso/workflows/tasks/import_router.py @@ -8,15 +8,15 @@ from orchestrator.types import FormGenerator, State, SubscriptionLifecycle from orchestrator.workflow import StepList, done, init, step from orchestrator.workflows.steps import resync, set_status, store_process_subscription +from gso.products import ProductType from gso.products.product_blocks import router as router_pb from gso.products.product_blocks.router import RouterRole, RouterVendor from gso.products.product_types import router from gso.products.product_types.router import RouterInactive from gso.products.product_types.site import Site -from utils.types.ip_port import PortNumber -from gso.products import ProductType from gso.services import subscriptions from gso.services.crm import get_customer_by_name +from gso.utils.types.ip_port import PortNumber def _get_site_by_name(site_name: str) -> Site: diff --git a/gso/workflows/tasks/import_site.py b/gso/workflows/tasks/import_site.py index b9ea20ed44fb9156f5998c32bad13699491c8906..af96fca24e6e67d0ffac5013c593eed238a16706 100644 --- a/gso/workflows/tasks/import_site.py +++ b/gso/workflows/tasks/import_site.py @@ -6,9 +6,9 @@ from orchestrator.types import FormGenerator, State, SubscriptionLifecycle from orchestrator.workflow import StepList, done, init, step, workflow from orchestrator.workflows.steps import resync, set_status, store_process_subscription +from gso.products import ProductType from gso.products.product_blocks.site import SiteTier from gso.products.product_types.site import SiteInactive -from gso.products import ProductType from gso.services import subscriptions from gso.services.crm import get_customer_by_name from gso.workflows.site.create_site import initialize_subscription diff --git a/test/fixtures.py b/test/fixtures.py index 65ad4c0d671f9a18c848540da547dc845bd1d5b6..24864c5a96b9f4b26b2e2e648c63f12a26f1f1f4 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -5,12 +5,12 @@ from orchestrator.db import db from orchestrator.domain import SubscriptionModel from orchestrator.types import SubscriptionLifecycle, UUIDstr +from gso.products import ProductType from gso.products.product_blocks.router import RouterRole, RouterVendor from gso.products.product_blocks.site import SiteTier from gso.products.product_types.router import RouterInactive from gso.products.product_types.site import Site, SiteInactive from gso.services import subscriptions -from gso.products import ProductType CUSTOMER_ID: UUIDstr = "2f47f65a-0911-e511-80d0-005056956c1a" diff --git a/test/imports/test_imports.py b/test/imports/test_imports.py index c41497c026ad36d7391542542da103b04db49519..639ace3e961384908dfdb93facd00559e4ed6653 100644 --- a/test/imports/test_imports.py +++ b/test/imports/test_imports.py @@ -5,10 +5,10 @@ import pytest from orchestrator.db import SubscriptionTable from orchestrator.services import subscriptions -from gso.products.product_blocks import PhyPortCapacity from gso.products.product_blocks.iptrunk import IptrunkType from gso.products.product_blocks.router import RouterRole, RouterVendor from gso.products.product_blocks.site import SiteTier +from gso.utils.types.phy_port import PhyPortCapacity SITE_IMPORT_ENDPOINT = "/api/v1/imports/sites" ROUTER_IMPORT_ENDPOINT = "/api/v1/imports/routers" diff --git a/test/workflows/iptrunk/__init__.py b/test/workflows/iptrunk/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/test/workflows/iptrunks/iptrunks/test_create_iptrunks.py b/test/workflows/iptrunk/test_create_iptrunk.py similarity index 98% rename from test/workflows/iptrunks/iptrunks/test_create_iptrunks.py rename to test/workflows/iptrunk/test_create_iptrunk.py index b38253f109fde50a5994b3e24966ed18b3916283..886c26d5b0558a8fc1c872abc0dba18b069e961a 100644 --- a/test/workflows/iptrunks/iptrunks/test_create_iptrunks.py +++ b/test/workflows/iptrunk/test_create_iptrunk.py @@ -3,12 +3,11 @@ from unittest.mock import patch import pytest -from gso.products import Iptrunk -from gso.products.product_blocks import PhyPortCapacity +from gso.products import Iptrunk, ProductType from gso.products.product_blocks.iptrunk import IptrunkType -from gso.products import ProductType from gso.services.crm import get_customer_by_name from gso.services.subscriptions import get_product_id_by_name +from gso.utils.types.phy_port import PhyPortCapacity from gso.workflows.utils import customer_selector from test.workflows import ( assert_aborted, diff --git a/test/workflows/site/test_create_site.py b/test/workflows/site/test_create_site.py index 6023f05a0aca979d9dbf8d961a63695bbb7c894f..20486ec23bc169bede53bd6668de2b14c4761d28 100644 --- a/test/workflows/site/test_create_site.py +++ b/test/workflows/site/test_create_site.py @@ -1,8 +1,8 @@ import pytest +from gso.products import ProductType from gso.products.product_blocks.site import SiteTier from gso.products.product_types.site import Site -from gso.products import ProductType from gso.services.crm import get_customer_by_name from gso.services.subscriptions import get_product_id_by_name from test.workflows import assert_complete, extract_state, run_workflow