diff --git a/geant_service_orchestrator/migrations/versions/2023-04-05_857225661207_add_device_workflows.py b/geant_service_orchestrator/migrations/versions/2023-04-05_857225661207_add_device_workflows.py new file mode 100644 index 0000000000000000000000000000000000000000..c4d7d7fed664375254113c0537cdbe2ce6d90beb --- /dev/null +++ b/geant_service_orchestrator/migrations/versions/2023-04-05_857225661207_add_device_workflows.py @@ -0,0 +1,39 @@ +"""add Device workflows. + +Revision ID: 857225661207 +Revises: f4959f32c866 +Create Date: 2023-04-05 09:16:03.725750 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '857225661207' +down_revision = 'f4959f32c866' +branch_labels = None +depends_on = None + + +from orchestrator.migrations.helpers import create_workflow, delete_workflow + +new_workflows = [ + { + "name": "create_device", + "target": "CREATE", + "description": "Create Device", + "product_type": "Device" + } +] + + +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"]) diff --git a/geant_service_orchestrator/products/product_types/device.py b/geant_service_orchestrator/products/product_types/device.py index a630d2b3378ee2b37b428a239a8e05ddc53c7b42..0b20fa9080744ee682734b83bf0c0866be42c680 100644 --- a/geant_service_orchestrator/products/product_types/device.py +++ b/geant_service_orchestrator/products/product_types/device.py @@ -11,8 +11,8 @@ class DeviceType(strEnum): class DeviceVendor(strEnum): - Juniper = "juniper" - Newvendor = "newvendor" + Juniper = "Juniper" + Newvendor = "Newvendor" class DeviceInactive(SubscriptionModel, is_base=True): diff --git a/geant_service_orchestrator/workflows/device/create_device.py b/geant_service_orchestrator/workflows/device/create_device.py index 4c46e93fcf9d3d9194ef0194f25fd2da0fa1aee3..6a4f29f8d4c722d840b3630137339561bfe470e4 100644 --- a/geant_service_orchestrator/workflows/device/create_device.py +++ b/geant_service_orchestrator/workflows/device/create_device.py @@ -73,12 +73,12 @@ def initialize_subscription( fqdn: str, ts_address: ipaddress.IPv4Address, ts_port: str, - device_vendor: str + device_vendor: DeviceVendor ) -> State: subscription.device.fqdn = fqdn - subscription.device.ts_address = ts_address - subscription.device.ts_port = ts_port - subscription.device.device_vendor = device_vendor + subscription.device.ts_address = str(ts_address) + subscription.device.ts_port = str(ts_port) + subscription.device_vendor = device_vendor subscription.description = f"Device {fqdn} type \ ({subscription.device_type})" subscription = DeviceProvisioning.from_other_lifecycle( @@ -95,17 +95,17 @@ def provision_device( import ansible_runner r = ansible_runner.run( - private_data_dir="/opt", + private_data_dir="/opt/geant-gap-ansible", playbook="base_config.yaml", inventory=subscription.device.fqdn, extravars={ - "lo_ipv4_address": subscription.device.lo_ipv4_address, - "lo_ipv6_address": subscription.device.lo_ipv6_address, + "lo_ipv4_address": str(subscription.device.lo_ipv4_address), + "lo_ipv6_address": str(subscription.device.lo_ipv6_address), "lo_iso_address": subscription.device.lo_iso_address, "snmp_location": subscription.device.snmp_location, - "si_ipv4_network": subscription.device.si_ipv4_network, - "lt_ipv4_network": subscription.device.ias_lt_ipv4_network, - "lt_ipv6_network": subscription.device.ias_lt_ipv6_network, + "si_ipv4_network": str(subscription.device.si_ipv4_network), + "lt_ipv4_network": str(subscription.device.ias_lt_ipv4_network), + "lt_ipv6_network": str(subscription.device.ias_lt_ipv6_network), "site_country_code": subscription.device.site_country_code, "verb": "deploy", },