foreman_rescue 3.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +2 -2
- data/app/controllers/foreman_rescue/hosts_controller.rb +10 -5
- data/app/helpers/concerns/foreman_rescue/hosts_helper_extensions.rb +9 -7
- data/app/models/concerns/foreman_rescue/host_extensions.rb +2 -0
- data/app/models/concerns/foreman_rescue/orchestration/tftp.rb +2 -0
- data/app/models/concerns/foreman_rescue/provisioning_template_extensions.rb +10 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20170901131321_add_rescue_mode_to_host.foreman_rescue.rb +2 -0
- data/db/migrate/20240506132712_migrate_rescue_settings_category_to_dsl.rb +13 -0
- data/db/seeds.d/103-provisioning_templates.rb +3 -1
- data/lib/foreman_rescue/engine.rb +36 -21
- data/lib/foreman_rescue/version.rb +3 -1
- data/lib/foreman_rescue.rb +2 -0
- data/lib/tasks/foreman_rescue_tasks.rake +2 -20
- data/locale/gemspec.rb +3 -1
- data/test/controllers/hosts_controller_test.rb +2 -0
- data/test/factories/host.rb +2 -0
- data/test/lib/tasks/seeds_test.rb +3 -1
- data/test/models/host_test.rb +2 -1
- data/test/models/provisioning_template_test.rb +26 -0
- data/test/test_plugin_helper.rb +2 -4
- data/test/unit/foreman_rescue/access_permissions_test.rb +18 -0
- metadata +23 -16
- data/app/models/setting/rescue.rb +0 -45
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: dd0bce1ad2fa35f301d40febfbeccede3ed3d5134ece9a75a27f6b468bb8e2ae
         | 
| 4 | 
            +
              data.tar.gz: f2d4236c22ae308055658f79811b2dd7b88b15b9669b353db942a6610131e7ae
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fe7c1775d102b27647d909ee0a0e1df46fcf3ea5dd4090fde64d793f03c44965f24a071e781973422579b576e15e838d881d2d57f4d2ef801616594a57d94deb
         | 
| 7 | 
            +
              data.tar.gz: 269e2a963a5d9030794832dff7f18541cbafe183c47495c2e6a9aef51ad31379ca8a5f2df0b4c1c48eab74465eca5a76429cdfac8ea04cbc4877d013ba6a638f
         | 
    
        data/README.md
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | @@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc| | |
| 20 20 | 
             
              rdoc.rdoc_files.include('lib/**/*.rb')
         | 
| 21 21 | 
             
            end
         | 
