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

add workflow for taking a router from provisioning to active

parent 26ddc379
No related branches found
No related tags found
1 merge request!165router creation flow update
This commit is part of merge request !165. Comments created here will be created in the context of that merge request.
"""Add Router activation workflow.
Revision ID: 113a81d2a40a
Revises: bacd55c26106
Create Date: 2024-02-21 10:28:18.340922
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '113a81d2a40a'
down_revision = 'bacd55c26106'
branch_labels = None
depends_on = None
from orchestrator.migrations.helpers import create_workflow, delete_workflow
new_workflows = [
{
"name": "activate_router",
"target": "MODIFY",
"description": "Activate a router",
"product_type": "Router"
}
]
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"])
......@@ -8,6 +8,7 @@ LazyWorkflowInstance("gso.workflows.iptrunk.modify_isis_metric", "modify_isis_me
LazyWorkflowInstance("gso.workflows.iptrunk.modify_trunk_interface", "modify_trunk_interface")
LazyWorkflowInstance("gso.workflows.iptrunk.migrate_iptrunk", "migrate_iptrunk")
LazyWorkflowInstance("gso.workflows.iptrunk.terminate_iptrunk", "terminate_iptrunk")
LazyWorkflowInstance("gso.workflows.router.activate_router", "activate_router")
LazyWorkflowInstance("gso.workflows.router.create_router", "create_router")
LazyWorkflowInstance("gso.workflows.router.redeploy_base_config", "redeploy_base_config")
LazyWorkflowInstance("gso.workflows.router.terminate_router", "terminate_router")
......
"""Activate router takes a provisioning router to the active lifecycle state."""
from orchestrator.forms import FormPage
from orchestrator.forms.validators import Label
from orchestrator.targets import Target
from orchestrator.types import FormGenerator, SubscriptionLifecycle, UUIDstr
from orchestrator.workflow import StepList, done, init, workflow
from orchestrator.workflows.steps import resync, set_status, store_process_subscription, unsync
from orchestrator.workflows.utils import wrap_modify_initial_input_form
from gso.products.product_types.router import Router
def _initial_input_form(subscription_id: UUIDstr) -> FormGenerator:
router = Router.from_subscription(subscription_id)
class ActivateRouterForm(FormPage):
info_label: Label = "promote?"
tt_number: str
user_input = yield ActivateRouterForm
return user_input.dict() | {"subscription": router}
@workflow(
"Activate a router",
initial_input_form=wrap_modify_initial_input_form(_initial_input_form),
target=Target.MODIFY,
)
def activate_router() -> StepList:
"""Move a router from a ``PROVISIONING`` state to an ``ACTIVE`` state.
* Send email notifications to different teams.
* Wait for approval to be given.
* Update the subscription lifecycle state to ``ACTIVE``.
"""
return (
init
>> store_process_subscription(Target.MODIFY)
>> unsync
>> set_status(SubscriptionLifecycle.ACTIVE)
>> 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