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

Fix extension namespacing

parent d0b4e274
No related branches found
No related tags found
No related merge requests found
Pipeline #87566 passed
# 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
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