Skip to content
Snippets Groups Projects
Commit 7b336e90 authored by root's avatar root
Browse files

Add workflow for provisioning devices

parent 5636c8d3
Branches
Tags
1 merge request!5Device workflows
"""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"])
......@@ -11,8 +11,8 @@ class DeviceType(strEnum):
class DeviceVendor(strEnum):
Juniper = "juniper"
Newvendor = "newvendor"
Juniper = "Juniper"
Newvendor = "Newvendor"
class DeviceInactive(SubscriptionModel, is_base=True):
......
......@@ -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",
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment