|
| 1 | +"""Add nsistp product. |
| 2 | +
|
| 3 | +Revision ID: a87d11eb8dd1 |
| 4 | +Revises: 0e8d17ce0f06 |
| 5 | +Create Date: 2025-09-30 15:50:36.882313 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +from uuid import uuid4 |
| 10 | + |
| 11 | +from alembic import op |
| 12 | +from orchestrator.migrations.helpers import create, create_workflow, delete, delete_workflow, ensure_default_workflows |
| 13 | +from orchestrator.targets import Target |
| 14 | + |
| 15 | +# revision identifiers, used by Alembic. |
| 16 | +revision = "a87d11eb8dd1" |
| 17 | +down_revision = "0e8d17ce0f06" |
| 18 | +branch_labels = None |
| 19 | +depends_on = None |
| 20 | + |
| 21 | +new_products = { |
| 22 | + "products": { |
| 23 | + "nsistp": { |
| 24 | + "product_id": uuid4(), |
| 25 | + "product_type": "Nsistp", |
| 26 | + "description": "NSISTP", |
| 27 | + "tag": "NSISTP", |
| 28 | + "status": "active", |
| 29 | + "root_product_block": "Nsistp", |
| 30 | + "fixed_inputs": {}, |
| 31 | + }, |
| 32 | + }, |
| 33 | + "product_blocks": { |
| 34 | + "Nsistp": { |
| 35 | + "product_block_id": uuid4(), |
| 36 | + "description": "nsistp product block", |
| 37 | + "tag": "NSISTP", |
| 38 | + "status": "active", |
| 39 | + "resources": { |
| 40 | + "topology": "Name of the topology this Service Termination Point is exposed in", |
| 41 | + "stp_id": "Unique identifier for the Service Termination Point", |
| 42 | + "stp_description": "Description of the Service Termination Point", |
| 43 | + "is_alias_in": "Inbound port from the other topology in case this STP is part of a SDP", |
| 44 | + "is_alias_out": "Outbound port from the other topology in case this STP is part of a SDP", |
| 45 | + "expose_in_topology": "Whether to actively expose this STP in the topology", |
| 46 | + "bandwidth": "Maximum bandwidth for the combined set of STP (in Mbps)", |
| 47 | + }, |
| 48 | + "depends_on_block_relations": [ |
| 49 | + "SAP", |
| 50 | + ], |
| 51 | + }, |
| 52 | + }, |
| 53 | + "workflows": {}, |
| 54 | +} |
| 55 | + |
| 56 | +new_workflows = [ |
| 57 | + { |
| 58 | + "name": "create_nsistp", |
| 59 | + "target": Target.CREATE, |
| 60 | + "is_task": False, |
| 61 | + "description": "Create nsistp", |
| 62 | + "product_type": "Nsistp", |
| 63 | + }, |
| 64 | + { |
| 65 | + "name": "modify_nsistp", |
| 66 | + "target": Target.MODIFY, |
| 67 | + "is_task": False, |
| 68 | + "description": "Modify nsistp", |
| 69 | + "product_type": "Nsistp", |
| 70 | + }, |
| 71 | + { |
| 72 | + "name": "terminate_nsistp", |
| 73 | + "target": Target.TERMINATE, |
| 74 | + "is_task": False, |
| 75 | + "description": "Terminate nsistp", |
| 76 | + "product_type": "Nsistp", |
| 77 | + }, |
| 78 | + { |
| 79 | + "name": "validate_nsistp", |
| 80 | + "target": Target.VALIDATE, |
| 81 | + "is_task": True, |
| 82 | + "description": "Validate nsistp", |
| 83 | + "product_type": "Nsistp", |
| 84 | + }, |
| 85 | +] |
| 86 | + |
| 87 | + |
| 88 | +def upgrade() -> None: |
| 89 | + conn = op.get_bind() |
| 90 | + create(conn, new_products) |
| 91 | + for workflow in new_workflows: |
| 92 | + create_workflow(conn, workflow) |
| 93 | + ensure_default_workflows(conn) |
| 94 | + |
| 95 | + |
| 96 | +def downgrade() -> None: |
| 97 | + conn = op.get_bind() |
| 98 | + for workflow in new_workflows: |
| 99 | + delete_workflow(conn, workflow["name"]) |
| 100 | + |
| 101 | + delete(conn, new_products) |
0 commit comments