foreman_bootdisk 14.0.0 → 17.0.2
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/AUTHORS +30 -0
- data/README.md +25 -0
- data/app/controllers/foreman_bootdisk/api/v2/disks_controller.rb +5 -7
- data/app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb +9 -4
- data/app/controllers/foreman_bootdisk/disks_controller.rb +11 -10
- data/app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb +14 -14
- data/app/lib/foreman_bootdisk/scope/bootdisk.rb +4 -1
- data/app/lib/foreman_bootdisk/scope/full_host_bootdisk_efi.rb +15 -0
- data/app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb +10 -1
- data/app/models/concerns/foreman_bootdisk/host_ext.rb +7 -10
- data/app/models/concerns/foreman_bootdisk/orchestration/compute.rb +28 -19
- data/app/models/setting/bootdisk.rb +16 -19
- data/app/services/foreman_bootdisk/iso_generator.rb +129 -52
- data/app/services/foreman_bootdisk/renderer.rb +36 -18
- data/app/views/foreman_bootdisk/generic_efi_host.erb +64 -0
- data/app/views/foreman_bootdisk/generic_static_host.erb +34 -0
- data/app/views/foreman_bootdisk/host.erb +27 -11
- data/db/seeds.d/50-bootdisk_templates.rb +15 -31
- data/lib/foreman_bootdisk/engine.rb +6 -6
- data/lib/foreman_bootdisk/version.rb +1 -1
- data/lib/tasks/bootdisk.rake +10 -6
- data/locale/action_names.rb +5 -0
- data/locale/ca/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ca/foreman_bootdisk.po +65 -16
- data/locale/de/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/de/foreman_bootdisk.po +74 -23
- data/locale/en/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en/foreman_bootdisk.po +58 -10
- data/locale/en_GB/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en_GB/foreman_bootdisk.po +65 -17
- data/locale/es/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/es/foreman_bootdisk.po +82 -34
- data/locale/foreman_bootdisk.pot +124 -48
- data/locale/fr/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/fr/foreman_bootdisk.po +65 -17
- data/locale/it/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/it/foreman_bootdisk.po +63 -15
- data/locale/ja/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ja/foreman_bootdisk.po +64 -16
- data/locale/ko/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ko/foreman_bootdisk.po +63 -15
- data/locale/pt_BR/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/pt_BR/foreman_bootdisk.po +76 -27
- data/locale/ru/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ru/foreman_bootdisk.po +63 -15
- data/locale/sv_SE/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/sv_SE/foreman_bootdisk.po +61 -13
- data/locale/zh_CN/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_CN/foreman_bootdisk.po +79 -31
- data/locale/zh_TW/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_TW/foreman_bootdisk.po +63 -15
- data/release-gem +84 -0
- data/test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb +51 -17
- data/test/functional/foreman_bootdisk/api/v2/subnet_disks_controller_test.rb +23 -10
- data/test/functional/foreman_bootdisk/disks_controller_test.rb +65 -25
- data/test/test_plugin_helper.rb +23 -3
- data/test/unit/concerns/host_test.rb +12 -1
- data/test/unit/concerns/orchestration/compute_test.rb +32 -13
- data/test/unit/foreman_bootdisk/renderer_test.rb +1 -1
- data/test/unit/iso_generator_test.rb +16 -7
- metadata +65 -4
| @@ -5,33 +5,67 @@ require 'test_plugin_helper' | |
| 5 5 | 
             
            class ForemanBootdisk::Api::V2::DisksControllerTest < ActionController::TestCase
         | 
| 6 6 | 
             
              include ForemanBootdiskTestHelper
         | 
| 7 7 | 
             
              setup :setup_bootdisk
         | 
| 8 | 
            +
              setup :setup_referer
         | 
| 9 | 
            +
              setup :setup_org_loc
         | 
| 8 10 |  | 
| 9 | 
            -
               | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 11 | 
            +
              def perform_generic_generate
         | 
| 12 | 
            +
                tmp = create_tempfile
         | 
| 13 | 
            +
                ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
         | 
| 12 14 | 
             
                get :generic
         | 
| 13 15 | 
             
                assert_response :success
         | 
| 14 | 
            -
             | 
| 16 | 
            +
              ensure
         | 
| 17 | 
            +
                tmp.unlink
         | 
| 15 18 | 
             
              end
         | 
| 16 19 |  | 
| 17 | 
            -
               | 
| 18 | 
            -
                 | 
| 19 | 
            -
                 | 
| 20 | 
            +
              def perform_host_generate
         | 
| 21 | 
            +
                tmp = create_tempfile
         | 
| 22 | 
            +
                ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
         | 
| 23 | 
            +
                get :host, params: { id: @host.name }
         | 
| 24 | 
            +
                assert_response :success
         | 
| 25 | 
            +
              ensure
         | 
| 26 | 
            +
                tmp.unlink
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              def perform_full_host_generate
         | 
| 30 | 
            +
                tmp = create_tempfile
         | 
| 31 | 
            +
                ForemanBootdisk::ISOGenerator.expects(:generate_full_host).yields(create_tempfile.path)
         | 
| 32 | 
            +
                get :host, params: { id: @host.name, full: true }
         | 
| 33 | 
            +
                assert_response :success
         | 
| 34 | 
            +
              ensure
         | 
| 35 | 
            +
                tmp.unlink
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              describe '#generic with TFTP' do
         | 
| 39 | 
            +
                setup :setup_subnet_with_tftp
         | 
| 40 | 
            +
                setup :setup_host
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                test 'should generate generic image' do
         | 
| 43 | 
            +
                  perform_generic_generate
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                test 'should generate host image' do
         | 
| 47 | 
            +
                  perform_host_generate
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                test 'should generate full host image' do
         | 
| 51 | 
            +
                  perform_full_host_generate
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              describe '#subnet_host with TFTP and HTTPBOOT' do
         | 
| 56 | 
            +
                setup :setup_subnet_with_tftp_httpboot_template
         | 
| 57 | 
            +
                setup :setup_host
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                test 'should generate generic image' do
         | 
| 60 | 
            +
                  perform_generic_generate
         | 
| 61 | 
            +
                end
         | 
| 20 62 |  | 
| 21 63 | 
             
                test 'should generate host image' do
         | 
| 22 | 
            -
                   | 
| 23 | 
            -
                  @controller.expects(:read_file).with('temp ISO').returns('ISO image')
         | 
| 24 | 
            -
                  get :host, params: { id: @host.name }
         | 
| 25 | 
            -
                  assert_response :success
         | 
| 26 | 
            -
                  assert_equal 'ISO image', @response.body
         | 
| 64 | 
            +
                  perform_host_generate
         | 
| 27 65 | 
             
                end
         | 
| 28 66 |  | 
| 29 67 | 
             
                test 'should generate full host image' do
         | 
| 30 | 
            -
                   | 
| 31 | 
            -
                  @controller.expects(:read_file).with('temp ISO').returns('ISO image')
         | 
| 32 | 
            -
                  get :host, params: { id: @host.name, full: true }
         | 
| 33 | 
            -
                  assert_response :success
         | 
| 34 | 
            -
                  assert_equal 'ISO image', @response.body
         | 
| 68 | 
            +
                  perform_full_host_generate
         | 
| 35 69 | 
             
                end
         | 
| 36 70 | 
             
              end
         | 
| 37 71 |  | 
| @@ -5,20 +5,33 @@ require 'test_plugin_helper' | |
| 5 5 | 
             
            class ForemanBootdisk::Api::V2::SubnetDisksControllerTest < ActionController::TestCase
         | 
| 6 6 | 
             
              include ForemanBootdiskTestHelper
         | 
| 7 7 | 
             
              setup :setup_bootdisk
         | 
| 8 | 
            +
              setup :setup_referer
         | 
| 9 | 
            +
              setup :setup_org_loc
         | 
| 8 10 |  | 
| 9 | 
            -
               | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 12 | 
            -
                 | 
| 11 | 
            +
              def perform_subnet_generate
         | 
| 12 | 
            +
                tmp = create_tempfile
         | 
| 13 | 
            +
                ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
         | 
| 14 | 
            +
                get :subnet, params: { id: @host.subnet.id }
         | 
