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
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ def _set_port_attributes(
inspected_port: InspectedPort,
physical_network: str | None,
):
category = None
if physical_network:
category = physical_network.split("-")[-1]

try:
if port.local_link_connection != inspected_port.local_link_connection:
LOG.debug(
Expand All @@ -130,6 +134,7 @@ def _set_port_attributes(

if physical_network and not physical_network.endswith("-network"):
physical_network = None
category = "storage"

if port.physical_network != physical_network:
LOG.debug(
Expand All @@ -141,6 +146,9 @@ def _set_port_attributes(
)
port.physical_network = physical_network

if port.category != category:
port.category = category

port.save()
except exception.IronicException as e:
LOG.warning(
Expand All @@ -153,6 +161,7 @@ def _clear_port_attributes(port: Any, node_uuid: str):
try:
port.local_link_connection = {}
port.physical_network = None
port.category = None
port.save()
except exception.IronicException as e:
LOG.warning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_with_valid_data(mocker, caplog):
address="11:11:11:11:11:11",
local_link_connection={},
physical_network="original_value",
category=None,
)

mocker.patch(
Expand All @@ -101,6 +102,7 @@ def test_with_valid_data(mocker, caplog):
"switch_info": "f20-3-1.iad3.rackspace.net",
}
assert mock_port.physical_network == "f20-3-network"
assert mock_port.category == "network"
mock_port.save.assert_called()
mock_node.save.assert_called_once()

Expand Down
Loading