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

Ensure stored UUIDs are of correct format

parent 1edb5a26
No related branches found
No related tags found
No related merge requests found
Pipeline #129686 passed
......@@ -4,16 +4,19 @@ module ForemanUuidBoot
class UuidbootHostFacet < ApplicationRecord
include Facets::Base
UUID_REX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.freeze
def self.populate_fields_from_facts(host, parser, _type, _proxy)
uuid = parser.facts.dig('dmi', 'product', 'uuid') || parser.facts['uuid']
if uuid
if uuid && uuid =~ UUID_REX
facet = host.uuidboot_facet || host.build_uuidboot_facet
facet.uuid = uuid
facet.save if facet.changed? || !facet.persisted?
facet
else
host.uuidboot_facet&.destroy
host.uuidboot_facet = nil
nil
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