Skip to content

Commit 3ade42b

Browse files
committed
Fix baremetmal extra field updating
1 parent ae20898 commit 3ade42b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

python/ironic-understack/ironic_understack/port_bios_name_hook.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,20 @@ def __call__(self, task, inventory, plugin_data):
2828

2929
for baremetal_port in ironic_ports_for_node(task.context, task.node.id):
3030
mac = baremetal_port.address.upper()
31-
name = interface_names.get(mac)
32-
LOG.info("Port %(mac)s bios_name=%(name)s", {"mac": mac, "name": name})
33-
if name:
34-
baremetal_port.extra["bios_name"] = name
35-
else:
36-
baremetal_port.extra.pop("bios_name", None)
37-
baremetal_port.save()
31+
required_bios_name = interface_names.get(mac)
32+
extra = baremetal_port.extra
33+
current_bios_name = extra.get("bios_name")
34+
35+
if current_bios_name != required_bios_name:
36+
LOG.debug(
37+
"Port %(mac)s updating bios_name from %(old)s to %(new)s",
38+
{"mac": mac, "old": current_bios_name, "new": required_bios_name}
39+
)
40+
41+
if required_bios_name:
42+
extra["bios_name"] = required_bios_name
43+
else:
44+
extra.pop("bios_name", None)
45+
46+
baremetal_port.extra = extra
47+
baremetal_port.save()

0 commit comments

Comments
 (0)