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
2 changes: 1 addition & 1 deletion components/ironic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ conf:
hooks: "ramdisk-error,validate-interfaces,architecture,pci-devices,validate-interfaces,parse-lldp,resource-class,update-baremetal-port"
redfish:
# Redfish inspection hooks run after inspecting out-of-band using the BMC:
inspection_hooks: "validate-interfaces,ports,port-bios-name,architecture,pci-devices"
inspection_hooks: "validate-interfaces,ports,port-bios-name,architecture,pci-devices,resource-class"
add_ports: "all"
# enable sensors and metrics for redfish metrics - https://docs.openstack.org/ironic/latest/admin/drivers/redfish/metrics.html
sensor_data:
Expand Down
7 changes: 6 additions & 1 deletion python/ironic-understack/ironic_understack/resource_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class ResourceClassHook(base.InspectionHook):

def __call__(self, task, inventory, plugin_data):
"""Update node resource_class with matched resource class."""
# clear the existing resource_class
task.node.resource_class = None

try:
memory_mb = inventory["memory"]["physical_mb"]
disk_size_gb = int(int(inventory["disks"][0]["size"]) / 10**9)
Expand Down Expand Up @@ -60,7 +63,6 @@ def __call__(self, task, inventory, plugin_data):
task.node.uuid,
)
task.node.resource_class = resource_class_name
task.node.save()
except (KeyError, ValueError, TypeError):
msg = (
f"Inventory has missing hardware information for node {task.node.uuid}."
Expand All @@ -73,6 +75,9 @@ def __call__(self, task, inventory, plugin_data):
msg = f"No matching resource class found for {task.node.uuid}"
LOG.error(msg)

# always save so that we clear it if we failed to find a match
task.node.save()

def classify(self, machine):
matcher = Matcher(device_types=DEVICE_TYPES)
match_result = matcher.match(machine)
Expand Down
Loading