From f5c6ee6a70738e97e8c4a3ad9247afb61f20d0ec Mon Sep 17 00:00:00 2001 From: Alexander Olofsson <alexander.olofsson@liu.se> Date: Mon, 16 Jan 2023 16:04:51 +0100 Subject: [PATCH] Fix extension namespacing --- .../concerns/host_finder_extensions.rb | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb b/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb index d9be12b..20e6ffb 100644 --- a/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb +++ b/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb @@ -1,30 +1,28 @@ # frozen_string_literal: true -module ForemanUuidBoot - module HostFinderExtensions - def search - host = super - host ||= find_host_by_uuid unless token_from_params.present? +module HostFinderExtensions + def search + host = super + host ||= find_host_by_uuid unless token_from_params.present? - host - end + host + end - private + private - def find_host_by_uuid - return unless (uuid = query_params['uuid']) + def find_host_by_uuid + return unless (uuid = query_params['uuid']) - fact_name_id = FactName.where(name: 'uuid').map(&:id) - return unless fact_name_id.any? + fact_name_id = FactName.where(name: 'uuid').map(&:id) + return unless fact_name_id.any? - query = { fact_values: { fact_name_id: fact_name_id, value: uuid } } - hosts = Host.joins(:fact_values).where(query).order(:created_at) + query = { fact_values: { fact_name_id: fact_name_id, value: uuid } } + hosts = Host.joins(:fact_values).where(query).order(:created_at) - Rails.logger.warn("Multiple hosts found with #{uuid}, picking up the most recent") if hosts.count > 1 + Rails.logger.warn("Multiple hosts found with #{uuid}, picking up the most recent") if hosts.count > 1 - return unless hosts.present? + return unless hosts.present? - hosts.last.reload - end + hosts.last.reload end end -- GitLab