Skip to content
Snippets Groups Projects
Verified Commit 23976c78 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Add workflow step for iptrunk creation that handles DNS records

parent 3a7eaf8e
No related branches found
No related tags found
1 merge request!172Add IPAM step to IPtrunk creation
Pipeline #85879 passed
......@@ -400,6 +400,22 @@ def check_ip_trunk_isis(
return {"subscription": subscription}
@step("Register DNS records for both sides of the trunk")
def register_dns_records(subscription: IptrunkInactive) -> State:
"""Register DNS records for both sides of the newly created IPtrunk."""
for index, side in enumerate(subscription.iptrunk.iptrunk_sides):
fqdn = f"{side.iptrunk_side_ae_iface}-0.{side.iptrunk_side_node.router_fqdn}"
if not (subscription.iptrunk.iptrunk_ipv4_network and subscription.iptrunk.iptrunk_ipv6_network):
msg = f"Missing IP resources in trunk, cannot allocate DNS record for side {fqdn}!"
raise ValueError(msg)
ipv4_addr = subscription.iptrunk.iptrunk_ipv4_network[index]
ipv6_addr = subscription.iptrunk.iptrunk_ipv6_network[index]
infoblox.create_host_by_ip(fqdn, ipv4_addr, ipv6_addr, "TRUNK", str(subscription.subscription_id))
return {"subscription": subscription}
@step("NextBox integration")
def reserve_interfaces_in_netbox(subscription: IptrunkInactive) -> State:
"""Create the :term:`LAG` interfaces in NetBox and attach the lag interfaces to the physical interfaces."""
......@@ -490,6 +506,7 @@ def create_iptrunk() -> StepList:
>> pp_interaction(provision_ip_trunk_isis_iface_dry)
>> pp_interaction(provision_ip_trunk_isis_iface_real)
>> pp_interaction(check_ip_trunk_isis)
>> register_dns_records
>> side_a_is_nokia(netbox_allocate_side_a_interfaces)
>> side_b_is_nokia(netbox_allocate_side_b_interfaces)
>> set_status(SubscriptionLifecycle.PROVISIONING)
......
......@@ -97,7 +97,9 @@ def input_form_wizard_data(request, juniper_router_subscription_factory, nokia_r
@patch("gso.workflows.iptrunk.create_iptrunk.execute_playbook")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.create_host_by_ip")
def test_successful_iptrunk_creation_with_standard_lso_result(
mock_create_host,
mock_allocate_v4_network,
mock_allocate_v6_network,
mock_execute_playbook,
......@@ -108,6 +110,7 @@ def test_successful_iptrunk_creation_with_standard_lso_result(
data_config_filename: PathLike,
test_client,
):
mock_create_host.return_value = None
mock_allocate_v4_network.return_value = faker.ipv4(network=True)
mock_allocate_v6_network.return_value = faker.ipv6(network=True)
product_id = get_product_id_by_name(ProductType.IP_TRUNK)
......@@ -170,7 +173,9 @@ def test_iptrunk_creation_fails_when_lso_return_code_is_one(
@patch("gso.workflows.iptrunk.create_iptrunk.execute_playbook")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.create_host_by_ip")
def test_successful_iptrunk_creation_with_juniper_interface_names(
mock_create_host,
mock_allocate_v4_network,
mock_allocate_v6_network,
mock_execute_playbook,
......@@ -181,8 +186,9 @@ def test_successful_iptrunk_creation_with_juniper_interface_names(
_netbox_client_mock, # noqa: PT019
test_client,
):
mock_allocate_v4_network.return_value = faker.ipv4(network=True)
mock_allocate_v6_network.return_value = faker.ipv6(network=True)
mock_create_host.return_value = None
mock_allocate_v4_network.return_value = faker.ipv4_network(max_subnet=31)
mock_allocate_v6_network.return_value = faker.ipv6_network(max_subnet=127)
product_id = get_product_id_by_name(ProductType.IP_TRUNK)
initial_site_data = [{"product": product_id}, *input_form_wizard_data]
result, process_stat, step_log = run_workflow("create_iptrunk", initial_site_data)
......
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