Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions python/neutron-understack/neutron_understack/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,21 @@ def subnet_create(
}
return self.make_api_request("POST", "/api/ipam/prefixes/", payload)

def associate_subnet_with_network(
self, network_uuid: str, subnet_uuid: str, role: str
):
def set_svi_role_on_network(self, network_uuid: str, role: str):
url = f"/api/plugins/undercloud-vni/ucvnis/{network_uuid}/"
payload = {"role": {"name": role}}
self.make_api_request("PATCH", url, payload)

def associate_subnet_with_network(self, network_uuid: str, subnet_uuid: str):
url = "/api/extras/relationship-associations/"
payload = {
"role": {"name": role},
"relationships": {
"ucvni_prefixes": {
"destination": {
"objects": [subnet_uuid],
},
},
},
"relationship": {"key": "ucvni_prefixes"},
"source_type": "vni_custom_model.ucvni",
"source_id": network_uuid,
"destination_type": "ipam.prefix",
"destination_id": subnet_uuid,
}
self.make_api_request("PATCH", url, payload)
self.make_api_request("POST", url, payload)

def add_tenant_vlan_tag_to_ucvni(self, network_uuid: str, vlan_tag: int) -> dict:
url = f"/api/plugins/undercloud-vni/ucvnis/{network_uuid}/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,13 @@ def create_subnet_postcommit(self, context):

if external:
self.nb.associate_subnet_with_network(
role="svi_vxlan_anycast_gateway",
network_uuid=network_uuid,
subnet_uuid=subnet_uuid,
)
self.nb.set_svi_role_on_network(
role="svi_vxlan_anycast_gateway",
network_uuid=network_uuid,
)

LOG.info(
"subnet with ID: %s and prefix %s has been "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@ def test_create_public(self, understack_driver, subnet_context, subnet):
tenant_uuid=ANY,
)
understack_driver.nb.associate_subnet_with_network.assert_called_once_with(
role="svi_vxlan_anycast_gateway",
network_uuid=subnet.network_id,
subnet_uuid=subnet.id,
)
understack_driver.nb.set_svi_role_on_network.assert_called_once_with(
network_uuid=subnet.network_id,
role="svi_vxlan_anycast_gateway",
)


class TestDeleteSubnetPostCommit:
Expand Down