| 15 | 
            +
                assert_response :success
         | 
| 16 | 
            +
              ensure
         | 
| 17 | 
            +
                tmp.unlink
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              describe '#subnet_host with TFTP' do
         | 
| 21 | 
            +
                setup :setup_subnet_with_tftp
         | 
| 22 | 
            +
                setup :setup_host
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                test 'should generate subnet generic host image' do
         | 
| 25 | 
            +
                  perform_subnet_generate
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              describe '#subnet_host with TFTP and HTTPBOOT' do
         | 
| 30 | 
            +
                setup :setup_subnet_with_tftp_httpboot_template
         | 
| 13 31 | 
             
                setup :setup_host
         | 
| 14 32 |  | 
| 15 33 | 
             
                test 'should generate subnet generic host image' do
         | 
| 16 | 
            -
                   | 
| 17 | 
            -
                  ForemanBootdisk::Renderer.any_instance.stubs(:bootdisk_chain_url).yields('http://smart-proxy.lan')
         | 
| 18 | 
            -
                  File.expects(:read).with('temp ISO').returns('ISO image')
         | 
| 19 | 
            -
                  get :subnet, params: { id: @host.subnet.id }
         | 
| 20 | 
            -
                  assert_response :success
         | 
| 21 | 
            -
                  assert_equal 'ISO image', @response.body
         | 
| 34 | 
            +
                  perform_subnet_generate
         | 
| 22 35 | 
             
                end
         | 
| 23 36 | 
             
              end
         | 
| 24 37 | 
             
            end
         | 
| @@ -5,45 +5,85 @@ require 'test_plugin_helper' | |
| 5 5 | 
             
            class ForemanBootdisk::DisksControllerTest < ActionController::TestCase
         | 
| 6 6 | 
             
              include ForemanBootdiskTestHelper
         | 
| 7 7 | 
             
              setup :setup_bootdisk
         | 
| 8 | 
            +
              setup :setup_referer
         | 
| 9 | 
            +
              setup :setup_org_loc
         | 
| 8 10 |  | 
| 9 | 
            -
               | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 11 | 
            +
              def perform_generic_generate
         | 
| 12 | 
            +
                tmp = create_tempfile
         | 
| 13 | 
            +
                ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
         | 
| 12 14 | 
             
                get :generic, session: set_session_user
         | 
| 13 15 | 
             
                assert_response :success
         | 
| 14 | 
            -
             | 
| 16 | 
            +
              ensure
         | 
| 17 | 
            +
                tmp.unlink
         | 
| 15 18 | 
             
              end
         | 
| 16 19 |  | 
| 17 | 
            -
               | 
| 18 | 
            -
                 | 
| 19 | 
            -
                 | 
| 20 | 
            -
                 | 
| 20 | 
            +
              def perform_host_generate
         | 
| 21 | 
            +
                tmp = create_tempfile
         | 
| 22 | 
            +
                ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
         | 
| 23 | 
            +
                get :host, params: { id: @host.name }, session: set_session_user
         | 
| 24 | 
            +
                assert_response :success
         | 
| 25 | 
            +
              ensure
         | 
| 26 | 
            +
                tmp.unlink
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              def perform_full_host_generate
         | 
| 30 | 
            +
                tmp = create_tempfile
         | 
| 31 | 
            +
                ForemanBootdisk::ISOGenerator.expects(:generate_full_host).yields(create_tempfile.path)
         | 
| 32 | 
            +
                get :full_host, params: { id: @host.name }, session: set_session_user
         | 
| 33 | 
            +
                assert_response :success
         | 
| 34 | 
            +
              ensure
         | 
| 35 | 
            +
                tmp.unlink
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              def perform_subnet_generate
         | 
| 39 | 
            +
                tmp = create_tempfile
         | 
| 40 | 
            +
                ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
         | 
| 41 | 
            +
                get :subnet, params: { id: @host.name }, session: set_session_user
         | 
| 42 | 
            +
                assert_empty flash[:error]
         | 
| 43 | 
            +
                assert_response :success
         | 
| 44 | 
            +
              ensure
         | 
