Skip to content
Snippets Groups Projects
Commit 4ef56d26 authored by Karel van Klink's avatar Karel van Klink :smiley_cat: Committed by Aleksandr Kurbatov
Browse files

Update IPtrunk migration IPAM step behaviour

parent aaed503e
No related branches found
No related tags found
1 merge request!173Update IPtrunk migration IPAM step behaviour
......@@ -542,26 +542,25 @@ def delete_old_config_real(
@step("Update IP records in IPAM")
def update_ipam(subscription: Iptrunk, old_side_data: dict, new_node: Router, new_lag_interface: str) -> State:
def update_ipam(subscription: Iptrunk, replace_index: int, new_node: Router, new_lag_interface: str) -> State:
"""Update :term:`IPAM` resources.
Move the DNS record pointing to the old side of the trunk, to the new side.
"""
old_fqdn = f"{old_side_data['iptrunk_side_ae_iface']}.{old_side_data['iptrunk_side_node']['router_fqdn']}"
trunk_v4 = infoblox.find_host_by_fqdn(old_fqdn)
trunk_v6 = infoblox.find_v6_host_by_fqdn(old_fqdn)
v4_addr = subscription.iptrunk.iptrunk_ipv4_network[replace_index]
v6_addr = subscription.iptrunk.iptrunk_ipv6_network[replace_index]
# Out with the old
try:
infoblox.delete_host_by_fqdn(old_fqdn)
infoblox.delete_host_by_ip(subscription.iptrunk.iptrunk_ipv4_network[replace_index])
except DeletionError as e:
msg = "Failed to delete record from Infoblox."
raise ProcessFailureError(msg) from e
# And in with the new
new_fqdn = f"{new_lag_interface}.{new_node.router.router_fqdn}"
new_fqdn = f"{new_lag_interface}-0.{new_node.router.router_fqdn}"
comment = str(subscription.subscription_id)
infoblox.create_host_by_ip(new_fqdn, trunk_v4.ipv4addr, trunk_v6.ipv6addr, service_type="TRUNK", comment=comment)
infoblox.create_host_by_ip(new_fqdn, v4_addr, v6_addr, "TRUNK", comment)
return {"subscription": subscription}
......
......@@ -109,9 +109,7 @@ def interface_lists_are_equal(list1, list2):
)
@pytest.mark.workflow()
@patch("gso.services.infoblox.create_host_by_ip")
@patch("gso.services.infoblox.find_v6_host_by_fqdn")
@patch("gso.services.infoblox.find_host_by_fqdn")
@patch("gso.services.infoblox.delete_host_by_fqdn")
@patch("gso.services.infoblox.delete_host_by_ip")
@patch("gso.services.provisioning_proxy._send_request")
@patch("gso.services.netbox_client.NetboxClient.get_available_interfaces")
@patch("gso.services.netbox_client.NetboxClient.get_available_lags")
......@@ -131,9 +129,7 @@ def test_migrate_iptrunk_success(
mocked_get_available_lags,
mocked_get_available_interfaces,
mock_execute_playbook,
mock_delete_host_by_fqdn,
mock_find_host_by_fqdn,
mock_find_v6_host_by_fqdn,
mock_delete_host_by_ip,
mock_create_host_by_ip,
migrate_form_input,
data_config_filename: PathLike,
......@@ -173,10 +169,8 @@ def test_migrate_iptrunk_success(
assert subscription.status == "active"
assert mock_execute_playbook.call_count == 9
assert mock_find_host_by_fqdn.call_count == 1
assert mock_find_v6_host_by_fqdn.call_count == 1
assert mock_create_host_by_ip.call_count == 1
assert mock_delete_host_by_fqdn.call_count == 1
assert mock_delete_host_by_ip.call_count == 1
# get some values from form
new_router = migrate_form_input[2]["new_node"]
......
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