From 895ee6d749fc17ff3605436ace3ead4cdde03231 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Fri, 19 Apr 2024 15:26:53 +0200 Subject: [PATCH] Move all import workflows into separate product types --- docs/source/module/workflows/index.rst | 3 ++- .../iptrunk/create_imported_iptrunk.rst | 6 +++++ .../source/module/workflows/iptrunk/index.rst | 1 + .../create_imported_office_router.rst | 6 +++++ .../module/workflows/office_router/index.rst | 15 +++++++++++ .../router/create_imported_router.rst | 6 +++++ docs/source/module/workflows/router/index.rst | 1 + .../workflows/site/create_imported_site.rst | 6 +++++ docs/source/module/workflows/site/index.rst | 1 + .../create_imported_super_pop_switch.rst | 6 +++++ .../workflows/super_pop_switch/index.rst | 15 +++++++++++ .../module/workflows/tasks/import_iptrunk.rst | 6 ----- .../workflows/tasks/import_office_router.rst | 6 ----- .../module/workflows/tasks/import_router.rst | 6 ----- .../module/workflows/tasks/import_site.rst | 6 ----- .../tasks/import_super_pop_switch.rst | 6 ----- docs/source/module/workflows/tasks/index.rst | 19 -------------- gso/products/__init__.py | 25 +++++++++++++++---- gso/products/product_types/iptrunk.py | 12 +++++++++ gso/products/product_types/office_router.py | 12 +++++++++ gso/products/product_types/router.py | 12 +++++++++ gso/products/product_types/site.py | 12 +++++++++ .../product_types/super_pop_switch.py | 12 +++++++++ gso/translations/en-GB.json | 7 +++++- .../create_imported_iptrunk.py} | 14 +++++------ gso/workflows/office_router/__init__.py | 1 + .../create_imported_office_router.py} | 13 +++------- .../create_imported_router.py} | 19 ++++++-------- .../create_imported_site.py} | 13 ++++------ gso/workflows/super_pop_switch/__init__.py | 1 + 30 files changed, 175 insertions(+), 93 deletions(-) create mode 100644 docs/source/module/workflows/iptrunk/create_imported_iptrunk.rst create mode 100644 docs/source/module/workflows/office_router/create_imported_office_router.rst create mode 100644 docs/source/module/workflows/office_router/index.rst create mode 100644 docs/source/module/workflows/router/create_imported_router.rst create mode 100644 docs/source/module/workflows/site/create_imported_site.rst create mode 100644 docs/source/module/workflows/super_pop_switch/create_imported_super_pop_switch.rst create mode 100644 docs/source/module/workflows/super_pop_switch/index.rst delete mode 100644 docs/source/module/workflows/tasks/import_iptrunk.rst delete mode 100644 docs/source/module/workflows/tasks/import_office_router.rst delete mode 100644 docs/source/module/workflows/tasks/import_router.rst delete mode 100644 docs/source/module/workflows/tasks/import_site.rst delete mode 100644 docs/source/module/workflows/tasks/import_super_pop_switch.rst delete mode 100644 docs/source/module/workflows/tasks/index.rst rename gso/workflows/{tasks/import_iptrunk.py => iptrunk/create_imported_iptrunk.py} (93%) create mode 100644 gso/workflows/office_router/__init__.py rename gso/workflows/{tasks/import_office_router.py => office_router/create_imported_office_router.py} (88%) rename gso/workflows/{tasks/import_router.py => router/create_imported_router.py} (83%) rename gso/workflows/{tasks/import_site.py => site/create_imported_site.py} (89%) create mode 100644 gso/workflows/super_pop_switch/__init__.py diff --git a/docs/source/module/workflows/index.rst b/docs/source/module/workflows/index.rst index 97204c39..9ef57ae8 100644 --- a/docs/source/module/workflows/index.rst +++ b/docs/source/module/workflows/index.rst @@ -13,6 +13,7 @@ Subpackages :titlesonly: iptrunk/index + office_router/index router/index site/index - tasks/index + super_pop_switch/index diff --git a/docs/source/module/workflows/iptrunk/create_imported_iptrunk.rst b/docs/source/module/workflows/iptrunk/create_imported_iptrunk.rst new file mode 100644 index 00000000..c7a72a1a --- /dev/null +++ b/docs/source/module/workflows/iptrunk/create_imported_iptrunk.rst @@ -0,0 +1,6 @@ +``gso.workflows.iptrunk.create_imported_iptrunk`` +====================================== + +.. automodule:: gso.workflows.iptrunk.create_imported_iptrunk + :members: + :show-inheritance: diff --git a/docs/source/module/workflows/iptrunk/index.rst b/docs/source/module/workflows/iptrunk/index.rst index f046983f..e5135e2e 100644 --- a/docs/source/module/workflows/iptrunk/index.rst +++ b/docs/source/module/workflows/iptrunk/index.rst @@ -13,6 +13,7 @@ Submodules :titlesonly: activate_iptrunk + create_imported_iptrunk create_iptrunk migrate_iptrunk modify_isis_metric diff --git a/docs/source/module/workflows/office_router/create_imported_office_router.rst b/docs/source/module/workflows/office_router/create_imported_office_router.rst new file mode 100644 index 00000000..a3136a81 --- /dev/null +++ b/docs/source/module/workflows/office_router/create_imported_office_router.rst @@ -0,0 +1,6 @@ +``gso.workflows.office_router.create_imported_office_router`` +============================================================= + +.. automodule:: gso.workflows.office_router.create_imported_office_router + :members: + :show-inheritance: diff --git a/docs/source/module/workflows/office_router/index.rst b/docs/source/module/workflows/office_router/index.rst new file mode 100644 index 00000000..a3d8b3eb --- /dev/null +++ b/docs/source/module/workflows/office_router/index.rst @@ -0,0 +1,15 @@ +``gso.workflows.office_router`` +=============================== + +.. automodule:: gso.workflows.office_router + :members: + :show-inheritance: + +Submodules +---------- + +.. toctree:: + :maxdepth: 2 + :titlesonly: + + create_imported_office_router diff --git a/docs/source/module/workflows/router/create_imported_router.rst b/docs/source/module/workflows/router/create_imported_router.rst new file mode 100644 index 00000000..8124fd0d --- /dev/null +++ b/docs/source/module/workflows/router/create_imported_router.rst @@ -0,0 +1,6 @@ +``gso.workflows.router.create_imported_router`` +=============================================== + +.. automodule:: gso.workflows.router.create_imported_router + :members: + :show-inheritance: diff --git a/docs/source/module/workflows/router/index.rst b/docs/source/module/workflows/router/index.rst index e582a440..08fcc72b 100644 --- a/docs/source/module/workflows/router/index.rst +++ b/docs/source/module/workflows/router/index.rst @@ -13,6 +13,7 @@ Submodules :titlesonly: activate_router + create_imported_router create_router redeploy_base_config terminate_router diff --git a/docs/source/module/workflows/site/create_imported_site.rst b/docs/source/module/workflows/site/create_imported_site.rst new file mode 100644 index 00000000..52fab323 --- /dev/null +++ b/docs/source/module/workflows/site/create_imported_site.rst @@ -0,0 +1,6 @@ +``gso.workflows.site.create_imported_site`` +=========================================== + +.. automodule:: gso.workflows.site.create_imported_site + :members: + :show-inheritance: diff --git a/docs/source/module/workflows/site/index.rst b/docs/source/module/workflows/site/index.rst index c07dc9b9..b06ffd13 100644 --- a/docs/source/module/workflows/site/index.rst +++ b/docs/source/module/workflows/site/index.rst @@ -12,6 +12,7 @@ Submodules :maxdepth: 2 :titlesonly: + create_imported_site create_site modify_site terminate_site diff --git a/docs/source/module/workflows/super_pop_switch/create_imported_super_pop_switch.rst b/docs/source/module/workflows/super_pop_switch/create_imported_super_pop_switch.rst new file mode 100644 index 00000000..69922a13 --- /dev/null +++ b/docs/source/module/workflows/super_pop_switch/create_imported_super_pop_switch.rst @@ -0,0 +1,6 @@ +``gso.workflows.office_router.create_imported_super_pop_switch`` +================================================================ + +.. automodule:: gso.workflows.office_router.create_imported_super_pop_switch + :members: + :show-inheritance: diff --git a/docs/source/module/workflows/super_pop_switch/index.rst b/docs/source/module/workflows/super_pop_switch/index.rst new file mode 100644 index 00000000..e76428c7 --- /dev/null +++ b/docs/source/module/workflows/super_pop_switch/index.rst @@ -0,0 +1,15 @@ +``gso.workflows.super_pop_switch`` +================================== + +.. automodule:: gso.workflows.super_pop_switch + :members: + :show-inheritance: + +Submodules +---------- + +.. toctree:: + :maxdepth: 2 + :titlesonly: + + create_imported_super_pop_switch diff --git a/docs/source/module/workflows/tasks/import_iptrunk.rst b/docs/source/module/workflows/tasks/import_iptrunk.rst deleted file mode 100644 index 24a4be08..00000000 --- a/docs/source/module/workflows/tasks/import_iptrunk.rst +++ /dev/null @@ -1,6 +0,0 @@ -``gso.workflows.tasks.import_iptrunk`` -====================================== - -.. automodule:: gso.workflows.tasks.import_iptrunk - :members: - :show-inheritance: diff --git a/docs/source/module/workflows/tasks/import_office_router.rst b/docs/source/module/workflows/tasks/import_office_router.rst deleted file mode 100644 index a6b37df5..00000000 --- a/docs/source/module/workflows/tasks/import_office_router.rst +++ /dev/null @@ -1,6 +0,0 @@ -``gso.workflows.tasks.import_office_router`` -============================================ - -.. automodule:: gso.workflows.tasks.import_office_router - :members: - :show-inheritance: diff --git a/docs/source/module/workflows/tasks/import_router.rst b/docs/source/module/workflows/tasks/import_router.rst deleted file mode 100644 index 65a6e607..00000000 --- a/docs/source/module/workflows/tasks/import_router.rst +++ /dev/null @@ -1,6 +0,0 @@ -``gso.workflows.tasks.import_router`` -===================================== - -.. automodule:: gso.workflows.tasks.import_router - :members: - :show-inheritance: diff --git a/docs/source/module/workflows/tasks/import_site.rst b/docs/source/module/workflows/tasks/import_site.rst deleted file mode 100644 index eb9280df..00000000 --- a/docs/source/module/workflows/tasks/import_site.rst +++ /dev/null @@ -1,6 +0,0 @@ -``gso.workflows.tasks.import_site`` -=================================== - -.. automodule:: gso.workflows.tasks.import_site - :members: - :show-inheritance: diff --git a/docs/source/module/workflows/tasks/import_super_pop_switch.rst b/docs/source/module/workflows/tasks/import_super_pop_switch.rst deleted file mode 100644 index 575db1e0..00000000 --- a/docs/source/module/workflows/tasks/import_super_pop_switch.rst +++ /dev/null @@ -1,6 +0,0 @@ -``gso.workflows.tasks.import_super_pop_switch`` -=============================================== - -.. automodule:: gso.workflows.tasks.import_super_pop_switch - :members: - :show-inheritance: diff --git a/docs/source/module/workflows/tasks/index.rst b/docs/source/module/workflows/tasks/index.rst deleted file mode 100644 index 1931adef..00000000 --- a/docs/source/module/workflows/tasks/index.rst +++ /dev/null @@ -1,19 +0,0 @@ -``gso.workflows.tasks`` -======================= - -.. automodule:: gso.workflows.tasks - :members: - :show-inheritance: - -Submodules ----------- - -.. toctree:: - :maxdepth: 2 - :titlesonly: - - import_super_pop_switch - import_office_router - import_iptrunk - import_router - import_site diff --git a/gso/products/__init__.py b/gso/products/__init__.py index b50bb6f0..e81b36b8 100644 --- a/gso/products/__init__.py +++ b/gso/products/__init__.py @@ -8,14 +8,14 @@ from orchestrator.domain import SUBSCRIPTION_MODEL_REGISTRY from pydantic_forms.types import strEnum -from gso.products.product_types.iptrunk import Iptrunk +from gso.products.product_types.iptrunk import ImportedIptrunk, Iptrunk from gso.products.product_types.lan_switch_interconnect import LanSwitchInterconnect -from gso.products.product_types.office_router import OfficeRouter +from gso.products.product_types.office_router import ImportedOfficeRouter, OfficeRouter from gso.products.product_types.opengear import Opengear from gso.products.product_types.pop_vlan import PopVlan -from gso.products.product_types.router import Router -from gso.products.product_types.site import Site -from gso.products.product_types.super_pop_switch import SuperPopSwitch +from gso.products.product_types.router import ImportedRouter, Router +from gso.products.product_types.site import ImportedSite, Site +from gso.products.product_types.super_pop_switch import ImportedSuperPopSwitch, SuperPopSwitch from gso.products.product_types.switch import Switch @@ -30,6 +30,11 @@ class ProductName(strEnum): SWITCH = "Switch" LAN_SWITCH_INTERCONNECT = "LAN Switch Interconnect" POP_VLAN = "Pop VLAN" + IMPORTED_IP_TRUNK = "Imported IP trunk" + IMPORTED_ROUTER = "Imported router" + IMPORTED_SITE = "Imported site" + IMPORTED_SUPER_POP_SWITCH = "Imported super PoP switch" + IMPORTED_OFFICE_ROUTER = "Imported office router" OPENGEAR = "Opengear" @@ -44,6 +49,11 @@ class ProductType(strEnum): SWITCH = Switch.__name__ LAN_SWITCH_INTERCONNECT = LanSwitchInterconnect.__name__ POP_VLAN = PopVlan.__name__ + IMPORTED_IP_TRUNK = ImportedIptrunk.__name__ + IMPORTED_ROUTER = ImportedRouter.__name__ + IMPORTED_SITE = ImportedSite.__name__ + IMPORTED_SUPER_POP_SWITCH = ImportedSuperPopSwitch.__name__ + IMPORTED_OFFICE_ROUTER = ImportedOfficeRouter.__name__ OPENGEAR = Opengear.__name__ @@ -57,6 +67,11 @@ SUBSCRIPTION_MODEL_REGISTRY.update( ProductName.SWITCH.value: Switch, ProductName.LAN_SWITCH_INTERCONNECT.value: LanSwitchInterconnect, ProductName.POP_VLAN.value: PopVlan, + ProductName.IMPORTED_IP_TRUNK.value: ImportedIptrunk, + ProductName.IMPORTED_ROUTER.value: ImportedRouter, + ProductName.IMPORTED_SITE.value: ImportedSite, + ProductName.IMPORTED_SUPER_POP_SWITCH.value: ImportedSuperPopSwitch, + ProductName.IMPORTED_OFFICE_ROUTER.value: ImportedOfficeRouter, ProductName.OPENGEAR.value: Opengear, }, ) diff --git a/gso/products/product_types/iptrunk.py b/gso/products/product_types/iptrunk.py index 70612d49..82c912bf 100644 --- a/gso/products/product_types/iptrunk.py +++ b/gso/products/product_types/iptrunk.py @@ -26,3 +26,15 @@ class Iptrunk(IptrunkProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): """An IP trunk that is active.""" iptrunk: IptrunkBlock + + +class ImportedIptrunkInactive(SubscriptionModel, is_base=True): + """An IP trunk that is inactive.""" + + iptrunk: IptrunkBlockInactive + + +class ImportedIptrunk(ImportedIptrunkInactive, lifecycle=[SubscriptionLifecycle.ACTIVE]): + """An IP trunk that is active.""" + + iptrunk: IptrunkBlock diff --git a/gso/products/product_types/office_router.py b/gso/products/product_types/office_router.py index 6fff33e0..04c47dfb 100644 --- a/gso/products/product_types/office_router.py +++ b/gso/products/product_types/office_router.py @@ -26,3 +26,15 @@ class OfficeRouter(OfficeRouterProvisioning, lifecycle=[SubscriptionLifecycle.AC """An office router that is currently active.""" office_router: OfficeRouterBlock + + +class ImportedOfficeRouterInactive(SubscriptionModel, is_base=True): + """An imported, inactive office router.""" + + office_router: OfficeRouterBlockInactive + + +class ImportedOfficeRouter(ImportedOfficeRouterInactive, lifecycle=[SubscriptionLifecycle.ACTIVE]): + """An imported office router that is currently active.""" + + office_router: OfficeRouterBlock diff --git a/gso/products/product_types/router.py b/gso/products/product_types/router.py index d6a59c12..e24df3e7 100644 --- a/gso/products/product_types/router.py +++ b/gso/products/product_types/router.py @@ -26,3 +26,15 @@ class Router(RouterProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): """A router that is currently active.""" router: RouterBlock + + +class ImportedRouterInactive(SubscriptionModel, is_base=True): + """An imported, inactive router.""" + + router: RouterBlockInactive + + +class ImportedRouter(ImportedRouterInactive, lifecycle=[SubscriptionLifecycle.ACTIVE]): + """An imported router that is currently active.""" + + router: RouterBlock diff --git a/gso/products/product_types/site.py b/gso/products/product_types/site.py index ec09962e..0fb16a57 100644 --- a/gso/products/product_types/site.py +++ b/gso/products/product_types/site.py @@ -26,3 +26,15 @@ class Site(SiteProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]): """A site that is currently active.""" site: SiteBlock + + +class ImportedSiteInactive(SubscriptionModel, is_base=True): + """An imported site that is inactive.""" + + site: SiteBlockInactive + + +class ImportedSite(ImportedSiteInactive, lifecycle=[SubscriptionLifecycle.ACTIVE]): + """An imported site that is currently active.""" + + site: SiteBlock diff --git a/gso/products/product_types/super_pop_switch.py b/gso/products/product_types/super_pop_switch.py index e12b1a3d..3c80e364 100644 --- a/gso/products/product_types/super_pop_switch.py +++ b/gso/products/product_types/super_pop_switch.py @@ -26,3 +26,15 @@ class SuperPopSwitch(SuperPopSwitchProvisioning, lifecycle=[SubscriptionLifecycl """A Super PoP switch that is currently active.""" super_pop_switch: SuperPopSwitchBlock + + +class ImportedSuperPopSwitchInactive(SubscriptionModel, is_base=True): + """An imported, inactive Super PoP switch.""" + + super_pop_switch: SuperPopSwitchBlockInactive + + +class ImportedSuperPopSwitch(ImportedSuperPopSwitchInactive, lifecycle=[SubscriptionLifecycle.ACTIVE]): + """An imported Super PoP switch that is currently active.""" + + super_pop_switch: SuperPopSwitchBlock diff --git a/gso/translations/en-GB.json b/gso/translations/en-GB.json index 63b31e76..2ef5f1c0 100644 --- a/gso/translations/en-GB.json +++ b/gso/translations/en-GB.json @@ -45,6 +45,11 @@ "modify_site": "Modify site", "modify_trunk_interface": "Modify IP Trunk interface", "redeploy_base_config": "Redeploy base config", - "update_ibgp_mesh": "Update iBGP mesh" + "update_ibgp_mesh": "Update iBGP mesh", + "create_imported_site": "NOT FOR HUMANS -- Import existing site", + "create_imported_router": "NOT FOR HUMANS -- Import existing router", + "create_imported_iptrunk": "NOT FOR HUMANS -- Import existing IP trunk", + "create_imported_super_pop_switch": "NOT FOR HUMANS -- Import existing super PoP switch", + "create_imported_office_router": "NOT FOR HUMANS -- Import existing office router" } } diff --git a/gso/workflows/tasks/import_iptrunk.py b/gso/workflows/iptrunk/create_imported_iptrunk.py similarity index 93% rename from gso/workflows/tasks/import_iptrunk.py rename to gso/workflows/iptrunk/create_imported_iptrunk.py index 9c6687b3..7e28fe64 100644 --- a/gso/workflows/tasks/import_iptrunk.py +++ b/gso/workflows/iptrunk/create_imported_iptrunk.py @@ -13,7 +13,7 @@ from orchestrator.workflows.steps import resync, set_status, store_process_subsc from gso.products import ProductName from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlockInactive, IptrunkType, PhysicalPortCapacity -from gso.products.product_types.iptrunk import IptrunkInactive, IptrunkProvisioning +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 @@ -68,8 +68,8 @@ def initial_input_form_generator() -> FormGenerator: def create_subscription(partner: str) -> State: """Create a new subscription in the service database.""" partner_id = get_partner_by_name(partner)["partner_id"] - product_id = subscriptions.get_product_id_by_name(ProductName.IP_TRUNK) - subscription = IptrunkInactive.from_product_id(product_id, partner_id) + product_id = subscriptions.get_product_id_by_name(ProductName.IMPORTED_IP_TRUNK) + subscription = ImportedIptrunkInactive.from_product_id(product_id, partner_id) return { "subscription": subscription, @@ -79,7 +79,7 @@ def create_subscription(partner: str) -> State: @step("Initialize subscription") def initialize_subscription( - subscription: IptrunkInactive, + subscription: ImportedIptrunkInactive, geant_s_sid: str | None, iptrunk_type: IptrunkType, iptrunk_description: str, @@ -120,14 +120,12 @@ def initialize_subscription( ) subscription.description = f"IP trunk, geant_s_sid:{geant_s_sid}" - subscription = IptrunkProvisioning.from_other_lifecycle(subscription, SubscriptionLifecycle.PROVISIONING) - return {"subscription": subscription} @step("Update IPAM Stub for Subscription") def update_ipam_stub_for_subscription( - subscription: IptrunkProvisioning, + subscription: ImportedIptrunkInactive, iptrunk_ipv4_network: ipaddress.IPv4Network, iptrunk_ipv6_network: ipaddress.IPv6Network, ) -> State: @@ -143,7 +141,7 @@ def update_ipam_stub_for_subscription( initial_input_form=initial_input_form_generator, target=Target.CREATE, ) -def import_iptrunk() -> StepList: +def create_imported_iptrunk() -> StepList: """Import an IP trunk without provisioning it.""" return ( init diff --git a/gso/workflows/office_router/__init__.py b/gso/workflows/office_router/__init__.py new file mode 100644 index 00000000..1a947a50 --- /dev/null +++ b/gso/workflows/office_router/__init__.py @@ -0,0 +1 @@ +"""Workflows for Office router products.""" diff --git a/gso/workflows/tasks/import_office_router.py b/gso/workflows/office_router/create_imported_office_router.py similarity index 88% rename from gso/workflows/tasks/import_office_router.py rename to gso/workflows/office_router/create_imported_office_router.py index 9168cdae..82c52fc4 100644 --- a/gso/workflows/tasks/import_office_router.py +++ b/gso/workflows/office_router/create_imported_office_router.py @@ -10,8 +10,7 @@ from orchestrator.workflow import StepList, done, init, step from orchestrator.workflows.steps import resync, set_status, store_process_subscription from gso.products import ProductName -from gso.products.product_types import office_router -from gso.products.product_types.office_router import OfficeRouterInactive +from gso.products.product_types.office_router import ImportedOfficeRouterInactive from gso.services import subscriptions from gso.services.partners import get_partner_by_name from gso.services.subscriptions import get_site_by_name @@ -22,8 +21,8 @@ from gso.utils.shared_enums import PortNumber, Vendor def create_subscription(partner: str) -> State: """Create a new subscription object.""" partner_id = get_partner_by_name(partner)["partner_id"] - product_id = subscriptions.get_product_id_by_name(ProductName.OFFICE_ROUTER) - subscription = OfficeRouterInactive.from_product_id(product_id, partner_id) + product_id = subscriptions.get_product_id_by_name(ProductName.IMPORTED_OFFICE_ROUTER) + subscription = ImportedOfficeRouterInactive.from_product_id(product_id, partner_id) return { "subscription": subscription, @@ -52,7 +51,7 @@ def initial_input_form_generator() -> FormGenerator: @step("Initialize subscription") def initialize_subscription( - subscription: OfficeRouterInactive, + subscription: ImportedOfficeRouterInactive, office_router_fqdn: str, office_router_ts_port: PortNumber, office_router_site: str, @@ -69,10 +68,6 @@ def initialize_subscription( subscription.office_router.office_router_lo_ipv6_address = office_router_lo_ipv6_address subscription.office_router.vendor = Vendor.JUNIPER - subscription = office_router.OfficeRouterProvisioning.from_other_lifecycle( - subscription, SubscriptionLifecycle.PROVISIONING - ) - return {"subscription": subscription} diff --git a/gso/workflows/tasks/import_router.py b/gso/workflows/router/create_imported_router.py similarity index 83% rename from gso/workflows/tasks/import_router.py rename to gso/workflows/router/create_imported_router.py index c71ce26e..a71a7a18 100644 --- a/gso/workflows/tasks/import_router.py +++ b/gso/workflows/router/create_imported_router.py @@ -10,13 +10,10 @@ from orchestrator.workflow import StepList, done, init, step from orchestrator.workflows.steps import resync, set_status, store_process_subscription from gso.products import ProductName -from gso.products.product_blocks import router as router_pb from gso.products.product_blocks.router import RouterRole -from gso.products.product_types import router -from gso.products.product_types.router import RouterInactive -from gso.services import subscriptions +from gso.products.product_types.router import ImportedRouterInactive from gso.services.partners import get_partner_by_name -from gso.services.subscriptions import get_site_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 PortNumber, Vendor @@ -25,8 +22,8 @@ from gso.utils.shared_enums import PortNumber, Vendor def create_subscription(partner: str) -> State: """Create a new subscription object.""" partner_id = get_partner_by_name(partner)["partner_id"] - product_id = subscriptions.get_product_id_by_name(ProductName.ROUTER) - subscription = RouterInactive.from_product_id(product_id, partner_id) + product_id = get_product_id_by_name(ProductName.IMPORTED_ROUTER) + subscription = ImportedRouterInactive.from_product_id(product_id, partner_id) return { "subscription": subscription, @@ -58,11 +55,11 @@ def initial_input_form_generator() -> FormGenerator: @step("Initialize subscription") def initialize_subscription( - subscription: RouterInactive, + subscription: ImportedRouterInactive, hostname: str, ts_port: PortNumber, router_site: str, - router_role: router_pb.RouterRole, + router_role: RouterRole, router_vendor: Vendor, router_lo_ipv4_address: ipaddress.IPv4Address | None = None, router_lo_ipv6_address: ipaddress.IPv6Address | None = None, @@ -82,8 +79,6 @@ def initialize_subscription( subscription.router.router_lo_iso_address = router_lo_iso_address subscription.router.vendor = router_vendor - subscription = router.RouterProvisioning.from_other_lifecycle(subscription, SubscriptionLifecycle.PROVISIONING) - return {"subscription": subscription} @@ -92,7 +87,7 @@ def initialize_subscription( initial_input_form=initial_input_form_generator, target=Target.CREATE, ) -def import_router() -> StepList: +def create_imported_router() -> StepList: """Import a router without provisioning it.""" return ( init diff --git a/gso/workflows/tasks/import_site.py b/gso/workflows/site/create_imported_site.py similarity index 89% rename from gso/workflows/tasks/import_site.py rename to gso/workflows/site/create_imported_site.py index ff49808a..ef3977f4 100644 --- a/gso/workflows/tasks/import_site.py +++ b/gso/workflows/site/create_imported_site.py @@ -10,7 +10,7 @@ from orchestrator.workflows.steps import resync, set_status, store_process_subsc from gso.products import ProductName from gso.products.product_blocks.site import SiteTier -from gso.products.product_types.site import SiteInactive +from gso.products.product_types.site import ImportedSiteInactive from gso.services import subscriptions from gso.services.partners import get_partner_by_name from gso.workflows.site.create_site import initialize_subscription @@ -18,13 +18,10 @@ from gso.workflows.site.create_site import initialize_subscription @step("Create subscription") def create_subscription(partner: str) -> State: - """Create a new subscription object in the service database. - - FIXME: all attributes passed by the input form appear to be unused - """ + """Create a new subscription object in the service database.""" partner_id = get_partner_by_name(partner)["partner_id"] - product_id: UUID = subscriptions.get_product_id_by_name(ProductName.SITE) - subscription = SiteInactive.from_product_id(product_id, partner_id) + product_id: UUID = subscriptions.get_product_id_by_name(ProductName.IMPORTED_SITE) + subscription = ImportedSiteInactive.from_product_id(product_id, partner_id) return { "subscription": subscription, @@ -60,7 +57,7 @@ def generate_initial_input_form() -> FormGenerator: target=Target.CREATE, initial_input_form=generate_initial_input_form, ) -def import_site() -> StepList: +def create_imported_site() -> StepList: """Workflow to import a site without provisioning it.""" return ( init diff --git a/gso/workflows/super_pop_switch/__init__.py b/gso/workflows/super_pop_switch/__init__.py new file mode 100644 index 00000000..caed99fa --- /dev/null +++ b/gso/workflows/super_pop_switch/__init__.py @@ -0,0 +1 @@ +"""Workflows for super PoP switches.""" -- GitLab