| 22 22 |  | 
| 23 | 
            -
            APP_RAKEFILE = File.expand_path(' | 
| 23 | 
            +
            APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
         | 
| 24 24 |  | 
| 25 25 | 
             
            Bundler::GemHelper.install_tasks
         | 
| 26 26 |  | 
| @@ -38,7 +38,7 @@ task default: :test | |
| 38 38 | 
             
            begin
         | 
| 39 39 | 
             
              require 'rubocop/rake_task'
         | 
| 40 40 | 
             
              RuboCop::RakeTask.new
         | 
| 41 | 
            -
            rescue  | 
| 41 | 
            +
            rescue StandardError
         | 
| 42 42 | 
             
              puts 'Rubocop not loaded.'
         | 
| 43 43 | 
             
            end
         | 
| 44 44 |  | 
| @@ -1,9 +1,12 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module ForemanRescue
         | 
| 2 4 | 
             
              class HostsController < ::HostsController
         | 
| 3 5 | 
             
                before_action :find_resource, :only => [:rescue, :set_rescue, :cancel_rescue]
         | 
| 4 6 | 
             
                define_action_permission ['rescue', 'set_rescue', 'cancel_rescue'], :rescue
         | 
| 5 7 |  | 
| 6 | 
            -
                def rescue | 
| 8 | 
            +
                def rescue
         | 
| 9 | 
            +
                end
         | 
| 7 10 |  | 
| 8 11 | 
             
                def set_rescue
         | 
| 9 12 | 
             
                  forward_url_options
         | 
| @@ -16,10 +19,10 @@ module ForemanRescue | |
| 16 19 | 
             
                                    _('Enabled %s for boot into rescue system on next boot, but failed to power cycle the host.')
         | 
| 17 20 | 
             
                                  end
         | 
| 18 21 | 
             
                        process_success :success_msg => message % @host, :success_redirect => :back
         | 
| 19 | 
            -
                      rescue StandardError =>  | 
| 22 | 
            +
                      rescue StandardError => e
         | 
| 20 23 | 
             
                        message = _('Failed to reboot %s.') % @host
         | 
| 21 24 | 
             
                        warning(message)
         | 
| 22 | 
            -
                        Foreman::Logging.exception(message,  | 
| 25 | 
            +
                        Foreman::Logging.exception(message, e)
         | 
| 23 26 | 
             
                        process_success :success_msg => _('Enabled %s for rescue system on next boot.') % @host, :success_redirect => :back
         | 
| 24 27 | 
             
                      end
         | 
| 25 28 | 
             
                    else
         | 
| @@ -35,8 +38,10 @@ module ForemanRescue | |
| 35 38 | 
             
                    process_success :success_msg => _('Canceled booting into rescue system for %s.') % @host.name, :success_redirect => :back
         | 
| 36 39 | 
             
                  else
         | 
| 37 40 | 
             
                    process_error :redirect => :back,
         | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 41 | 
            +
                      :error_msg => _('Failed to cancel booting into rescue system for %{hostname} with the following errors: %{errors}') % {
         | 
| 42 | 
            +
                        :hostname => @host.name,
         | 
| 43 | 
            +
                        :errors => @host.errors.full_messages.to_sentence,
         | 
| 44 | 
            +
                      }
         | 
| 40 45 | 
             
                  end
         | 
| 41 46 | 
             
                end
         | 
| 42 47 | 
             
              end
         | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module ForemanRescue
         | 
| 2 4 | 
             
              module HostsHelperExtensions
         | 
| 3 5 | 
             
                def host_title_actions(host)
         | 
| @@ -5,15 +7,15 @@ module ForemanRescue | |
| 5 7 | 
             
                    button_group(
         | 
| 6 8 | 
             
                      if host.rescue_mode?
         | 
| 7 9 | 
             
                        link_to_if_authorized(_('Cancel rescue'), hash_for_cancel_rescue_host_path(:id => host).merge(:auth_object => host, :permission => 'rescue_hosts'),
         | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 10 | 
            +
                          :disabled => host.can_be_rescued?,
         | 
| 11 | 
            +
                          :title => _('Cancel rescue system for this host.'),
         | 
| 12 | 
            +
                          :class => 'btn btn-default',
         | 
| 13 | 
            +
                          :method => :put)
         | 
| 12 14 | 
             
                      else
         | 
| 13 15 | 
             
                        link_to_if_authorized(_('Rescue'), hash_for_rescue_host_path(:id => host).merge(:auth_object => host, :permission => 'rescue_hosts'),
         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 16 | 
            +
                          :disabled => !host.can_be_rescued?,
         | 
| 17 | 
            +
                          :title => _('Activate rescue mode for this host.'),
         | 
| 18 | 
            +
                          :class => 'btn btn-default')
         | 
| 17 19 | 
             
                      end
         | 
| 18 20 | 
             
                    )
         | 
| 19 21 | 
             
                  )
         | 
| @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module ForemanRescue
         | 
| 4 | 
            +
              module ProvisioningTemplateExtensions
         | 
| 5 | 
            +
                def templates_by_kind(kind)
         | 
| 6 | 
            +
                  template_kind = TemplateKind.find_by(name: kind)
         | 
| 7 | 
            +
                  ProvisioningTemplate.where(:template_kind => template_kind).pluck(:name, :name).to_h
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
            end
         | 
    
        data/config/routes.rb
    CHANGED
    
    
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class MigrateRescueSettingsCategoryToDsl < ActiveRecord::Migration[6.0]
         | 
| 4 | 
            +
              class MigrationSettings < ApplicationRecord
         | 
| 5 | 
            +
                self.table_name = :settings
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              def up
         | 
| 9 | 
            +
                MigrationSettings.where(category: 'Setting::Rescue').update_all(category: 'Setting') if column_exists?(
         | 
| 10 | 
            +
                  :settings, :category
         | 
| 11 | 
            +
                )
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -1,6 +1,8 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            User.as_anonymous_admin do
         | 
| 2 4 | 
             
              templates = [
         | 
| 3 | 
            -
                { :name => 'Kickstart rescue PXELinux', :source => 'PXELinux/kickstart_rescue_pxelinux.erb', :template_kind => TemplateKind.find_by(:name => 'PXELinux') }
         | 
| 5 | 
            +
                { :name => 'Kickstart rescue PXELinux', :source => 'PXELinux/kickstart_rescue_pxelinux.erb', :template_kind => TemplateKind.find_by(:name => 'PXELinux') },
         | 
| 4 6 | 
             
              ]
         | 
| 5 7 |  | 
| 6 8 | 
             
              templates.each do |template|
         | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module ForemanRescue
         | 
| 2 4 | 
             
              class Engine < ::Rails::Engine
         | 
| 3 5 | 
             
                engine_name 'foreman_rescue'
         | 
| @@ -12,20 +14,34 @@ module ForemanRescue | |
| 12 14 | 
             
                  end
         | 
| 13 15 | 
             
                end
         | 
| 14 16 |  | 
| 15 | 
            -
                initializer ' | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
                    Setting.table_exists?
         | 
| 19 | 
            -
                  rescue StandardError
         | 
| 20 | 
            -
                    false
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
                    require_dependency File.expand_path('../../../app/models/setting/rescue.rb', __FILE__)
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                end
         | 
| 17 | 
            +
                initializer 'foreman_rescue.register_plugin', :before => :finisher_hook do |_app| # rubocop:disable Metrics/BlockLength
         | 
| 18 | 
            +
                  Foreman::Plugin.register :foreman_rescue do # rubocop:disable Metrics/BlockLength
         | 
| 19 | 
            +
                    requires_foreman '>= 3.9'
         | 
| 25 20 |  | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 21 | 
            +
                    settings do
         | 
| 22 | 
            +
                      category :rescue, N_('Rescue') do
         | 
| 23 | 
            +
                        setting('rescue_pxelinux_tftp_template',
         | 
| 24 | 
            +
                          type: :string,
         | 
| 25 | 
            +
                          default: 'Kickstart rescue PXELinux',
         | 
| 26 | 
            +
                          full_name: N_('PXELinux rescue template'),
         | 
| 27 | 
            +
                          description: N_('PXELinux template used when booting rescue system'),
         | 
| 28 | 
            +
                          collection: proc { ProvisioningTemplate.templates_by_kind('PXELinux') })
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                        setting('rescue_pxegrub_tftp_template',
         | 
| 31 | 
            +
                          type: :string,
         | 
| 32 | 
            +
                          default: '',
         | 
| 33 | 
            +
                          full_name: N_('PXEGrub rescue template'),
         | 
| 34 | 
            +
                          description: N_('PXEGrub template used when booting rescue system'),
         | 
| 35 | 
            +
                          collection: proc { ProvisioningTemplate.templates_by_kind('PXEGrub') })
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                        setting('rescue_pxegrub2_tftp_template',
         | 
| 38 | 
            +
                          type: :string,
         | 
| 39 | 
            +
                          default: '',
         | 
| 40 | 
            +
                          full_name: N_('PXEGrub2 rescue template'),
         | 
| 41 | 
            +
                          description: N_('PXEGrub2 template used when booting rescue system'),
         | 
| 42 | 
            +
                          collection: proc { ProvisioningTemplate.templates_by_kind('PXEGrub2') })
         | 
| 43 | 
            +
                      end
         | 
| 44 | 
            +
                    end
         | 
| 29 45 |  | 
| 30 46 | 
             
                    # Add permissions
         | 
| 31 47 | 
             
                    security_block :foreman_rescue do
         | 
| @@ -35,13 +51,12 @@ module ForemanRescue | |
| 35 51 | 
             
                end
         | 
| 36 52 |  | 
| 37 53 | 
             
                config.to_prepare do
         | 
| 38 | 
            -
                   | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
                  end
         | 
| 54 | 
            +
                  Host::Managed.prepend ForemanRescue::HostExtensions
         | 
| 55 | 
            +
                  HostsHelper.prepend ForemanRescue::HostsHelperExtensions
         | 
| 56 | 
            +
                  Nic::Managed.prepend ForemanRescue::Orchestration::TFTP
         | 
| 57 | 
            +
                  ProvisioningTemplate.singleton_class.prepend ForemanRescue::ProvisioningTemplateExtensions
         | 
| 58 | 
            +
                rescue StandardError => e
         | 
| 59 | 
            +
                  Rails.logger.warn "ForemanRescue: skipping engine hook (#{e})"
         | 
| 45 60 | 
             
                end
         | 
| 46 61 |  | 
| 47 62 | 
             
                rake_tasks do
         | 
| @@ -51,7 +66,7 @@ module ForemanRescue | |
| 51 66 | 
             
                end
         | 
| 52 67 |  | 
| 53 68 | 
             
                initializer 'foreman_rescue.register_gettext', after: :load_config_initializers do |_app|
         | 
| 54 | 
            -
                  locale_dir = File.join(File.expand_path(' | 
| 69 | 
            +
                  locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
         | 
| 55 70 | 
             
                  locale_domain = 'foreman_rescue'
         | 
| 56 71 | 
             
                  Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
         | 
| 57 72 | 
             
                end
         | 
    
        data/lib/foreman_rescue.rb
    CHANGED
    
    
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'rake/testtask'
         | 
| 2 4 |  | 
| 3 5 | 
             
            # Tests
         | 
| @@ -12,24 +14,4 @@ namespace :test do | |
| 12 14 | 
             
              end
         | 
| 13 15 | 
             
            end
         | 
| 14 16 |  | 
| 15 | 
            -
            namespace :foreman_rescue do
         | 
| 16 | 
            -
              task :rubocop do
         | 
| 17 | 
            -
                begin
         | 
| 18 | 
            -
                  require 'rubocop/rake_task'
         | 
| 19 | 
            -
                  RuboCop::RakeTask.new(:rubocop_foreman_rescue) do |task|
         | 
| 20 | 
            -
                    task.patterns = ["#{ForemanRescue::Engine.root}/app/**/*.rb",
         | 
| 21 | 
            -
                                     "#{ForemanRescue::Engine.root}/lib/**/*.rb",
         | 
| 22 | 
            -
                                     "#{ForemanRescue::Engine.root}/test/**/*.rb"]
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                rescue StandardError
         | 
| 25 | 
            -
                  puts 'Rubocop not loaded.'
         | 
| 26 | 
            -
                end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                Rake::Task['rubocop_foreman_rescue'].invoke
         | 
| 29 | 
            -
              end
         | 
| 30 | 
            -
            end
         | 
| 31 | 
            -
             | 
| 32 17 | 
             
            Rake::Task[:test].enhance ['test:foreman_rescue']
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            load 'tasks/jenkins.rake'
         | 
| 35 | 
            -
            Rake::Task['jenkins:unit'].enhance ['test:foreman_rescue', 'foreman_rescue:rubocop'] if Rake::Task.task_defined?(:'jenkins:unit')
         | 
    
        data/locale/gemspec.rb
    CHANGED
    
    
    
        data/test/factories/host.rb
    CHANGED
    
    
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'test_plugin_helper'
         | 
| 2 4 |  | 
| 3 5 | 
             
            module ForemanRescue
         | 
| @@ -27,7 +29,7 @@ module ForemanRescue | |
| 27 29 | 
             
                def seed
         | 
| 28 30 | 
             
                  User.current = FactoryBot.build(:user, :admin => true,
         | 
| 29 31 | 
             
                                                         :organizations => [], :locations => [])
         | 
| 30 | 
            -
                  load Rails.root.join('db | 
| 32 | 
            +
                  load Rails.root.join('db/seeds.rb')
         | 
| 31 33 | 
             
                end
         | 
| 32 34 | 
             
              end
         | 
| 33 35 | 
             
            end
         | 
    
        data/test/models/host_test.rb
    CHANGED
    
    
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'test_plugin_helper'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class ProvisioningHostTest < ActiveSupport::TestCase
         | 
| 6 | 
            +
              setup do
         | 
| 7 | 
            +
                User.current = FactoryBot.build(:user, :admin)
         | 
| 8 | 
            +
                disable_orchestration
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              context 'provisioning template query' do
         | 
| 12 | 
            +
                context 'with type PXELinux' do
         | 
| 13 | 
            +
                  let(:type) do
         | 
| 14 | 
            +
                    'PXELinux'
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  test 'should return templates' do
         | 
| 18 | 
            +
                    templates = ProvisioningTemplate.templates_by_kind(type)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                    assert_includes templates, 'PXE Default Menu'
         | 
| 21 | 
            +
                    assert_includes templates, 'PXELinux default local boot'
         | 
| 22 | 
            +
                    assert_includes templates, 'PXELinux global default'
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
    
        data/test/test_plugin_helper.rb
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            # This calls the main test_helper in Foreman-core
         | 
| 2 4 | 
             
            require 'test_helper'
         | 
| 3 5 | 
             
            require 'database_cleaner'
         | 
| @@ -9,10 +11,6 @@ FactoryBot.reload | |
| 9 11 | 
             
            # Foreman's setup doesn't handle cleaning up for Minitest::Spec
         | 
| 10 12 | 
             
            DatabaseCleaner.strategy = :transaction
         | 
| 11 13 |  | 
| 12 | 
            -
            def setup_settings
         | 
| 13 | 
            -
              Setting::Rescue.load_defaults
         | 
| 14 | 
            -
            end
         | 
| 15 | 
            -
             | 
| 16 14 | 
             
            module Minitest
         | 
| 17 15 | 
             
              class Spec
         | 
| 18 16 | 
             
                before :each do
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'test_plugin_helper'
         | 
| 4 | 
            +
            require 'unit/shared/access_permissions_test_base'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Permissions are added in AccessPermissions with lists of controllers and
         | 
| 7 | 
            +
            # actions that they enable access to.  For non-admin users, we need to test
         | 
| 8 | 
            +
            # that there are permissions available that cover every controller action, else
         | 
| 9 | 
            +
            # it can't be delegated and this will lead to parts of the application that
         | 
| 10 | 
            +
            # aren't functional for non-admin users.
         | 
| 11 | 
            +
            #
         | 
| 12 | 
            +
            # In particular, it's important that actions for AJAX requests are added to
         | 
| 13 | 
            +
            # an appropriate permission so views using those requests function.
         | 
| 14 | 
            +
            class AccessPermissionsTest < ActiveSupport::TestCase
         | 
| 15 | 
            +
              include AccessPermissionsTestBase
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              check_routes(ForemanRescue::Engine.routes, [])
         | 
| 18 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: foreman_rescue
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 4.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Timo Goebel
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2024-05-17 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rdoc
         | 
| @@ -25,19 +25,19 @@ dependencies: | |
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: '0'
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            -
              name: rubocop
         | 
| 28 | 
            +
              name: theforeman-rubocop
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 | 
            -
                - -  | 
| 31 | 
            +
                - - "~>"
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: 0. | 
| 33 | 
            +
                    version: 0.1.2
         | 
| 34 34 | 
             
              type: :development
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 | 
            -
                - -  | 
| 38 | 
            +
                - - "~>"
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: 0. | 
| 40 | 
            +
                    version: 0.1.2
         | 
| 41 41 | 
             
            description: Foreman Plugin to provide the ability to boot a host into a rescue system.
         | 
| 42 42 | 
             
            email:
         | 
| 43 43 | 
             
            - timo.goebel@dm.de
         | 
| @@ -52,11 +52,12 @@ files: | |
| 52 52 | 
             
            - app/helpers/concerns/foreman_rescue/hosts_helper_extensions.rb
         | 
| 53 53 | 
             
            - app/models/concerns/foreman_rescue/host_extensions.rb
         | 
| 54 54 | 
             
            - app/models/concerns/foreman_rescue/orchestration/tftp.rb
         | 
| 55 | 
            -
            - app/models/ | 
| 55 | 
            +
            - app/models/concerns/foreman_rescue/provisioning_template_extensions.rb
         | 
| 56 56 | 
             
            - app/views/foreman/unattended/provisioning_templates/PXELinux/kickstart_rescue_pxelinux.erb
         | 
| 57 57 | 
             
            - app/views/foreman_rescue/hosts/rescue.html.erb
         | 
| 58 58 | 
             
            - config/routes.rb
         | 
| 59 59 | 
             
            - db/migrate/20170901131321_add_rescue_mode_to_host.foreman_rescue.rb
         | 
| 60 | 
            +
            - db/migrate/20240506132712_migrate_rescue_settings_category_to_dsl.rb
         | 
| 60 61 | 
             
            - db/seeds.d/103-provisioning_templates.rb
         | 
| 61 62 | 
             
            - lib/foreman_rescue.rb
         | 
| 62 63 | 
             
            - lib/foreman_rescue/engine.rb
         | 
| @@ -70,12 +71,14 @@ files: | |
| 70 71 | 
             
            - test/factories/host.rb
         | 
| 71 72 | 
             
            - test/lib/tasks/seeds_test.rb
         | 
| 72 73 | 
             
            - test/models/host_test.rb
         | 
| 74 | 
            +
            - test/models/provisioning_template_test.rb
         | 
| 73 75 | 
             
            - test/test_plugin_helper.rb
         | 
| 76 | 
            +
            - test/unit/foreman_rescue/access_permissions_test.rb
         | 
| 74 77 | 
             
            homepage: https://github.com/dm-drogeriemarkt/foreman_rescue
         | 
| 75 78 | 
             
            licenses:
         | 
| 76 79 | 
             
            - GPL-3.0
         | 
| 77 80 | 
             
            metadata: {}
         | 
| 78 | 
            -
            post_install_message: | 
| 81 | 
            +
            post_install_message:
         | 
| 79 82 | 
             
            rdoc_options: []
         | 
| 80 83 | 
             
            require_paths:
         | 
| 81 84 | 
             
            - lib
         | 
| @@ -83,21 +86,25 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 83 86 | 
             
              requirements:
         | 
| 84 87 | 
             
              - - ">="
         | 
| 85 88 | 
             
                - !ruby/object:Gem::Version
         | 
| 86 | 
            -
                  version: ' | 
| 89 | 
            +
                  version: '2.7'
         | 
| 90 | 
            +
              - - "<"
         | 
| 91 | 
            +
                - !ruby/object:Gem::Version
         | 
| 92 | 
            +
                  version: '4'
         | 
| 87 93 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 88 94 | 
             
              requirements:
         | 
| 89 95 | 
             
              - - ">="
         | 
| 90 96 | 
             
                - !ruby/object:Gem::Version
         | 
| 91 97 | 
             
                  version: '0'
         | 
| 92 98 | 
             
            requirements: []
         | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
            signing_key: 
         | 
| 99 | 
            +
            rubygems_version: 3.4.1
         | 
| 100 | 
            +
            signing_key:
         | 
| 96 101 | 
             
            specification_version: 4
         | 
| 97 102 | 
             
            summary: Provides the ability to boot a host into a rescue system.
         | 
| 98 103 | 
             
            test_files:
         | 
| 99 | 
            -
            - test/ | 
| 104 | 
            +
            - test/controllers/hosts_controller_test.rb
         | 
| 100 105 | 
             
            - test/factories/host.rb
         | 
| 101 106 | 
             
            - test/lib/tasks/seeds_test.rb
         | 
| 107 | 
            +
            - test/models/host_test.rb
         | 
| 108 | 
            +
            - test/models/provisioning_template_test.rb
         | 
| 102 109 | 
             
            - test/test_plugin_helper.rb
         | 
| 103 | 
            -
            - test/ | 
| 110 | 
            +
            - test/unit/foreman_rescue/access_permissions_test.rb
         | 
| @@ -1,45 +0,0 @@ | |
| 1 | 
            -
            class Setting
         | 
| 2 | 
            -
              class Rescue < ::Setting
         | 
| 3 | 
            -
                BLANK_ATTRS.concat ['rescue_pxegrub_tftp_template', 'rescue_pxegrub2_tftp_template']
         | 
| 4 | 
            -
             | 
| 5 | 
            -
                def self.default_settings
         | 
| 6 | 
            -
                  [
         | 
| 7 | 
            -
                    set('rescue_pxelinux_tftp_template',
         | 
| 8 | 
            -
                        N_('PXELinux template used when booting rescue system'),
         | 
| 9 | 
            -
                        'Kickstart rescue PXELinux', N_('PXELinux rescue template'), nil,
         | 
| 10 | 
            -
                        :collection => proc { Setting::Rescue.templates('PXELinux') }),
         | 
| 11 | 
            -
                    set('rescue_pxegrub_tftp_template',
         | 
| 12 | 
            -
                        N_('PXEGrub template used when booting rescue system'),
         | 
| 13 | 
            -
                        '', N_('PXEGrub rescue template'), nil,
         | 
| 14 | 
            -
                        :collection => proc { Setting::Rescue.templates('PXEGrub') }),
         | 
| 15 | 
            -
                    set('rescue_pxegrub2_tftp_template',
         | 
| 16 | 
            -
                        N_('PXEGrub2 template used when booting rescue system'),
         | 
| 17 | 
            -
                        '', N_('PXEGrub2 rescue template'), nil,
         | 
| 18 | 
            -
                        :collection => proc { Setting::Rescue.templates('PXEGrub2') })
         | 
| 19 | 
            -
                  ]
         | 
| 20 | 
            -
                end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                def self.load_defaults
         | 
| 23 | 
            -
                  # Check the table exists
         | 
| 24 | 
            -
                  return unless super
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  transaction do
         | 
| 27 | 
            -
                    default_settings.each { |s| create! s.update(:category => 'Setting::Rescue') }
         | 
| 28 | 
            -
                  end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                  true
         | 
| 31 | 
            -
                end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                def self.templates(kind)
         | 
| 34 | 
            -
                  template_kind = TemplateKind.find_by(name: kind)
         | 
| 35 | 
            -
                  templates = ProvisioningTemplate.where(:template_kind => template_kind)
         | 
| 36 | 
            -
                  templates.each_with_object({}) do |template, hsh|
         | 
| 37 | 
            -
                    hsh[template.name] = template.name
         | 
| 38 | 
            -
                  end
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                def self.humanized_category
         | 
| 42 | 
            -
                  N_('Rescue System')
         | 
| 43 | 
            -
                end
         | 
| 44 | 
            -
              end
         | 
| 45 | 
            -
            end
         |