Skip to content
Snippets Groups Projects
Commit 0806c772 authored by Simone Spinelli's avatar Simone Spinelli
Browse files

Device FQDN is calculated - SNMP location needs rework

parent 1a5b365b
No related branches found
No related tags found
1 merge request!12Add sites, and add integration of IPtrunks and routers with LSO deployment
......@@ -48,7 +48,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
title = product_name
device_site: site_selector()
fqdn: str
hostname: str
ts_address: ipaddress.IPv4Address
ts_port: int
device_vendor: device_pb.DeviceVendor
......@@ -88,19 +88,23 @@ def get_info_from_ipam(subscription: device.DeviceInactive) -> State:
@step("Initialize subscription")
def initialize_subscription(
subscription: device.DeviceInactive,
fqdn: str,
hostname: str,
ts_address: ipaddress.IPv4Address,
ts_port: str,
device_vendor: device_pb.DeviceVendor,
device_site: str,
device_role: device_pb.DeviceRole
) -> State:
subscription.device.device_fqdn = fqdn
subscription.device.device_ts_address = str(ts_address)
subscription.device.device_ts_port = str(ts_port)
subscription.device.device_vendor = device_vendor
subscription.device.device_site \
= Site.from_subscription(device_site[0]).site
fqdn = str(hostname + "." +
subscription.device.device_site.site_name.lower() + "." +
subscription.device.device_site.site_country_code.lower() +
".geant.net")
subscription.device.device_fqdn = fqdn
subscription.device.device_role = device_role
subscription.description = f"Device {fqdn} type \
({subscription.device_type})"
......@@ -108,45 +112,43 @@ def initialize_subscription(
subscription, SubscriptionLifecycle.PROVISIONING
)
return {"subscription": subscription}
return {"subscription": subscription, "fqdn": fqdn}
@step("Provision device [DRY RUN]")
def provision_device_dry(
subscription: device.DeviceProvisioning,
fqdn: str,
ts_address: str,
ts_port: str
subscription: device.DeviceProvisioning
) -> State:
# import ansible_runner
#
# r = ansible_runner.run(
# private_data_dir="/opt/geant-gap-ansible",
# playbook="base_config.yaml",
# inventory=subscription.device.fqdn,
# extravars={
# "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": 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",
# },
# )
# out = r.stdout.read()
# out_splitted = out.splitlines()
import ansible_runner
snmp_location = subscription.device.device_site.site_country_code
r = ansible_runner.run(
private_data_dir="/opt/geant-gap-ansible",
playbook="base_config.yaml",
inventory=subscription.device.device_fqdn,
extravars={
"lo_ipv4_address": str(subscription.device.device_lo_ipv4_address),
"lo_ipv6_address": str(subscription.device.device_lo_ipv6_address),
"lo_iso_address": subscription.device.device_lo_iso_address,
"snmp_location": snmp_location,
"si_ipv4_network": str(subscription.device.device_si_ipv4_network),
"lt_ipv4_network": str(subscription.device.device_ias_lt_ipv4_network),
"lt_ipv6_network": str(subscription.device.device_ias_lt_ipv6_network),
"site_country_code": subscription.device.device_site.site_country_code,
"verb": "deploy",
},
)
out = r.stdout.read()
out_splitted = out.splitlines()
# # if r.rc != 0:
# # raise ValueError("Ansible has failed")
# return {"dry_run_output": out_splitted, "return_code": r.rc}
return {"dry_run_output": out_splitted, "return_code": r.rc}
# provisioning_proxy.provision_node(
# node_subscription_params=subscription,
# dry_run=True)
# TODO: figure out what to return when we are suspending & waiting
# for the provisioning-proxy to call back
return {"return_code": 0}
#return {"return_code": 0}
@inputstep("Confirm step", assignee="CHANGES")
......@@ -161,39 +163,40 @@ def confirm_step() -> FormGenerator:
@step("Provision device [FOR REAL]")
def provision_device_real(
subscription: device.DeviceProvisioning,
fqdn: str,
ts_address: str,
ts_port: str
subscription: device.DeviceProvisioning
) -> State:
# import ansible_runner
#
# r = ansible_runner.run(
# private_data_dir="/opt/geant-gap-ansible",
# playbook="base_config.yaml",
# inventory=subscription.device.fqdn,
# extravars={
# "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": 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",
# },
# )
# out = r.stdout.read()
# out_splitted = out.splitlines()
#
# return {"real_run_output": out_splitted, "return_code": r.rc}
import ansible_runner
snmp_location = subscription.device.device_site.site_country_code
r = ansible_runner.run(
private_data_dir="/opt/geant-gap-ansible",
playbook="base_config.yaml",
inventory=subscription.device.device_fqdn,
extravars={
"lo_ipv4_address": str(subscription.device.device_lo_ipv4_address),
"lo_ipv6_address": str(subscription.device.device_lo_ipv6_address),
"lo_iso_address": subscription.device.device_lo_iso_address,
"snmp_location": snmp_location,
"si_ipv4_network": str(subscription.device.device_si_ipv4_network),
"lt_ipv4_network": str(subscription.device.device_ias_lt_ipv4_network),
"lt_ipv6_network": str(subscription.device.device_ias_lt_ipv6_network),
"site_country_code": subscription.device.device_site.site_country_code,
"verb": "deploy",
"dryrun": "False",
"commit_comment": "Deployed with WFO and Ansible",
},
)
out = r.stdout.read()
out_splitted = out.splitlines()
# # if r.rc != 0:
# # raise ValueError("Ansible has failed")
return {"dry_run_output": out_splitted, "return_code": r.rc}
# provisioning_proxy.provision_node(
# node_subscription_params=subscription)
# TODO: figure out what to return when we are suspending & waiting
# for the provisioning-proxy to call back
return {"return_code": 0}
# node_subscription_params=subscription,
# dry_run=True)
# TODO: figure out what to return when we are suspending & waiting
# for the provisioning-proxy to call back
#return {"return_code": 0}
@workflow(
"Create Device",
......
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