Skip to content
Snippets Groups Projects
Verified Commit a4e97544 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Restructure UUID facet creation

parent 63d45f07
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,17 @@ module ForemanUuidBoot
include Facets::Base
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.uuid && facet.changed?
facet.destroy if !facet.uuid && facet.persisted?
uuid = parser.facts.dig('dmi', 'product', 'uuid') || parser.facts['uuid']
if uuid
facet = host.uuidboot_facet || host.build_uuidboot_facet
facet.uuid = uuid
facet.save if facet.changed? || !facet.persisted?
facet
else
host.uuidboot_facet&.destroy
nil
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment