From fcf86bc0c3203b236053c027adbd7bcbbd7c592c Mon Sep 17 00:00:00 2001 From: Alexander Olofsson <alexander.olofsson@liu.se> Date: Mon, 27 Nov 2023 16:08:56 +0100 Subject: [PATCH] Handle platforms without UUIDs --- app/models/foreman_uuid_boot/uuidboot_host_facet.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/foreman_uuid_boot/uuidboot_host_facet.rb b/app/models/foreman_uuid_boot/uuidboot_host_facet.rb index 202a003..79756b7 100644 --- a/app/models/foreman_uuid_boot/uuidboot_host_facet.rb +++ b/app/models/foreman_uuid_boot/uuidboot_host_facet.rb @@ -7,7 +7,8 @@ module ForemanUuidBoot def self.populate_fields_from_facts(host, parser, _type, _proxy) facet = host.uuidboot_facet || host.build_uuidboot_facet facet.uuid = parser.facts.dig('dmi', 'product', 'uuid') || parser.facts['uuid'] - facet.save if facet.changed? + facet.save if facet.uuid && facet.changed? + facet.destroy if !facet.uuid && facet.persisted? end end end -- GitLab