Skip to content

Commit 6432d6d

Browse files
authored
Merge pull request #1602 from rackerlabs/set-storage-category
fix(ironic): set the category on ports based on physical_network
2 parents b4c7902 + b39e26c commit 6432d6d

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

python/ironic-understack/ironic_understack/inspect_hook_update_baremetal_ports.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def _set_port_attributes(
117117
inspected_port: InspectedPort,
118118
physical_network: str | None,
119119
):
120+
category = None
121+
if physical_network:
122+
category = physical_network.split("-")[-1]
123+
120124
try:
121125
if port.local_link_connection != inspected_port.local_link_connection:
122126
LOG.debug(
@@ -130,6 +134,7 @@ def _set_port_attributes(
130134

131135
if physical_network and not physical_network.endswith("-network"):
132136
physical_network = None
137+
category = "storage"
133138

134139
if port.physical_network != physical_network:
135140
LOG.debug(
@@ -141,6 +146,9 @@ def _set_port_attributes(
141146
)
142147
port.physical_network = physical_network
143148

149+
if port.category != category:
150+
port.category = category
151+
144152
port.save()
145153
except exception.IronicException as e:
146154
LOG.warning(
@@ -153,6 +161,7 @@ def _clear_port_attributes(port: Any, node_uuid: str):
153161
try:
154162
port.local_link_connection = {}
155163
port.physical_network = None
164+
port.category = None
156165
port.save()
157166
except exception.IronicException as e:
158167
LOG.warning(

python/ironic-understack/ironic_understack/tests/test_inspect_hook_update_baremetal_ports.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def test_with_valid_data(mocker, caplog):
7777
address="11:11:11:11:11:11",
7878
local_link_connection={},
7979
physical_network="original_value",
80+
category=None,
8081
)
8182

8283
mocker.patch(
@@ -101,6 +102,7 @@ def test_with_valid_data(mocker, caplog):
101102
"switch_info": "f20-3-1.iad3.rackspace.net",
102103
}
103104
assert mock_port.physical_network == "f20-3-network"
105+
assert mock_port.category == "network"
104106
mock_port.save.assert_called()
105107
mock_node.save.assert_called_once()
106108

0 commit comments

Comments
 (0)