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