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 @@ -172,12 +172,14 @@ def _set_node_traits(task, vlan_groups: set[str]):

We remove pre-existing traits if the node does not have the required
connections.

Traits other than CUSTOM_*_SWITCH are left alone.
"""
node = task.node
existing_traits = set(node.traits.get_trait_names())
vlan_group_traits = {_trait_name(x) for x in vlan_groups if x}
irrelevant_existing_traits = {x for x in existing_traits if not _is_our_trait(x)}
required_traits = irrelevant_existing_traits.intersection(vlan_group_traits)
required_traits = irrelevant_existing_traits.union(vlan_group_traits)

if existing_traits == required_traits:
LOG.debug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_with_valid_data(mocker, caplog):
"ironic_understack.inspect_hook_update_baremetal_ports.CONF.ironic_understack.switch_name_vlan_group_mapping",
MAPPING,
)
mocker.patch(
trait_create = mocker.patch(
"ironic_understack.inspect_hook_update_baremetal_ports.objects.TraitList.create"
)

Expand All @@ -103,3 +103,7 @@ def test_with_valid_data(mocker, caplog):
assert mock_port.physical_network == "f20-3-network"
mock_port.save.assert_called()
mock_node.save.assert_called_once()

trait_create.assert_called_once_with(
mock_context, 1234, {"CUSTOM_STORAGE_SWITCH", "CUSTOM_NETWORK_SWITCH", "bar"}
)
Loading