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

add import site workflow

parent 647f0753
No related branches found
No related tags found
1 merge request!201Add imported products
"""Add site modification import workflow.
Revision ID: 8ebfc8a34c2e
Revises: ab8d805d27b3
Create Date: 2024-04-23 11:32:39.502729
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '8ebfc8a34c2e'
down_revision = 'ab8d805d27b3'
branch_labels = None
depends_on = None
from orchestrator.migrations.helpers import create_workflow, delete_workflow
new_workflows = [
{
"name": "import_site",
"target": "MODIFY",
"description": "Import Site",
"product_type": "ImportedSite"
}
]
def upgrade() -> None:
conn = op.get_bind()
for workflow in new_workflows:
create_workflow(conn, workflow)
def downgrade() -> None:
conn = op.get_bind()
for workflow in new_workflows:
delete_workflow(conn, workflow["name"])
......@@ -50,6 +50,7 @@
"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"
"create_imported_office_router": "NOT FOR HUMANS -- Import existing office router",
"import_site": "Finalize import into a Site product"
}
}
......@@ -41,6 +41,7 @@ LazyWorkflowInstance("gso.workflows.site.create_site", "create_site")
LazyWorkflowInstance("gso.workflows.site.modify_site", "modify_site")
LazyWorkflowInstance("gso.workflows.site.terminate_site", "terminate_site")
LazyWorkflowInstance("gso.workflows.site.create_imported_site", "create_imported_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")
LazyWorkflowInstance(
......
"""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.site import ImportedSite, Site
from gso.services.subscriptions import get_product_id_by_name
@step("Create new site subscription")
def import_site_subscription(subscription_id: UUIDstr) -> State:
"""Take an ImportedSite subscription, and turn it into a Site subscription."""
old_site = ImportedSite.from_subscription(subscription_id)
new_subscription_id = get_product_id_by_name(ProductName.SITE)
new_subscription = Site.from_other_product(old_site, new_subscription_id)
return {"subscription": new_subscription}
@workflow("Import Site", target=Target.MODIFY, initial_input_form=wrap_modify_initial_input_form(None))
def import_site() -> StepList:
"""Modify an ImportedSite subscription into a Site subscription to complete the import."""
return init >> store_process_subscription(Target.MODIFY) >> unsync >> import_site_subscription >> resync >> done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment