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

Add support for foreman_discovery

parent 57f7d2b9
No related branches found
No related tags found
No related merge requests found
# frozen_string_literal: true
module ForemanUuidBoot
module HostDiscoveredExtensions
def populate_fields_from_facts(parser, type, source_proxy)
super
populate_facet_fields(parser, type, source_proxy)
end
end
end
......@@ -4,6 +4,7 @@ module ForemanUuidBoot
class Engine < ::Rails::Engine
engine_name 'foreman_uuid_boot'
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
config.autoload_paths += Dir["#{config.root}/app/services/foreman/unattended_installation/concerns"]
initializer 'foreman_uuid_boot.load_app_instance_data' do |app|
......@@ -17,13 +18,27 @@ module ForemanUuidBoot
requires_foreman '>= 2.5'
register_facet ForemanUuidBoot::UuidbootHostFacet, :uuidboot_facet do
set_dependent_action :destroy
configure_host do
set_dependent_action :destroy
end
end
end
end
config.to_prepare do
::Foreman::UnattendedInstallation::HostFinder.prepend ForemanUuidBoot::HostFinderExtensions
# Slight hack for foreman_discovery - to store UUID for provision
begin
# Ensure that Host::Discovered applies host facets
unless ::Host::Discovered.include? Facets::ModelExtensionsBase
::Host::Discovered.include SelectiveClone
::Host::Discovered.include Facets::ManagedHostExtensions
::Host::Discovered.prepend ForemanUuidBoot::HostDiscoveredExtensions
end
rescue NameError => e
Rails.logger.warn "ForemanUuidBoot: Discovery not installed(#{e}), skipping discovery extensions"
end
rescue StandardError => e
Rails.logger.warn "ForemanUuidBoot: skipping engine hook(#{e})"
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