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

Initial commit

parents
No related branches found
Tags v0.1.0
No related merge requests found
Pipeline #87561 passed
/.bundle/
/vendor/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
/public/
/*.gem
---
include:
- project: ITI/ci-pipelines
file: '/foreman-module.yaml'
---
AllCops:
NewCops: enable
Style/Documentation:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Metrics/MethodLength:
Max: 15
source 'https://rubygems.org'
# Specify your gem's dependencies in foreman_vmware_advanced.gemspec
gemspec
This diff is collapsed.
# Foreman UUID Boot
Allows booting machines based off of machine UUID instead of - or in addition to - interface MAC
Example iPXE boot URLs;
`http://foreman.example.com/unattended/iPXE?uuid=${uuid}`
`http://template-proxy.example.com:8000/unattended/iPXE?mac=${netX/mac}&uuid=${uuid}`
## Installation
See the [Plugins install instructions, advanced installation from gems](https://theforeman.org/plugins/#2.3AdvancedInstallationfromGems) for information on how to install this plugins.
## Contributing
Bug reports and pull requests are welcome on the LiU GitLab at https://gitlab.liu.se/ITI/foreman_uuid_boot or on GitHub at https://github.com/ananace/foreman_uuid_boot
## License
The gem is available as open source under the terms of the [GPL-3.0 License](https://opensource.org/licenses/GPL-3.0).
Rakefile 0 → 100644
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList['test/**/*_test.rb']
end
task :default => :test
# frozen_string_literal: true
module ForemanUuidBoot
module HostFinderExtensions
def search
host = super
host ||= find_host_by_uuid unless token_from_params.present?
host
end
private
def find_host_by_uuid
return unless (uuid = query_params['uuid'])
fact_name_id = FactName.where(name: 'uuid').map(&:id)
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
return unless hosts.present?
hosts.last.reload
end
end
end
# frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'foreman_uuid_boot/version'
Gem::Specification.new do |spec|
spec.name = 'foreman_uuid_boot'
spec.version = ForemanUuidBoot::VERSION
spec.authors = ['Alexander Olofsson']
spec.email = ['alexander.olofsson@liu.se']
spec.summary = 'Allows booting based off of machine UUID'
spec.description = spec.summary
spec.homepage = 'https://github.com/ananace/foreman_uuid_boot'
spec.license = 'GPL-3.0'
spec.files = Dir['{app,lib}/**/*.{rake,rb}'] + %w[LICENSE.txt Rakefile README.md]
spec.metadata['rubygems_mfa_required'] = 'true'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-minitest'
spec.add_development_dependency 'rubocop-performance'
spec.add_development_dependency 'rubocop-rails'
end
# frozen_string_literal: true
require 'foreman_uuid_boot/engine'
module ForemanUuidBoot
end
# frozen_string_literal: true
module ForemanUuidBoot
class Engine < ::Rails::Engine
engine_name 'foreman_uuid_boot'
config.autoload_paths += Dir["#{config.root}/app/services/foreman/unattended_installation/concerns"]
initializer 'foreman_uuid_boot.register_plugin', before: :finisher_hook do |_app|
Foreman::Plugin.register :foreman_uuid_boot do
requires_foreman '>= 1.14'
end
end
config.to_prepare do
::Foreman::UnattendedInstallation::HostFinder.prepend ForemanUuidBoot::HostFinderExtensions
rescue StandardError => e
Rails.logger.warn "ForemanUuidBoot: skipping engine hook(#{e})"
end
end
end
# frozen_string_literal: true
module ForemanUuidBoot
VERSION = '0.1.0'
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