| 45 | 
            +
                tmp.unlink
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              describe '#generic with TFTP' do
         | 
| 49 | 
            +
                setup :setup_subnet_with_tftp
         | 
| 21 50 | 
             
                setup :setup_host
         | 
| 22 51 |  | 
| 52 | 
            +
                test 'should generate generic image' do
         | 
| 53 | 
            +
                  perform_generic_generate
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 23 56 | 
             
                test 'should generate host image' do
         | 
| 24 | 
            -
                   | 
| 25 | 
            -
                  @controller.expects(:read_file).with('temp ISO').returns('ISO image')
         | 
| 26 | 
            -
                  get :host, params: { id: @host.name }, session: set_session_user
         | 
| 27 | 
            -
                  assert_response :success
         | 
| 28 | 
            -
                  assert_equal 'ISO image', @response.body
         | 
| 57 | 
            +
                  perform_host_generate
         | 
| 29 58 | 
             
                end
         | 
| 30 59 |  | 
| 31 60 | 
             
                test 'should generate full host image' do
         | 
| 32 | 
            -
                   | 
| 33 | 
            -
                  @controller.expects(:read_file).with('temp ISO').returns('ISO image')
         | 
| 34 | 
            -
                  get :full_host, params: { id: @host.name }, session: set_session_user
         | 
| 35 | 
            -
                  assert_response :success
         | 
| 36 | 
            -
                  assert_equal 'ISO image', @response.body
         | 
| 61 | 
            +
                  perform_full_host_generate
         | 
| 37 62 | 
             
                end
         | 
| 38 63 |  | 
| 39 64 | 
             
                test 'should generate subnet image' do
         | 
| 40 | 
            -
                   | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 65 | 
            +
                  perform_subnet_generate
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              describe '#subnet_host with TFTP and HTTPBOOT' do
         | 
| 70 | 
            +
                setup :setup_subnet_with_tftp_httpboot_template
         | 
| 71 | 
            +
                setup :setup_host
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                test 'should generate generic image' do
         | 
| 74 | 
            +
                  perform_generic_generate
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                test 'should generate host image' do
         | 
| 78 | 
            +
                  perform_host_generate
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                test 'should generate full host image' do
         | 
| 82 | 
            +
                  perform_full_host_generate
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                test 'should generate subnet image' do
         | 
| 86 | 
            +
                  perform_subnet_generate
         | 
| 47 87 | 
             
                end
         | 
| 48 88 | 
             
              end
         | 
| 49 89 |  | 
    
        data/test/test_plugin_helper.rb
    CHANGED
    
    | @@ -1,17 +1,27 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'test_helper'
         | 
| 4 | 
            +
            require 'webmock/minitest'
         | 
| 5 | 
            +
            require 'webmock'
         | 
| 4 6 |  | 
| 5 7 | 
             
            module ForemanBootdiskTestHelper
         | 
| 8 | 
            +
              def create_tempfile
         | 
| 9 | 
            +
                file = Tempfile.new('bootdisk-test', '/tmp')
         | 
| 10 | 
            +
                file.close
         | 
| 11 | 
            +
                file
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 6 14 | 
             
              def setup_bootdisk
         | 
| 15 | 
            +
                ForemanBootdisk::Scope::Bootdisk.any_instance.stubs(:bootdisk_chain_url).returns('http://smart-proxy.example.com/unattended/iPXE?mac=')
         | 
| 7 16 | 
             
                setup_routes
         | 
| 8 17 | 
             
                setup_settings
         | 
| 9 18 | 
             
                setup_templates
         | 
| 10 19 | 
             
              end
         | 
| 11 20 |  | 
| 21 | 
            +
              # TODO remove me
         | 
| 12 22 | 
             
              def setup_host_env
         | 
| 13 23 | 
             
                setup_org_loc
         | 
| 14 | 
            -
                 | 
| 24 | 
            +
                setup_subnet_with_tftp
         | 
| 15 25 | 
             
                setup_host
         | 
| 16 26 | 
             
              end
         | 
| 17 27 |  | 
| @@ -37,7 +47,17 @@ module ForemanBootdiskTestHelper | |
| 37 47 | 
             
                @loc = FactoryBot.create(:location)
         | 
| 38 48 | 
             
              end
         | 
| 39 49 |  | 
| 40 | 
            -
              def  | 
| 50 | 
            +
              def setup_subnet_with_tftp_httpboot_template
         | 
| 51 | 
            +
                ProxyAPI::V2::Features.any_instance.stubs(:features).returns(:httpboot => { :settings => { :https_port => 1234 }, :state => 'running' }, :templates => {}, :tftp => {})
         | 
| 52 | 
            +
                SmartProxy.any_instance.stubs(:httpboot_http_port).returns('8888')
         | 
| 53 | 
            +
                SmartProxy.any_instance.stubs(:httpboot_https_port).returns('9999')
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                proxy = FactoryBot.create(:smart_proxy, features: [FactoryBot.create(:tftp_feature), FactoryBot.create(:feature, :templates), FactoryBot.create(:feature, :httpboot)])
         | 
| 56 | 
            +
                proxy.reload
         | 
| 57 | 
            +
                setup_subnet_no_tftp.update! tftp: proxy, httpboot: proxy, template: proxy
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              def setup_subnet_with_tftp
         | 
| 41 61 | 
             
                tftp_proxy = FactoryBot.create(:smart_proxy, features: [FactoryBot.create(:tftp_feature)])
         | 
| 42 62 | 
             
                setup_subnet_no_tftp.update! tftp: tftp_proxy
         | 
| 43 63 | 
             
              end
         | 
| @@ -47,6 +67,6 @@ module ForemanBootdiskTestHelper | |
| 47 67 | 
             
              end
         | 
| 48 68 |  | 
| 49 69 | 
             
              def setup_host
         | 
| 50 | 
            -
                @host = FactoryBot.create(:host, :managed, subnet: @subnet, ip: @subnet.network.sub(/0$/, '4'), organization: @org, location: @loc)
         | 
| 70 | 
            +
                @host = FactoryBot.create(:host, :managed, subnet: @subnet, ip: @subnet.network.sub(/0$/, '4'), organization: @org, location: @loc, build: true)
         | 
| 51 71 | 
             
              end
         | 
| 52 72 | 
             
            end
         | 
| @@ -36,7 +36,7 @@ module ForemanBootdisk | |
| 36 36 | 
             
                test 'host should not have bootdisk' do
         | 
| 37 37 | 
             
                  if unattended?
         | 
| 38 38 | 
             
                    h = FactoryBot.create(:host)
         | 
| 39 | 
            -
                     | 
| 39 | 
            +
                    assert_not(h.bootdisk?)
         | 
| 40 40 | 
             
                  end
         | 
| 41 41 | 
             
                end
         | 
| 42 42 |  | 
| @@ -69,5 +69,16 @@ module ForemanBootdisk | |
| 69 69 | 
             
                    assert host.bootdisk_downloadable?
         | 
| 70 70 | 
             
                  end
         | 
| 71 71 | 
             
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                context '#bootdisk_build?' do
         | 
| 74 | 
            +
                  test 'should be false for hosts without bootdisk' do
         | 
| 75 | 
            +
                    host = FactoryBot.create(:host)
         | 
| 76 | 
            +
                    assert_not host.bootdisk_build?
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  test 'should be available in safe mode' do
         | 
| 80 | 
            +
                    assert Host::Managed::Jail.allowed?(:bootdisk_build?)
         | 
| 81 | 
            +
                  end
         | 
| 82 | 
            +
                end
         | 
| 72 83 | 
             
              end
         | 
| 73 84 | 
             
            end
         | 
| @@ -22,29 +22,48 @@ module ForemanBootdisk | |
| 22 22 | 
             
                  @host.send(:setAttachIsoImage)
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 | 
            -
                test 'provisioning a host with provision method bootdisk should  | 
| 25 | 
            +
                test 'provisioning a host with provision method bootdisk should detach iso' do
         | 
| 26 | 
            +
                  @cr.expects(:iso_detach)
         | 
| 27 | 
            +
                  @host.send(:setDetachIsoImage)
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                test 'provisioning a new host with provision method bootdisk should queue bootdisk tasks' do
         | 
| 26 31 | 
             
                  @host.stubs(:compute?).returns(true)
         | 
| 32 | 
            +
                  @host.stubs(:build?).returns(true)
         | 
| 27 33 | 
             
                  @host.send(:queue_bootdisk_compute)
         | 
| 28 34 | 
             
                  tasks = @host.queue.all.map(&:name)
         | 
| 29 35 | 
             
                  assert_includes tasks, "Generating ISO image for #{@host.name}"
         | 
| 30 36 | 
             
                  assert_includes tasks, "Upload ISO image to datastore for #{@host.name}"
         | 
| 31 37 | 
             
                  assert_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
         | 
| 38 | 
            +
                  assert_not_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
         | 
| 32 39 | 
             
                end
         | 
| 33 40 |  | 
| 34 | 
            -
                test 'should  | 
| 35 | 
            -
                  @host. | 
| 36 | 
            -
                   | 
| 37 | 
            -
                   | 
| 38 | 
            -
                   | 
| 41 | 
            +
                test 'rebuilding a host with provision method bootdisk should queue bootdisk tasks' do
         | 
| 42 | 
            +
                  @host.stubs(:compute?).returns(true)
         | 
| 43 | 
            +
                  old = stub()
         | 
| 44 | 
            +
                  old.stubs(:build?).returns(false)
         | 
| 45 | 
            +
                  @host.stubs(:old).returns(old)
         | 
| 46 | 
            +
                  @host.stubs(:build?).returns(true)
         | 
| 47 | 
            +
                  @host.send(:queue_bootdisk_compute)
         | 
| 48 | 
            +
                  tasks = @host.queue.all.map(&:name)
         | 
| 49 | 
            +
                  assert_includes tasks, "Generating ISO image for #{@host.name}"
         | 
| 50 | 
            +
                  assert_includes tasks, "Upload ISO image to datastore for #{@host.name}"
         | 
| 51 | 
            +
                  assert_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
         | 
| 52 | 
            +
                  assert_not_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
         | 
| 39 53 | 
             
                end
         | 
| 40 54 |  | 
| 41 | 
            -
                test 'should  | 
| 42 | 
            -
                  host | 
| 43 | 
            -
             | 
| 44 | 
            -
                   | 
| 45 | 
            -
                  host. | 
| 46 | 
            -
                  host. | 
| 47 | 
            -
                   | 
| 55 | 
            +
                test 'the iso should be detached when the host leaves build mode' do
         | 
| 56 | 
            +
                  @host.stubs(:compute?).returns(true)
         | 
| 57 | 
            +
                  old = stub()
         | 
| 58 | 
            +
                  old.stubs(:build?).returns(true)
         | 
| 59 | 
            +
                  @host.stubs(:old).returns(old)
         | 
| 60 | 
            +
                  @host.stubs(:build?).returns(false)
         | 
| 61 | 
            +
                  @host.send(:queue_bootdisk_compute)
         | 
| 62 | 
            +
                  tasks = @host.queue.all.map(&:name)
         | 
| 63 | 
            +
                  assert_not_includes tasks, "Generating ISO image for #{@host.name}"
         | 
| 64 | 
            +
                  assert_not_includes tasks, "Upload ISO image to datastore for #{@host.name}"
         | 
| 65 | 
            +
                  assert_not_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
         | 
| 66 | 
            +
                  assert_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
         | 
| 48 67 | 
             
                end
         | 
| 49 68 | 
             
              end
         | 
| 50 69 | 
             
            end
         | 
| @@ -21,7 +21,7 @@ module ForemanBootdisk | |
| 21 21 |  | 
| 22 22 | 
             
                  test 'does not include a host token' do
         | 
| 23 23 | 
             
                    rendered_template = renderer.generic_template_render
         | 
| 24 | 
            -
                    assert_includes rendered_template, 'http:// | 
| 24 | 
            +
                    assert_includes rendered_template, 'http://smart-proxy.example.com/unattended/iPXE?mac=${net0/mac}'
         | 
| 25 25 | 
             
                    assert_not_includes rendered_template, 'token'
         | 
| 26 26 | 
             
                  end
         | 
| 27 27 | 
             
                end
         | 
| @@ -11,10 +11,22 @@ module ForemanBootdisk | |
| 11 11 | 
             
                  let(:medium) { FactoryBot.create(:medium, name: 'Red Hat Enterprise Linux Atomic Mirror') }
         | 
| 12 12 | 
             
                  let(:operatingsystem) { FactoryBot.create(:ubuntu14_10, :with_archs, :with_ptables, media: [medium]) }
         | 
| 13 13 | 
             
                  let(:host) { FactoryBot.create(:host, :managed, operatingsystem: operatingsystem, build: true) }
         | 
| 14 | 
            -
                  let(: | 
| 14 | 
            +
                  let(:pxelinux_template) { FactoryBot.create(:provisioning_template, template: 'Fake kernel line <%= @kernel %> - <%= @initrd %>') }
         | 
| 15 | 
            +
                  let(:pxegrub2_template) { FactoryBot.create(:provisioning_template, template: 'Fake kernel line <%= @kernel %> - <%= @initrd %>') }
         | 
| 15 16 |  | 
| 16 17 | 
             
                  setup do
         | 
| 17 | 
            -
                    host. | 
| 18 | 
            +
                    host.stubs(:provisioning_template).with(kind: :PXELinux).returns(pxelinux_template)
         | 
| 19 | 
            +
                    host.stubs(:provisioning_template).with(kind: :PXEGrub2).returns(pxegrub2_template)
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  test 'fetch handles redirect' do
         | 
| 23 | 
            +
                    Dir.mktmpdir do |dir|
         | 
| 24 | 
            +
                      url = 'http://example.com/request'
         | 
| 25 | 
            +
                      redirection = 'http://example.com/redirect'
         | 
| 26 | 
            +
                      stub_request(:get, url).to_return(status: 301, headers: { 'Location' => redirection })
         | 
| 27 | 
            +
                      stub_request(:get, redirection)
         | 
| 28 | 
            +
                      ForemanBootdisk::ISOGenerator.fetch(File.join(dir, 'test'), url)
         | 
| 29 | 
            +
                    end
         | 
| 18 30 | 
             
                  end
         | 
| 19 31 |  | 
| 20 32 | 
             
                  test 'generate_full_host creates with ISO-compatible file names' do
         | 
| @@ -30,11 +42,8 @@ module ForemanBootdisk | |
| 30 42 | 
             
                    )
         | 
| 31 43 | 
             
                    initrd_url = urls[:initrd]
         | 
| 32 44 |  | 
| 33 | 
            -
                    ForemanBootdisk::ISOGenerator.expects(:generate) | 
| 34 | 
            -
             | 
| 35 | 
            -
                                                                            files: { kernel => kernel_url,
         | 
| 36 | 
            -
                                                                                     initrd => initrd_url }
         | 
| 37 | 
            -
                                                                          }, anything)
         | 
| 45 | 
            +
                    ForemanBootdisk::ISOGenerator.expects(:generate)
         | 
| 46 | 
            +
                                                 .with({ isolinux: "Fake kernel line #{kernel} - #{initrd}", grub: "Fake kernel line /#{kernel} - /#{initrd}", files: { kernel => kernel_url, initrd => initrd_url } }, anything)
         | 
| 38 47 |  | 
| 39 48 | 
             
                    ForemanBootdisk::ISOGenerator.generate_full_host(host)
         | 
| 40 49 | 
             
                  end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: foreman_bootdisk
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 17.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Dominic Cleal
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2020-06-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rubocop
         | 
| @@ -24,6 +24,62 @@ dependencies: | |
| 24 24 | 
             
                - - ">="
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rubocop-minitest
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rubocop-performance
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: rubocop-rails
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ">="
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ">="
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: webmock
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ">="
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ">="
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0'
         | 
| 27 83 | 
             
            description: Plugin for Foreman that creates iPXE-based boot disks to provision hosts
         | 
| 28 84 | 
             
              without the need for PXE infrastructure.
         | 
| 29 85 | 
             
            email: dcleal@redhat.com
         | 
