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

Add import workflows to database

parent 6d2e36fb
No related branches found
No related tags found
1 merge request!201Add imported products
"""Add creation workflows for imported products.
Revision ID: ab8d805d27b3
Revises: 3b73ee683cec
Create Date: 2024-04-19 16:21:07.304696
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = 'ab8d805d27b3'
down_revision = '3b73ee683cec'
branch_labels = None
depends_on = None
from orchestrator.migrations.helpers import create_workflow, delete_workflow
new_workflows = [
{
"name": "create_imported_site",
"target": "CREATE",
"description": "Import Site",
"product_type": "ImportedSite"
},
{
"name": "create_imported_router",
"target": "CREATE",
"description": "Import router",
"product_type": "ImportedRouter"
},
{
"name": "create_imported_iptrunk",
"target": "CREATE",
"description": "Import iptrunk",
"product_type": "ImportedIptrunk"
},
{
"name": "create_imported_super_pop_switch",
"target": "CREATE",
"description": "Import Super PoP switch",
"product_type": "ImportedSuperPopSwitch"
},
{
"name": "create_imported_office_router",
"target": "CREATE",
"description": "Import office router",
"product_type": "ImportedOfficeRouter"
}
]
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"])
...@@ -40,8 +40,10 @@ LazyWorkflowInstance("gso.workflows.router.modify_connection_strategy", "modify_ ...@@ -40,8 +40,10 @@ LazyWorkflowInstance("gso.workflows.router.modify_connection_strategy", "modify_
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.tasks.import_site", "import_site") LazyWorkflowInstance("gso.workflows.site.create_imported_site", "create_imported_site")
LazyWorkflowInstance("gso.workflows.tasks.import_router", "import_router") LazyWorkflowInstance("gso.workflows.router.create_imported_router", "create_imported_router")
LazyWorkflowInstance("gso.workflows.tasks.import_iptrunk", "import_iptrunk") LazyWorkflowInstance("gso.workflows.iptrunk.create_imported_iptrunk", "create_imported_iptrunk")
LazyWorkflowInstance("gso.workflows.tasks.import_super_pop_switch", "import_super_pop_switch") LazyWorkflowInstance(
LazyWorkflowInstance("gso.workflows.tasks.import_office_router", "import_office_router") "gso.workflows.super_pop_switch.create_imported_super_pop_switch", "create_imported_super_pop_switch"
)
LazyWorkflowInstance("gso.workflows.office_router.create_imported_office_router", "create_imported_office_router")
...@@ -76,7 +76,7 @@ def initialize_subscription( ...@@ -76,7 +76,7 @@ def initialize_subscription(
initial_input_form=initial_input_form_generator, initial_input_form=initial_input_form_generator,
target=Target.CREATE, target=Target.CREATE,
) )
def import_office_router() -> StepList: def create_imported_office_router() -> StepList:
"""Import an office router without provisioning it.""" """Import an office router without provisioning it."""
return ( return (
init init
......
...@@ -10,8 +10,7 @@ from orchestrator.workflow import StepList, done, init, step ...@@ -10,8 +10,7 @@ from orchestrator.workflow import StepList, done, init, step
from orchestrator.workflows.steps import resync, set_status, store_process_subscription from orchestrator.workflows.steps import resync, set_status, store_process_subscription
from gso.products import ProductName from gso.products import ProductName
from gso.products.product_types import super_pop_switch from gso.products.product_types.super_pop_switch import ImportedSuperPopSwitchInactive
from gso.products.product_types.super_pop_switch import SuperPopSwitchInactive
from gso.services import subscriptions from gso.services import subscriptions
from gso.services.partners import get_partner_by_name from gso.services.partners import get_partner_by_name
from gso.services.subscriptions import get_site_by_name from gso.services.subscriptions import get_site_by_name
...@@ -23,8 +22,8 @@ from gso.utils.shared_enums import PortNumber, Vendor ...@@ -23,8 +22,8 @@ from gso.utils.shared_enums import PortNumber, Vendor
def create_subscription(partner: str) -> State: def create_subscription(partner: str) -> State:
"""Create a new subscription object.""" """Create a new subscription object."""
partner_id = get_partner_by_name(partner)["partner_id"] partner_id = get_partner_by_name(partner)["partner_id"]
product_id = subscriptions.get_product_id_by_name(ProductName.SUPER_POP_SWITCH) product_id = subscriptions.get_product_id_by_name(ProductName.IMPORTED_SUPER_POP_SWITCH)
subscription = SuperPopSwitchInactive.from_product_id(product_id, partner_id) subscription = ImportedSuperPopSwitchInactive.from_product_id(product_id, partner_id)
return { return {
"subscription": subscription, "subscription": subscription,
...@@ -52,7 +51,7 @@ def initial_input_form_generator() -> FormGenerator: ...@@ -52,7 +51,7 @@ def initial_input_form_generator() -> FormGenerator:
@step("Initialize subscription") @step("Initialize subscription")
def initialize_subscription( def initialize_subscription(
subscription: SuperPopSwitchInactive, subscription: ImportedSuperPopSwitchInactive,
hostname: str, hostname: str,
super_pop_switch_ts_port: PortNumber, super_pop_switch_ts_port: PortNumber,
super_pop_switch_site: str, super_pop_switch_site: str,
...@@ -68,10 +67,6 @@ def initialize_subscription( ...@@ -68,10 +67,6 @@ def initialize_subscription(
subscription.super_pop_switch.super_pop_switch_mgmt_ipv4_address = super_pop_switch_mgmt_ipv4_address subscription.super_pop_switch.super_pop_switch_mgmt_ipv4_address = super_pop_switch_mgmt_ipv4_address
subscription.super_pop_switch.vendor = Vendor.JUNIPER subscription.super_pop_switch.vendor = Vendor.JUNIPER
subscription = super_pop_switch.SuperPopSwitchProvisioning.from_other_lifecycle(
subscription, SubscriptionLifecycle.PROVISIONING
)
return {"subscription": subscription} return {"subscription": subscription}
...@@ -80,7 +75,7 @@ def initialize_subscription( ...@@ -80,7 +75,7 @@ def initialize_subscription(
initial_input_form=initial_input_form_generator, initial_input_form=initial_input_form_generator,
target=Target.CREATE, target=Target.CREATE,
) )
def import_super_pop_switch() -> StepList: def create_imported_super_pop_switch() -> StepList:
"""Import a Super PoP switch without provisioning it.""" """Import a Super PoP switch without provisioning it."""
return ( return (
init init
......
"""Task workflows that are either started by an :term:`API` endpoint, or by one of the set schedules."""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment