Skip to content
Snippets Groups Projects
Verified Commit 6a847ed2 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Add import workflows for other products as well

also condense migrations into a single one
parent cd413ee4
Branches
Tags
1 merge request!201Add imported products
"""Add site modification import workflow. """Add product import workflows.
Revision ID: 8ebfc8a34c2e Revision ID: c12ec1d9bd92
Revises: ab8d805d27b3 Revises: ab8d805d27b3
Create Date: 2024-04-23 11:32:39.502729 Create Date: 2024-04-23 12:57:51.227269
""" """
import sqlalchemy as sa import sqlalchemy as sa
from alembic import op from alembic import op
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = '8ebfc8a34c2e' revision = 'c12ec1d9bd92'
down_revision = 'ab8d805d27b3' down_revision = 'ab8d805d27b3'
branch_labels = None branch_labels = None
depends_on = None depends_on = None
...@@ -23,6 +23,30 @@ new_workflows = [ ...@@ -23,6 +23,30 @@ new_workflows = [
"target": "MODIFY", "target": "MODIFY",
"description": "Import Site", "description": "Import Site",
"product_type": "ImportedSite" "product_type": "ImportedSite"
},
{
"name": "import_office_router",
"target": "MODIFY",
"description": "Import OfficeRouter",
"product_type": "ImportedOfficeRouter"
},
{
"name": "import_super_pop_switch",
"target": "MODIFY",
"description": "Import SuperPopSwitch",
"product_type": "ImportedSuperPopSwitch"
},
{
"name": "import_router",
"target": "MODIFY",
"description": "Import Router",
"product_type": "ImportedRouter"
},
{
"name": "import_iptrunk",
"target": "MODIFY",
"description": "Import Iptrunk",
"product_type": "ImportedIptrunk"
} }
] ]
......
...@@ -51,6 +51,10 @@ ...@@ -51,6 +51,10 @@
"create_imported_iptrunk": "NOT FOR HUMANS -- Import existing IP trunk", "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_super_pop_switch": "NOT FOR HUMANS -- Import existing super PoP switch",
"create_imported_office_router": "NOT FOR HUMANS -- Import existing office router", "create_imported_office_router": "NOT FOR HUMANS -- Import existing office router",
"import_site": "Finalize import into a Site product" "import_site": "NOT FOR HUMANS -- Finalize import into a Site product",
"import_router": "NOT FOR HUMANS -- Finalize import into a Router product",
"import_iptrunk": "NOT FOR HUMANS -- Finalize import into an IP trunk product",
"import_office_router": "NOT FOR HUMANS -- Finalize import into an Office router product",
"import_super_pop_switch": "NOT FOR HUMANS -- Finalize import into a Super PoP switch"
} }
} }
...@@ -24,6 +24,7 @@ WF_USABLE_MAP.update( ...@@ -24,6 +24,7 @@ WF_USABLE_MAP.update(
} }
) )
# IP trunk workflows
LazyWorkflowInstance("gso.workflows.iptrunk.activate_iptrunk", "activate_iptrunk") LazyWorkflowInstance("gso.workflows.iptrunk.activate_iptrunk", "activate_iptrunk")
LazyWorkflowInstance("gso.workflows.iptrunk.create_iptrunk", "create_iptrunk") LazyWorkflowInstance("gso.workflows.iptrunk.create_iptrunk", "create_iptrunk")
LazyWorkflowInstance("gso.workflows.iptrunk.deploy_twamp", "deploy_twamp") LazyWorkflowInstance("gso.workflows.iptrunk.deploy_twamp", "deploy_twamp")
...@@ -31,20 +32,32 @@ LazyWorkflowInstance("gso.workflows.iptrunk.modify_isis_metric", "modify_isis_me ...@@ -31,20 +32,32 @@ LazyWorkflowInstance("gso.workflows.iptrunk.modify_isis_metric", "modify_isis_me
LazyWorkflowInstance("gso.workflows.iptrunk.modify_trunk_interface", "modify_trunk_interface") LazyWorkflowInstance("gso.workflows.iptrunk.modify_trunk_interface", "modify_trunk_interface")
LazyWorkflowInstance("gso.workflows.iptrunk.migrate_iptrunk", "migrate_iptrunk") LazyWorkflowInstance("gso.workflows.iptrunk.migrate_iptrunk", "migrate_iptrunk")
LazyWorkflowInstance("gso.workflows.iptrunk.terminate_iptrunk", "terminate_iptrunk") LazyWorkflowInstance("gso.workflows.iptrunk.terminate_iptrunk", "terminate_iptrunk")
LazyWorkflowInstance("gso.workflows.iptrunk.create_imported_iptrunk", "create_imported_iptrunk")
LazyWorkflowInstance("gso.workflows.iptrunk.import_iptrunk", "import_iptrunk")
# Router workflows
LazyWorkflowInstance("gso.workflows.router.activate_router", "activate_router") LazyWorkflowInstance("gso.workflows.router.activate_router", "activate_router")
LazyWorkflowInstance("gso.workflows.router.create_router", "create_router") LazyWorkflowInstance("gso.workflows.router.create_router", "create_router")
LazyWorkflowInstance("gso.workflows.router.redeploy_base_config", "redeploy_base_config") LazyWorkflowInstance("gso.workflows.router.redeploy_base_config", "redeploy_base_config")
LazyWorkflowInstance("gso.workflows.router.terminate_router", "terminate_router") LazyWorkflowInstance("gso.workflows.router.terminate_router", "terminate_router")
LazyWorkflowInstance("gso.workflows.router.update_ibgp_mesh", "update_ibgp_mesh") LazyWorkflowInstance("gso.workflows.router.update_ibgp_mesh", "update_ibgp_mesh")
LazyWorkflowInstance("gso.workflows.router.modify_connection_strategy", "modify_connection_strategy") LazyWorkflowInstance("gso.workflows.router.modify_connection_strategy", "modify_connection_strategy")
LazyWorkflowInstance("gso.workflows.router.import_router", "import_router")
LazyWorkflowInstance("gso.workflows.router.create_imported_router", "create_imported_router")
# Site workflows
LazyWorkflowInstance("gso.workflows.site.create_site", "create_site") LazyWorkflowInstance("gso.workflows.site.create_site", "create_site")
LazyWorkflowInstance("gso.workflows.site.modify_site", "modify_site") LazyWorkflowInstance("gso.workflows.site.modify_site", "modify_site")
LazyWorkflowInstance("gso.workflows.site.terminate_site", "terminate_site") LazyWorkflowInstance("gso.workflows.site.terminate_site", "terminate_site")
LazyWorkflowInstance("gso.workflows.site.create_imported_site", "create_imported_site") LazyWorkflowInstance("gso.workflows.site.create_imported_site", "create_imported_site")
LazyWorkflowInstance("gso.workflows.site.import_site", "import_site") LazyWorkflowInstance("gso.workflows.site.import_site", "import_site")
LazyWorkflowInstance("gso.workflows.router.create_imported_router", "create_imported_router")
LazyWorkflowInstance("gso.workflows.iptrunk.create_imported_iptrunk", "create_imported_iptrunk") # Super PoP switch workflows
LazyWorkflowInstance("gso.workflows.super_pop_switch.import_super_pop_switch", "import_super_pop_switch")
LazyWorkflowInstance( LazyWorkflowInstance(
"gso.workflows.super_pop_switch.create_imported_super_pop_switch", "create_imported_super_pop_switch" "gso.workflows.super_pop_switch.create_imported_super_pop_switch", "create_imported_super_pop_switch"
) )
# Office router workflows
LazyWorkflowInstance("gso.workflows.office_router.import_office_router", "import_office_router")
LazyWorkflowInstance("gso.workflows.office_router.create_imported_office_router", "create_imported_office_router") LazyWorkflowInstance("gso.workflows.office_router.create_imported_office_router", "create_imported_office_router")
"""A modification workflow for migrating an ImportedIptrunk to an Iptrunk subscription."""
from orchestrator.targets import Target
from orchestrator.types import State, UUIDstr
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 import ProductName
from gso.products.product_types.iptrunk import ImportedIptrunk, Iptrunk
from gso.services.subscriptions import get_product_id_by_name
@step("Create new IP trunk subscription")
def import_iptrunk_subscription(subscription_id: UUIDstr) -> State:
"""Take an ImportedIptrunk subscription, and turn it into an Iptrunk subscription."""
old_iptrunk = ImportedIptrunk.from_subscription(subscription_id)
new_subscription_id = get_product_id_by_name(ProductName.SITE)
new_subscription = Iptrunk.from_other_product(old_iptrunk, new_subscription_id)
return {"subscription": new_subscription}
@workflow("Import Iptrunk", target=Target.MODIFY, initial_input_form=wrap_modify_initial_input_form(None))
def import_iptrunk() -> StepList:
"""Modify an ImportedIptrunk subscription into an Iptrunk subscription to complete the import."""
return init >> store_process_subscription(Target.MODIFY) >> unsync >> import_iptrunk_subscription >> resync >> done
"""A modification workflow for migrating an ImportedOfficeRouter to an OfficeRouter subscription."""
from orchestrator.targets import Target
from orchestrator.types import State, UUIDstr
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 import ProductName
from gso.products.product_types.office_router import ImportedOfficeRouter, OfficeRouter
from gso.services.subscriptions import get_product_id_by_name
@step("Create new office_router subscription")
def import_office_router_subscription(subscription_id: UUIDstr) -> State:
"""Take an ImportedOfficeRouter subscription, and turn it into an OfficeRouter subscription."""
old_office_router = ImportedOfficeRouter.from_subscription(subscription_id)
new_subscription_id = get_product_id_by_name(ProductName.SITE)
new_subscription = OfficeRouter.from_other_product(old_office_router, new_subscription_id)
return {"subscription": new_subscription}
@workflow("Import OfficeRouter", target=Target.MODIFY, initial_input_form=wrap_modify_initial_input_form(None))
def import_office_router() -> StepList:
"""Modify an ImportedOfficeRouter subscription into an OfficeRouter subscription to complete the import."""
return (
init
>> store_process_subscription(Target.MODIFY)
>> unsync
>> import_office_router_subscription
>> resync
>> done
)
"""A modification workflow for setting a new :term:`ISIS` metric for an IP trunk."""
from orchestrator.targets import Target
from orchestrator.types import State, UUIDstr
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 import ProductName
from gso.products.product_types.router import ImportedRouter, Router
from gso.services.subscriptions import get_product_id_by_name
@step("Create new router subscription")
def import_router_subscription(subscription_id: UUIDstr) -> State:
"""Take an ImportedRouter subscription, and turn it into a Router subscription."""
old_router = ImportedRouter.from_subscription(subscription_id)
new_subscription_id = get_product_id_by_name(ProductName.SITE)
new_subscription = Router.from_other_product(old_router, new_subscription_id)
return {"subscription": new_subscription}
@workflow("Import Router", target=Target.MODIFY, initial_input_form=wrap_modify_initial_input_form(None))
def import_router() -> StepList:
"""Modify an ImportedRouter subscription into a Router subscription to complete the import."""
return init >> store_process_subscription(Target.MODIFY) >> unsync >> import_router_subscription >> resync >> done
"""A modification workflow for setting a new :term:`ISIS` metric for an IP trunk.""" """A modification workflow for migrating an ImportedSite to a Site subscription."""
from orchestrator.targets import Target from orchestrator.targets import Target
from orchestrator.types import State, UUIDstr from orchestrator.types import State, UUIDstr
......
"""A modification workflow for migrating an ImportedSuperPopSwitch to a SuperPopSwitch subscription."""
from orchestrator.targets import Target
from orchestrator.types import State, UUIDstr
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 import ProductName
from gso.products.product_types.super_pop_switch import ImportedSuperPopSwitch, SuperPopSwitch
from gso.services.subscriptions import get_product_id_by_name
@step("Create new super_pop_switch subscription")
def import_super_pop_switch_subscription(subscription_id: UUIDstr) -> State:
"""Take an ImportedSuperPopSwitch subscription, and turn it into a SuperPopSwitch subscription."""
old_super_pop_switch = ImportedSuperPopSwitch.from_subscription(subscription_id)
new_subscription_id = get_product_id_by_name(ProductName.SITE)
new_subscription = SuperPopSwitch.from_other_product(old_super_pop_switch, new_subscription_id)
return {"subscription": new_subscription}
@workflow("Import SuperPopSwitch", target=Target.MODIFY, initial_input_form=wrap_modify_initial_input_form(None))
def import_super_pop_switch() -> StepList:
"""Modify an ImportedSuperPopSwitch subscription into a SuperPopSwitch subscription to complete the import."""
return (
init
>> store_process_subscription(Target.MODIFY)
>> unsync
>> import_super_pop_switch_subscription
>> resync
>> done
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment