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

Introducing is_ias_connected attribute and manage it in create_device

parent ae49b5fd
No related branches found
No related tags found
1 merge request!56Reworked devices and sites - added new attribute to manage local connection to IAS
Pipeline #83805 failed
......@@ -45,10 +45,10 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
device_site: site_selector() # type: ignore
hostname: str
ts_address: ipaddress.IPv4Address
ts_port: int
device_vendor: device_pb.DeviceVendor
device_role: device_pb.DeviceRole
is_ias_connected: bool
user_input = yield CreateDeviceForm
......@@ -73,22 +73,26 @@ def iso_from_ipv4(ipv4_address: ipaddress.IPv4Address) -> str:
@step("Get information from IPAM")
def get_info_from_ipam(subscription: DeviceProvisioning) -> State:
def get_info_from_ipam(subscription: DeviceProvisioning, is_ias_connected: bool) -> State:
lo0_alias = re.sub(".geant.net", "", subscription.device.device_fqdn)
lo0_name = f"lo0.{lo0_alias}"
lo0_addr = ipam.allocate_host(hostname=lo0_name, service_type="LO", cname_aliases=[lo0_alias])
subscription.device.device_lo_ipv4_address = lo0_addr.v4
subscription.device.device_lo_ipv6_address = lo0_addr.v6
subscription.device.device_lo_iso_address = iso_from_ipv4(subscription.device.device_lo_ipv4_address)
subscription.device.device_si_ipv4_network = ipam.allocate_ipv4_network(
service_type="SI", comment=f"SI for {lo0_name}"
).v4
subscription.device.device_ias_lt_ipv4_network = ipam.allocate_ipv4_network(
service_type="LT_IAS", comment=f"LT for {lo0_name}"
).v4
subscription.device.device_ias_lt_ipv6_network = ipam.allocate_ipv6_network(
service_type="LT_IAS", comment=f"LT for {lo0_name}"
).v6
subscription.device.device_is_ias_connected = is_ias_connected
if is_ias_connected is True:
subscription.device.device_si_ipv4_network = ipam.allocate_ipv4_network(
service_type="SI", comment=f"SI for {lo0_name}"
).v4
subscription.device.device_ias_lt_ipv4_network = ipam.allocate_ipv4_network(
service_type="LT_IAS", comment=f"LT for {lo0_name}"
).v4
subscription.device.device_ias_lt_ipv6_network = ipam.allocate_ipv6_network(
service_type="LT_IAS", comment=f"LT for {lo0_name}"
).v6
return {"subscription": subscription}
......
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