| @@ -35,6 +91,7 @@ extra_rdoc_files: | |
| 35 91 | 
             
            - README.md
         | 
| 36 92 | 
             
            files:
         | 
| 37 93 | 
             
            - ".tx/config"
         | 
| 94 | 
            +
            - AUTHORS
         | 
| 38 95 | 
             
            - CHANGES.md
         | 
| 39 96 | 
             
            - LICENSE
         | 
| 40 97 | 
             
            - README.md
         | 
| @@ -45,6 +102,7 @@ files: | |
| 45 102 | 
             
            - app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb
         | 
| 46 103 | 
             
            - app/lib/foreman_bootdisk/scope/bootdisk.rb
         | 
| 47 104 | 
             
            - app/lib/foreman_bootdisk/scope/full_host_bootdisk.rb
         | 
| 105 | 
            +
            - app/lib/foreman_bootdisk/scope/full_host_bootdisk_efi.rb
         | 
| 48 106 | 
             
            - app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
         | 
| 49 107 | 
             
            - app/models/concerns/foreman_bootdisk/host_ext.rb
         | 
| 50 108 | 
             
            - app/models/concerns/foreman_bootdisk/orchestration/compute.rb
         | 
| @@ -52,7 +110,9 @@ files: | |
| 52 110 | 
             
            - app/services/foreman_bootdisk/iso_generator.rb
         | 
| 53 111 | 
             
            - app/services/foreman_bootdisk/renderer.rb
         | 
| 54 112 | 
             
            - app/views/foreman_bootdisk/disks/help.html.erb
         | 
| 113 | 
            +
            - app/views/foreman_bootdisk/generic_efi_host.erb
         | 
| 55 114 | 
             
            - app/views/foreman_bootdisk/generic_host.erb
         | 
| 115 | 
            +
            - app/views/foreman_bootdisk/generic_static_host.erb
         | 
| 56 116 | 
             
            - app/views/foreman_bootdisk/host.erb
         | 
| 57 117 | 
             
            - app/views/hosts/provision_method/bootdisk/_form.html.erb
         | 
| 58 118 | 
             
            - config/routes.rb
         | 
| @@ -70,6 +130,7 @@ files: | |
| 70 130 | 
             
            - lib/foreman_bootdisk/version.rb
         | 
| 71 131 | 
             
            - lib/tasks/bootdisk.rake
         | 
| 72 132 | 
             
            - locale/Makefile
         | 
| 133 | 
            +
            - locale/action_names.rb
         | 
| 73 134 | 
             
            - locale/ca/LC_MESSAGES/foreman_bootdisk.mo
         | 
| 74 135 | 
             
            - locale/ca/foreman_bootdisk.po
         | 
| 75 136 | 
             
            - locale/de/LC_MESSAGES/foreman_bootdisk.mo
         | 
| @@ -101,6 +162,7 @@ files: | |
| 101 162 | 
             
            - locale/zh_CN/foreman_bootdisk.po
         | 
| 102 163 | 
             
            - locale/zh_TW/LC_MESSAGES/foreman_bootdisk.mo
         | 
| 103 164 | 
             
            - locale/zh_TW/foreman_bootdisk.po
         | 
| 165 | 
            +
            - release-gem
         | 
| 104 166 | 
             
            - test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb
         | 
| 105 167 | 
             
            - test/functional/foreman_bootdisk/api/v2/subnet_disks_controller_test.rb
         | 
| 106 168 | 
             
            - test/functional/foreman_bootdisk/disks_controller_test.rb
         | 
| @@ -133,8 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 133 195 | 
             
                - !ruby/object:Gem::Version
         | 
| 134 196 | 
             
                  version: '0'
         | 
| 135 197 | 
             
            requirements: []
         | 
| 136 | 
            -
             | 
| 137 | 
            -
            rubygems_version: 2.7.6
         | 
| 198 | 
            +
            rubygems_version: 3.0.3
         | 
| 138 199 | 
             
            signing_key: 
         | 
| 139 200 | 
             
            specification_version: 4
         | 
| 140 201 | 
             
            summary: Create boot disks to provision hosts with Foreman
         |