From e4ed04516376797b559be8b74e490f96d136f26e Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Thu, 21 Mar 2024 14:11:05 +0100 Subject: [PATCH] Add db migration and translation key --- ..._add_subscription_cancellation_workflow.py | 45 +++++++++++++++++++ gso/translations/en-GB.json | 2 + gso/workflows/shared/cancel_subscription.py | 6 +-- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 gso/migrations/versions/2024-03-21_734e36a3e70b_add_subscription_cancellation_workflow.py diff --git a/gso/migrations/versions/2024-03-21_734e36a3e70b_add_subscription_cancellation_workflow.py b/gso/migrations/versions/2024-03-21_734e36a3e70b_add_subscription_cancellation_workflow.py new file mode 100644 index 00000000..7cf56d40 --- /dev/null +++ b/gso/migrations/versions/2024-03-21_734e36a3e70b_add_subscription_cancellation_workflow.py @@ -0,0 +1,45 @@ +"""Add subscription cancellation workflow. + +Revision ID: 734e36a3e70b +Revises: d61c0f92da1e +Create Date: 2024-03-21 13:03:08.981028 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '734e36a3e70b' +down_revision = 'd61c0f92da1e' +branch_labels = None +depends_on = None + + +from orchestrator.migrations.helpers import add_products_to_workflow_by_product_tag, create_workflow, delete_workflow, remove_products_from_workflow_by_product_tag + + +products = ["RTR", "IPTRUNK"] +new_workflows = [ + { + "name": "cancel_subscription", + "target": "TERMINATE", + "description": "Cancel a subscription", + "product_type": "Site" + } +] + + +def upgrade() -> None: + conn = op.get_bind() + for workflow in new_workflows: + create_workflow(conn, workflow) + for product_tag in products: + add_products_to_workflow_by_product_tag(conn, "cancel_subscription", product_tag) + + +def downgrade() -> None: + conn = op.get_bind() + for product_tag in products: + remove_products_from_workflow_by_product_tag(conn, "cancel_subscription", product_tag) + for workflow in new_workflows: + delete_workflow(conn, workflow["name"]) diff --git a/gso/translations/en-GB.json b/gso/translations/en-GB.json index 46f0e96e..fe687f34 100644 --- a/gso/translations/en-GB.json +++ b/gso/translations/en-GB.json @@ -38,10 +38,12 @@ "workflow": { "activate_iptrunk": "Activate IP Trunk", "activate_router": "Activate router", + "cancel_subscription": "Cancel subscription", "confirm_info": "Please verify this form looks correct.", "deploy_twamp": "Deploy TWAMP", "migrate_iptrunk": "Migrate IP Trunk", "modify_isis_metric": "Modify the ISIS metric", + "modify_site": "Modify site", "modify_trunk_interface": "Modify IP Trunk interface", "redeploy_base_config": "Redeploy base config", "update_ibgp_mesh": "Update iBGP mesh" diff --git a/gso/workflows/shared/cancel_subscription.py b/gso/workflows/shared/cancel_subscription.py index 314b5795..79bb0590 100644 --- a/gso/workflows/shared/cancel_subscription.py +++ b/gso/workflows/shared/cancel_subscription.py @@ -13,11 +13,11 @@ def _initial_input_form(subscription_id: UUIDstr) -> FormGenerator: class CancelSubscriptionForm(FormPage): info_label: Label = f"Canceling subscription with ID {subscription_id}" # type:ignore[assignment] info_label_2: Label = ( - "This will immediately mark the subscription as terminated, preventing any other workflows from interacting" + "This will immediately mark the subscription as terminated, preventing any other workflows from interacting" # type:ignore[assignment] " with this product subscription." ) - info_label_3: Label = "ONLY EXECUTE THIS WORKFLOW WHEN YOU ARE ABSOLUTELY SURE WHAT YOU ARE DOING." - info_label_4: Label = "THIS WORKFLOW IS IRREVERSIBLE AND MAY HAVE UNFORESEEN CONSEQUENCES." + info_label_3: Label = "ONLY EXECUTE THIS WORKFLOW WHEN YOU ARE ABSOLUTELY SURE WHAT YOU ARE DOING." # type:ignore[assignment] + info_label_4: Label = "THIS WORKFLOW IS IRREVERSIBLE AND MAY HAVE UNFORESEEN CONSEQUENCES." # type:ignore[assignment] yield CancelSubscriptionForm -- GitLab