foreman_bootdisk 17.1.0 → 18.0.0
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 +2 -3
- data/app/controllers/foreman_bootdisk/api/v2/disks_controller.rb +7 -2
- data/app/controllers/foreman_bootdisk/disks_controller.rb +22 -20
- data/app/controllers/foreman_bootdisk/subnet_disks_controller.rb +41 -0
- data/app/helpers/bootdisk_links_helper.rb +46 -0
- data/app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb +30 -42
- data/app/helpers/concerns/foreman_bootdisk/pretty_error.rb +13 -0
- data/app/helpers/concerns/foreman_bootdisk/subnets_helper_ext.rb +45 -0
- data/app/helpers/disk_helper.rb +8 -0
- data/app/views/foreman_bootdisk/disks/help.html.erb +16 -4
- data/app/views/subnets/_bootdisk_action_buttons.erb +1 -0
- data/app/views/subnets/_bootdisk_title_buttons.erb +1 -0
- data/config/routes.rb +1 -1
- data/lib/foreman_bootdisk/engine.rb +9 -2
- data/lib/foreman_bootdisk/version.rb +1 -1
- data/locale/action_names.rb +2 -4
- data/locale/ca/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ca/foreman_bootdisk.po +43 -13
- data/locale/de/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/de/foreman_bootdisk.po +41 -11
- data/locale/en/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en/foreman_bootdisk.po +39 -9
- data/locale/en_GB/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en_GB/foreman_bootdisk.po +41 -11
- data/locale/es/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/es/foreman_bootdisk.po +63 -32
- data/locale/foreman_bootdisk.pot +109 -64
- data/locale/fr/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/fr/foreman_bootdisk.po +74 -43
- data/locale/it/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/it/foreman_bootdisk.po +41 -11
- data/locale/ja/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ja/foreman_bootdisk.po +64 -33
- data/locale/ko/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ko/foreman_bootdisk.po +41 -11
- data/locale/pt_BR/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/pt_BR/foreman_bootdisk.po +73 -43
- data/locale/ru/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ru/foreman_bootdisk.po +41 -11
- data/locale/sv_SE/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/sv_SE/foreman_bootdisk.po +41 -11
- data/locale/zh_CN/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_CN/foreman_bootdisk.po +107 -77
- data/locale/zh_TW/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_TW/foreman_bootdisk.po +41 -11
- data/test/functional/foreman_bootdisk/disks_controller_test.rb +12 -22
- data/test/functional/foreman_bootdisk/subnet_disks_controller_test.rb +51 -0
- metadata +10 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4fcb24387c278c94c7958d2555049002680e100e3b29c95d6593bb38970849ec
         | 
| 4 | 
            +
              data.tar.gz: 82445ab3eab98f326a922ecae03937d2a323d5422cc1b4521d98f8a6cc11593a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fcb7c5f6975000d376ae1795b392b6583bee6179cccd0b1c1f3893aa6109cabc391cae7904a8dfb8f4235d6898d57c6ad0c13cd1bc52b97216a382b7f992f752
         | 
| 7 | 
            +
              data.tar.gz: 8fc3266a6933ca5bfc0b3e32547bd28c26926000ad8220a39b907402d441f1f49e271b58fc0ac3de2bc59e3db925e98ea91f6114944960c45524882a8a04b880
         | 
    
        data/README.md
    CHANGED
    
    | @@ -228,7 +228,7 @@ The installation can continue on either the DHCP or static IP depending on how | |
| 228 228 | 
             
            the OS iPXE template is configured, and could configure the assigned IP
         | 
| 229 229 | 
             
            address statically for the installed system via the kickstart file.
         | 
| 230 230 |  | 
| 231 | 
            -
            To generate the image from the web interface, view a  | 
| 231 | 
            +
            To generate the image from the web interface, view a subnet page, click the
         | 
| 232 232 | 
             
            "Boot disk" button and select "Generic image".
         | 
| 233 233 |  | 
| 234 234 | 
             
            To generate using the Hammer CLI, install the [hammer_cli_foreman_bootdisk](https://github.com/theforeman/hammer_cli_foreman_bootdisk)
         | 
| @@ -269,8 +269,7 @@ the "Templates" module enabled and configured. | |
| 269 269 |  | 
| 270 270 | 
             
            This image is generic for all hosts with a provisioning NIC on that subnet.
         | 
| 271 271 |  | 
| 272 | 
            -
            To generate the image from the web interface, view a  | 
| 273 | 
            -
            "Boot disk" button and select "Subnet image".
         | 
| 272 | 
            +
            To generate the image from the web interface, view a subnet page and select "Subnet image" from subnet action buttons.
         | 
| 274 273 |  | 
| 275 274 | 
             
            To generate using the Hammer CLI, install the [hammer_cli_foreman_bootdisk](https://github.com/theforeman/hammer_cli_foreman_bootdisk)
         | 
| 276 275 | 
             
            plugin and run:
         | 
| @@ -37,8 +37,13 @@ module ForemanBootdisk | |
| 37 37 | 
             
                      host = @disk
         | 
| 38 38 | 
             
                      if params[:full]
         | 
| 39 39 | 
             
                        return unless bootdisk_type_allowed?('full_host')
         | 
| 40 | 
            -
                         | 
| 41 | 
            -
                           | 
| 40 | 
            +
                        begin
         | 
| 41 | 
            +
                          ForemanBootdisk::ISOGenerator.generate_full_host(host) do |iso|
         | 
| 42 | 
            +
                            send_file(iso, filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso")
         | 
| 43 | 
            +
                          end
         | 
| 44 | 
            +
                        rescue ::Foreman::Exception => e
         | 
| 45 | 
            +
                          raise e unless e.code == 'ERF42-2893'
         | 
| 46 | 
            +
                          render_error json: { error: _('Host is not in build mode')}, status: :method_not_allowed
         | 
| 42 47 | 
             
                        end
         | 
| 43 48 | 
             
                      else
         | 
| 44 49 | 
             
                        return unless bootdisk_type_allowed?
         | 
| @@ -5,9 +5,13 @@ require 'uri' | |
| 5 5 | 
             
            module ForemanBootdisk
         | 
| 6 6 | 
             
              class DisksController < ::ApplicationController
         | 
| 7 7 | 
             
                include AllowedActions
         | 
| 8 | 
            +
                include PrettyError
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                helper DiskHelper
         | 
| 8 11 |  | 
| 9 12 | 
             
                before_action :bootdisk_type_allowed?, except: :help
         | 
| 10 | 
            -
             | 
| 13 | 
            +
             | 
| 14 | 
            +
                before_action :find_resource, only: %w[host full_host]
         | 
| 11 15 |  | 
| 12 16 | 
             
                # as this engine is isolated, we need to include url helpers from core explicitly
         | 
| 13 17 | 
             
                # to render help page layout
         | 
| @@ -39,6 +43,8 @@ module ForemanBootdisk | |
| 39 43 | 
             
                    return
         | 
| 40 44 | 
             
                  end
         | 
| 41 45 |  | 
| 46 | 
            +
                  prolong_token(host)
         | 
| 47 | 
            +
             | 
| 42 48 | 
             
                  ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
         | 
| 43 49 | 
             
                    send_file(iso, filename: "#{host.name}.iso")
         | 
| 44 50 | 
             
                  end
         | 
| @@ -46,28 +52,16 @@ module ForemanBootdisk | |
| 46 52 |  | 
| 47 53 | 
             
                def full_host
         | 
| 48 54 | 
             
                  host = @disk
         | 
| 49 | 
            -
                  ForemanBootdisk::ISOGenerator.generate_full_host(host) do |iso|
         | 
| 50 | 
            -
                    send_file(iso, filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso")
         | 
| 51 | 
            -
                  end
         | 
| 52 | 
            -
                end
         | 
| 53 55 |  | 
| 54 | 
            -
             | 
| 55 | 
            -
                  host = @disk
         | 
| 56 | 
            +
                  prolong_token(host)
         | 
| 56 57 | 
             
                  begin
         | 
| 57 | 
            -
                     | 
| 58 | 
            -
             | 
| 59 | 
            -
                     | 
| 60 | 
            -
             | 
| 61 | 
            -
                     | 
| 62 | 
            -
                     | 
| 63 | 
            -
                  rescue StandardError => e
         | 
| 64 | 
            -
                    error_rendering(e)
         | 
| 58 | 
            +
                    ForemanBootdisk::ISOGenerator.generate_full_host(host) do |iso|
         | 
| 59 | 
            +
                      send_file(iso, filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso")
         | 
| 60 | 
            +
                    end
         | 
| 61 | 
            +
                  rescue ::Foreman::Exception => e
         | 
| 62 | 
            +
                    raise e unless e.code == 'ERF42-2893'
         | 
| 63 | 
            +
                    error _('Host is not in build mode.')
         | 
| 65 64 | 
             
                    redirect_back(fallback_location: '/')
         | 
| 66 | 
            -
                    return
         | 
| 67 | 
            -
                  end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                  ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl_bios, grub: tmpl_efi) do |iso|
         | 
| 70 | 
            -
                    send_file(iso, filename: "bootdisk_subnet_#{subnet.name}.iso")
         | 
| 71 65 | 
             
                  end
         | 
| 72 66 | 
             
                end
         | 
| 73 67 |  | 
| @@ -84,5 +78,13 @@ module ForemanBootdisk | |
| 84 78 | 
             
                  error("#{msg}: #{exception.message}")
         | 
| 85 79 | 
             
                  ::Foreman::Logging.exception(msg, exception)
         | 
| 86 80 | 
             
                end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                def prolong_token(host)
         | 
| 83 | 
            +
                  return if Setting[:token_duration] == 0 || host.token.nil?
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                  # update build token
         | 
| 86 | 
            +
                  token = host.token
         | 
| 87 | 
            +
                  token.update(expires: Time.zone.now + Setting[:token_duration].minutes)
         | 
| 88 | 
            +
                end
         | 
| 87 89 | 
             
              end
         | 
| 88 90 | 
             
            end
         | 
| @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module ForemanBootdisk
         | 
| 4 | 
            +
              class SubnetDisksController < ::ApplicationController
         | 
| 5 | 
            +
                include PrettyError
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                before_action :find_resource, only: :subnet
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                # as this engine is isolated, we need to include url helpers from core explicitly
         | 
| 10 | 
            +
                # to render help page layout
         | 
| 11 | 
            +
                include Rails.application.routes.url_helpers
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def subnet
         | 
| 14 | 
            +
                  begin
         | 
| 15 | 
            +
                    @subnet.tftp || raise(::Foreman::Exception.new(N_('TFTP feature not enabled for subnet %s'), @subnet.name))
         | 
| 16 | 
            +
                    @subnet.httpboot || ForemanBootdisk.logger.warn('HTTPBOOT feature is not enabled for subnet %s, UEFI may not be available for bootdisk' % @subnet.name)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    tmpl_bios = ForemanBootdisk::Renderer.new.generic_template_render(@subnet)
         | 
| 19 | 
            +
                    tmpl_efi = ForemanBootdisk::Renderer.new.generic_efi_template_render(@subnet)
         | 
| 20 | 
            +
                  rescue StandardError => e
         | 
| 21 | 
            +
                    error_rendering(e)
         | 
| 22 | 
            +
                    redirect_back(fallback_location: '/')
         | 
| 23 | 
            +
                    return
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl_bios, grub: tmpl_efi) do |iso|
         | 
| 27 | 
            +
                    send_file(iso, filename: "bootdisk_subnet_#{@subnet.name}.iso")
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                private
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def resource_scope(_controller = controller_name)
         | 
| 34 | 
            +
                  Subnet.authorized(:view_subnets)
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                def find_resource
         | 
| 38 | 
            +
                  @subnet = Subnet.find(params[:id])
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module BootdiskLinksHelper
         | 
| 4 | 
            +
              # Core Foreman helpers can't look up a URL against a mounted engine
         | 
| 5 | 
            +
              def display_bootdisk_link_if_authorized(name, options = {}, html_options = {})
         | 
| 6 | 
            +
                if bootdisk_authorized_for(options)
         | 
| 7 | 
            +
                  link_to(name, bootdisk_url(options), html_options)
         | 
| 8 | 
            +
                else
         | 
| 9 | 
            +
                  ''
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              def bootdisk_url(options)
         | 
| 14 | 
            +
                ForemanBootdisk::Engine.routes.url_for(options.merge(only_path: true, script_name: foreman_bootdisk_path))
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              def bootdisk_authorized_for(options)
         | 
| 18 | 
            +
                User.current.allowed_to?(options)
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              def divider
         | 
| 22 | 
            +
                tag(:li, class: 'divider')
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              def bootdisk_help_link
         | 
| 26 | 
            +
                display_bootdisk_link_if_authorized(
         | 
| 27 | 
            +
                  _('Boot disk Help'),
         | 
| 28 | 
            +
                {
         | 
| 29 | 
            +
                    controller: 'foreman_bootdisk/disks',
         | 
| 30 | 
            +
                    action: 'help'
         | 
| 31 | 
            +
                  },
         | 
| 32 | 
            +
                  class: 'la'
         | 
| 33 | 
            +
                )
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              def bootdisk_title_action_buttons(actions)
         | 
| 37 | 
            +
                title_actions(
         | 
| 38 | 
            +
                  button_group(
         | 
| 39 | 
            +
                    select_action_button(
         | 
| 40 | 
            +
                      _('Boot disk'), { class: 'btn btn-group' },
         | 
| 41 | 
            +
                      actions
         | 
| 42 | 
            +
                    )
         | 
| 43 | 
            +
                  )
         | 
| 44 | 
            +
                )
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
| @@ -2,16 +2,11 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            module ForemanBootdisk
         | 
| 4 4 | 
             
              module HostsHelperExt
         | 
| 5 | 
            +
                include BootdiskLinksHelper
         | 
| 6 | 
            +
             | 
| 5 7 | 
             
                def host_title_actions(host)
         | 
| 6 8 | 
             
                  if host.bootdisk_downloadable?
         | 
| 7 | 
            -
                     | 
| 8 | 
            -
                      button_group(
         | 
| 9 | 
            -
                        select_action_button(
         | 
| 10 | 
            -
                          _('Boot disk'), { class: 'btn btn-group' },
         | 
| 11 | 
            -
                          host_action_buttons(host)
         | 
| 12 | 
            -
                        )
         | 
| 13 | 
            -
                      )
         | 
| 14 | 
            -
                    )
         | 
| 9 | 
            +
                    bootdisk_title_action_buttons(host_action_buttons(host))
         | 
| 15 10 | 
             
                  else
         | 
| 16 11 | 
             
                    bootdisk_button_disabled(host)
         | 
| 17 12 | 
             
                  end
         | 
| @@ -69,55 +64,48 @@ module ForemanBootdisk | |
| 69 64 |  | 
| 70 65 | 
             
                  host_image_link = display_bootdisk_link_if_authorized(
         | 
| 71 66 | 
             
                                      _("Host '%s' image") % host.name.split('.')[0],
         | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 67 | 
            +
                                    {
         | 
| 68 | 
            +
                                        controller: 'foreman_bootdisk/disks',
         | 
| 69 | 
            +
                                        action: 'host',
         | 
| 70 | 
            +
                                        id: host
         | 
| 76 71 | 
             
                                      },
         | 
| 77 72 | 
             
                                      class: 'la'
         | 
| 78 73 | 
             
                                    )
         | 
| 79 74 |  | 
| 80 75 | 
             
                  full_host_image_link = display_bootdisk_link_if_authorized(
         | 
| 81 76 | 
             
                                           _("Full host '%s' image") % host.name.split('.')[0],
         | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 77 | 
            +
                                         {
         | 
| 78 | 
            +
                                             controller: 'foreman_bootdisk/disks',
         | 
| 79 | 
            +
                                             action: 'full_host',
         | 
| 80 | 
            +
                                             id: host
         | 
| 86 81 | 
             
                                           },
         | 
| 87 82 | 
             
                                           class: 'la'
         | 
| 88 83 | 
             
                                         )
         | 
| 89 84 |  | 
| 90 | 
            -
                   | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
                                _('Help'),
         | 
| 101 | 
            -
                                {
         | 
| 102 | 
            -
                                controller: 'foreman_bootdisk/disks',
         | 
| 103 | 
            -
                                action: 'help'
         | 
| 104 | 
            -
                                },
         | 
| 105 | 
            -
                                class: 'la'
         | 
| 106 | 
            -
                              )
         | 
| 107 | 
            -
             | 
| 108 | 
            -
                  divider = tag(:li, '', class: 'divider')
         | 
| 85 | 
            +
                  full_host_blind_link = if bootdisk_authorized_for({controller: 'foreman_bootdisk/disks', action: 'full_host', id: host})
         | 
| 86 | 
            +
                                           link_to(_("Full host '%s' image") % host.name.split('.')[0],
         | 
| 87 | 
            +
                                                   '#',
         | 
| 88 | 
            +
                                                   class: 'la btn btn-info',
         | 
| 89 | 
            +
                                                   disabled: true,
         | 
| 90 | 
            +
                                                   title: _('Host is not in build mode')
         | 
| 91 | 
            +
                                           )
         | 
| 92 | 
            +
                                         else
         | 
| 93 | 
            +
                                           ''
         | 
| 94 | 
            +
                                         end
         | 
| 109 95 |  | 
| 110 96 | 
             
                  actions << host_image_link if allowed_actions.include?('host')
         | 
| 111 | 
            -
                   | 
| 97 | 
            +
                  if allowed_actions.include?('full_host')
         | 
| 98 | 
            +
                    if host.build?
         | 
| 99 | 
            +
                      actions << full_host_image_link
         | 
| 100 | 
            +
                    else
         | 
| 101 | 
            +
                      actions << full_host_blind_link
         | 
| 102 | 
            +
                    end
         | 
| 103 | 
            +
                  end
         | 
| 112 104 |  | 
| 113 | 
            -
                  subnet_link = display_bootdisk_for_subnet(host)
         | 
| 114 | 
            -
                  actions << divider if allowed_actions.include?('generic') || (allowed_actions.include?('subnet') && subnet_link.present?)
         | 
| 115 105 |  | 
| 116 | 
            -
                  actions <<  | 
| 117 | 
            -
                  actions << subnet_link if allowed_actions.include?('subnet')
         | 
| 106 | 
            +
                  actions << divider if (host_image_link.present? && allowed_actions.include?('host')) || (full_host_image_link.present? && allowed_actions.include?('full_host'))
         | 
| 118 107 |  | 
| 119 | 
            -
                  actions <<  | 
| 120 | 
            -
                  actions << help_link
         | 
| 108 | 
            +
                  actions << bootdisk_help_link
         | 
| 121 109 |  | 
| 122 110 | 
             
                  actions
         | 
| 123 111 | 
             
                end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module ForemanBootdisk
         | 
| 4 | 
            +
              module PrettyError
         | 
| 5 | 
            +
                extend ActiveSupport::Concern
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def error_rendering(exception)
         | 
| 8 | 
            +
                  msg = _('Failed to render boot disk template')
         | 
| 9 | 
            +
                  error("#{msg}: #{exception.message}")
         | 
| 10 | 
            +
                  ::Foreman::Logging.exception(msg, exception)
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module ForemanBootdisk
         | 
| 4 | 
            +
              module SubnetsHelperExt
         | 
| 5 | 
            +
                include BootdiskLinksHelper
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def display_bootdisk_for_subnet(subnet)
         | 
| 8 | 
            +
                  if (proxy = subnet.tftp || subnet.httpboot) && proxy.has_feature?('Templates') && Setting::Bootdisk.allowed_types.include?('subnet')
         | 
| 9 | 
            +
                    display_bootdisk_link_if_authorized(
         | 
| 10 | 
            +
                        _("Subnet generic image"), {
         | 
| 11 | 
            +
                        controller: 'foreman_bootdisk/subnet_disks',
         | 
| 12 | 
            +
                        action: 'subnet',
         | 
| 13 | 
            +
                        id: subnet.id
         | 
| 14 | 
            +
                    },
         | 
| 15 | 
            +
                        class: 'la'
         | 
| 16 | 
            +
                    )
         | 
| 17 | 
            +
                  else
         | 
| 18 | 
            +
                    ''
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def display_bootdisk_title_buttons
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  actions = []
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  generic_image_link = display_bootdisk_link_if_authorized(
         | 
| 27 | 
            +
                                         _('Generic image'),
         | 
| 28 | 
            +
                                       {
         | 
| 29 | 
            +
                                           controller: 'foreman_bootdisk/disks',
         | 
| 30 | 
            +
                                           action: 'generic'
         | 
| 31 | 
            +
                                         },
         | 
| 32 | 
            +
                                         class: 'la'
         | 
| 33 | 
            +
                                       )
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  if Setting::Bootdisk.allowed_types&.include?('generic')
         | 
| 36 | 
            +
                    actions << generic_image_link
         | 
| 37 | 
            +
                    actions << divider
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  actions << bootdisk_help_link
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  bootdisk_title_action_buttons(actions)
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
            end
         | 
| @@ -9,7 +9,12 @@ | |
| 9 9 | 
             
                <%= _('All images are usable as either ISOs or as disk images, including being written to a USB disk with `dd`.') %>
         | 
| 10 10 | 
             
              </p>
         | 
| 11 11 |  | 
| 12 | 
            -
              <h2><%= _('Host  | 
| 12 | 
            +
              <h2><%= _('Host images') %></h2>
         | 
| 13 | 
            +
              <p>
         | 
| 14 | 
            +
                <%= _('These images are used for host. You can find them at host detail page.') %>
         | 
| 15 | 
            +
              </p>
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              <h3><%= _('Host image') %><%= mark_disabled_bootdisk_type('host') %></h3>
         | 
| 13 18 | 
             
              <p>
         | 
| 14 19 | 
             
                <%= _("Per-host images contain data about a particular host registered in Foreman and set up fully static networking, avoiding the requirement for DHCP.  After networking is configured, they chainload from Foreman, picking up the current OS configuration and build state from the server.") %>
         | 
| 15 20 | 
             
              </p>
         | 
| @@ -17,12 +22,17 @@ | |
| 17 22 | 
             
                <%= _("Once chainloaded, the OS bootloader and installer are downloaded directly from the installation media configured in Foreman, and the provisioning script (kickstart/preseed) is downloaded from Foreman.") %>
         | 
| 18 23 | 
             
              </p>
         | 
| 19 24 |  | 
| 20 | 
            -
              < | 
| 25 | 
            +
              <h3><%= _('Full host image') %><%= mark_disabled_bootdisk_type('full_host') %></h3>
         | 
| 21 26 | 
             
              <p>
         | 
| 22 27 | 
             
                <%= _('A variant of the per-host image which contains the OS bootloader embedded inside the disk.  This may be useful if chainloading fails on certain hardware, but has the downside that the image must be regenerated for any change in the OS, bootloader or PXELinux templates.') %>
         | 
| 23 28 | 
             
              </p>
         | 
| 24 29 |  | 
| 25 | 
            -
              <h2><%= _('Generic  | 
| 30 | 
            +
              <h2><%= _('Generic images') %></h2>
         | 
| 31 | 
            +
              <p>
         | 
| 32 | 
            +
                <%= _('These images are more generic than previous images. You can find them at subnet index page.') %>
         | 
| 33 | 
            +
              </p>
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              <h3><%= _('Generic image') %><%= mark_disabled_bootdisk_type('generic') %></h3>
         | 
| 26 36 | 
             
              <p>
         | 
| 27 37 | 
             
                <%= _('Generic images are a reusable disk image that works for any host registered in Foreman.  It requires a basic DHCP and DNS service to function and contact the server, but does not require DHCP reservations or static IP addresses.') %>
         | 
| 28 38 | 
             
              </p>
         | 
| @@ -30,11 +40,13 @@ | |
| 30 40 | 
             
                <%= _('The OS install continues using the installation media configured in Foreman, and it will typically configure static networking, depending on how the OS iPXE template is configured.') %>
         | 
| 31 41 | 
             
              </p>
         | 
| 32 42 |  | 
| 33 | 
            -
              < | 
| 43 | 
            +
              <h3><%= _('Subnet image') %><%= mark_disabled_bootdisk_type('subnet') %></h3>
         | 
| 34 44 | 
             
              <p>
         | 
| 35 45 | 
             
                <%= _('Subnet images are similar to generic images, but chain-loading is done via the TFTP Smart Proxy assigned to the Subnet of the host. The smart proxy must have the "Templates" module enabled and configured.') %>
         | 
| 36 46 | 
             
              </p>
         | 
| 37 47 | 
             
              <p>
         | 
| 38 48 | 
             
                <%= _('This image is generic for all hosts with a provisioning NIC on that subnet.') %>
         | 
| 39 49 | 
             
              </p>
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              <p><%= _('* - These bootdisk types were disabled, you can enable them in Administer - Settings.') %></p>
         | 
| 40 52 | 
             
            </div>
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            <%= display_bootdisk_for_subnet(subject) %>
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            <%= display_bootdisk_title_buttons %>
         | 
    
        data/config/routes.rb
    CHANGED
    
    | @@ -7,7 +7,7 @@ ForemanBootdisk::Engine.routes.draw do | |
| 7 7 | 
             
                constraints(id: %r{[^/]+}) do
         | 
| 8 8 | 
             
                  get 'hosts/:id', on: :collection, to: 'disks#host'
         | 
| 9 9 | 
             
                  get 'full_hosts/:id', on: :collection, to: 'disks#full_host'
         | 
| 10 | 
            -
                  get 'subnet/:id', on: :collection, to: ' | 
| 10 | 
            +
                  get 'subnet/:id', on: :collection, to: 'subnet_disks#subnet'
         | 
| 11 11 | 
             
                end
         | 
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| @@ -38,10 +38,11 @@ module ForemanBootdisk | |
| 38 38 |  | 
| 39 39 | 
             
                initializer 'foreman_bootdisk.register_plugin', before: :finisher_hook do |_app|
         | 
| 40 40 | 
             
                  Foreman::Plugin.register :foreman_bootdisk do
         | 
| 41 | 
            -
                    requires_foreman '>=  | 
| 41 | 
            +
                    requires_foreman '>= 3.0'
         | 
| 42 42 |  | 
| 43 43 | 
             
                    security_block :bootdisk do |_map|
         | 
| 44 | 
            -
                      permission :download_bootdisk, 'foreman_bootdisk/disks': %i[generic host full_host  | 
| 44 | 
            +
                      permission :download_bootdisk, 'foreman_bootdisk/disks': %i[generic host full_host help],
         | 
| 45 | 
            +
                                                     'foreman_bootdisk/subnet_disks': [:subnet],
         | 
| 45 46 | 
             
                                                     'foreman_bootdisk/api/v2/disks': %i[generic host],
         | 
| 46 47 | 
             
                                                     'foreman_bootdisk/api/v2/subnet_disks': [:subnet]
         | 
| 47 48 | 
             
                    end
         | 
| @@ -57,6 +58,11 @@ module ForemanBootdisk | |
| 57 58 | 
             
                    provision_method 'bootdisk', N_('Boot disk based')
         | 
| 58 59 | 
             
                    template_labels 'Bootdisk' => N_('Boot disk embedded template')
         | 
| 59 60 | 
             
                    allowed_template_helpers :bootdisk_chain_url, :bootdisk_raise
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                    extend_page "subnets/index" do |cx|
         | 
| 63 | 
            +
                      cx.add_pagelet :subnet_index_action_buttons, name: 'Bootdisk', partial: 'subnets/bootdisk_action_buttons'
         | 
| 64 | 
            +
                      cx.add_pagelet :subnet_index_title_buttons, name: 'Bootdisk', partial: 'subnets/bootdisk_title_buttons'
         | 
| 65 | 
            +
                    end
         | 
| 60 66 | 
             
                  end
         | 
| 61 67 | 
             
                end
         | 
| 62 68 |  | 
| @@ -71,6 +77,7 @@ module ForemanBootdisk | |
| 71 77 | 
             
                    Host::Managed.prepend ForemanBootdisk::HostExt
         | 
| 72 78 | 
             
                    Host::Managed.include ForemanBootdisk::Orchestration::Compute if SETTINGS[:unattended]
         | 
| 73 79 | 
             
                    HostsHelper.prepend ForemanBootdisk::HostsHelperExt
         | 
| 80 | 
            +
                    SubnetsHelper.prepend ForemanBootdisk::SubnetsHelperExt
         | 
| 74 81 | 
             
                    Foreman::Model::Vmware.prepend ForemanBootdisk::ComputeResources::Vmware if Foreman::Model::Vmware.available?
         | 
| 75 82 | 
             
                  rescue StandardError => e
         | 
| 76 83 | 
             
                    Rails.logger.warn "#{ForemanBootdisk::ENGINE_NAME}: skipping engine hook (#{e})"
         | 
    
        data/locale/action_names.rb
    CHANGED
    
    
| Binary file | 
| @@ -3,14 +3,14 @@ | |
| 3 3 | 
             
            # This file is distributed under the same license as the foreman_bootdisk package.
         | 
| 4 4 | 
             
            #
         | 
| 5 5 | 
             
            # Translators:
         | 
| 6 | 
            -
            # Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>, 2017
         | 
| 7 | 
            -
            # Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>, 2015-2016
         | 
| 6 | 
            +
            # Robert Antoni Buj i Gelonch <rbuj@fedoraproject.org>, 2017
         | 
| 7 | 
            +
            # Robert Antoni Buj i Gelonch <rbuj@fedoraproject.org>, 2015-2016
         | 
| 8 8 | 
             
            msgid ""
         | 
| 9 9 | 
             
            msgstr ""
         | 
| 10 | 
            -
            "Project-Id-Version: foreman_bootdisk  | 
| 10 | 
            +
            "Project-Id-Version: foreman_bootdisk 18.0.0\n"
         | 
| 11 11 | 
             
            "Report-Msgid-Bugs-To: \n"
         | 
| 12 | 
            -
            "PO-Revision-Date:  | 
| 13 | 
            -
            "Last-Translator:  | 
| 12 | 
            +
            "PO-Revision-Date: 2021-04-29 10:23+0000\n"
         | 
| 13 | 
            +
            "Last-Translator: Transifex Bot <>\n"
         | 
| 14 14 | 
             
            "Language-Team: Catalan (http://www.transifex.com/foreman/foreman/language/ca/)"
         | 
| 15 15 | 
             
            "\n"
         | 
| 16 16 | 
             
            "MIME-Version: 1.0\n"
         | 
| @@ -19,6 +19,9 @@ msgstr "" | |
| 19 19 | 
             
            "Language: ca\n"
         | 
| 20 20 | 
             
            "Plural-Forms: nplurals=2; plural=(n != 1);\n"
         | 
| 21 21 |  | 
| 22 | 
            +
            msgid "* - These bootdisk types were disabled, you can enable them in Administer - Settings."
         | 
| 23 | 
            +
            msgstr ""
         | 
| 24 | 
            +
             | 
| 22 25 | 
             
            msgid "A variant of the per-host image which contains the OS bootloader embedded inside the disk.  This may be useful if chainloading fails on certain hardware, but has the downside that the image must be regenerated for any change in the OS, bootloader or PXELinux templates."
         | 
| 23 26 | 
             
            msgstr ""
         | 
| 24 27 |  | 
| @@ -28,6 +31,9 @@ msgstr "" | |
| 28 31 | 
             
            msgid "All images are usable as either ISOs or as disk images, including being written to a USB disk with `dd`."
         | 
| 29 32 | 
             
            msgstr ""
         | 
| 30 33 |  | 
| 34 | 
            +
            msgid "Allowed bootdisk types"
         | 
| 35 | 
            +
            msgstr ""
         | 
| 36 | 
            +
             | 
| 31 37 | 
             
            msgid "Attach ISO image to CDROM drive for %s"
         | 
| 32 38 | 
             
            msgstr ""
         | 
| 33 39 |  | 
| @@ -37,6 +43,9 @@ msgstr "Enrere" | |
| 37 43 | 
             
            msgid "Boot disk"
         | 
| 38 44 | 
             
            msgstr "Disc d'arrencada"
         | 
| 39 45 |  | 
| 46 | 
            +
            msgid "Boot disk Help"
         | 
| 47 | 
            +
            msgstr ""
         | 
| 48 | 
            +
             | 
| 40 49 | 
             
            msgid "Boot disk based"
         | 
| 41 50 | 
             
            msgstr ""
         | 
| 42 51 |  | 
| @@ -70,7 +79,7 @@ msgstr "Baixa la imatge d'amfitrió" | |
| 70 79 | 
             
            msgid "Download subnet generic image"
         | 
| 71 80 | 
             
            msgstr "Baixa la imatge genèrica de subxarxa"
         | 
| 72 81 |  | 
| 73 | 
            -
            msgid "Ensure %{ | 
| 82 | 
            +
            msgid "Ensure %{file} is readable (or update \"Grub2 directory\" setting)"
         | 
| 74 83 | 
             
            msgstr ""
         | 
| 75 84 |  | 
| 76 85 | 
             
            msgid "Failed to attach ISO image to CDROM drive of instance %{name}: %{message}"
         | 
| @@ -112,6 +121,9 @@ msgstr "Imatge genèrica" | |
| 112 121 | 
             
            msgid "Generic image template"
         | 
| 113 122 | 
             
            msgstr ""
         | 
| 114 123 |  | 
| 124 | 
            +
            msgid "Generic images"
         | 
| 125 | 
            +
            msgstr ""
         | 
| 126 | 
            +
             | 
| 115 127 | 
             
            msgid "Generic images are a reusable disk image that works for any host registered in Foreman.  It requires a basic DHCP and DNS service to function and contact the server, but does not require DHCP reservations or static IP addresses."
         | 
| 116 128 | 
             
            msgstr ""
         | 
| 117 129 |  | 
| @@ -121,9 +133,6 @@ msgstr "" | |
| 121 133 | 
             
            msgid "Grub2 template to use for generic EFI host boot disks"
         | 
| 122 134 | 
             
            msgstr ""
         | 
| 123 135 |  | 
| 124 | 
            -
            msgid "Help"
         | 
| 125 | 
            -
            msgstr "Ajuda"
         | 
| 126 | 
            -
             | 
| 127 136 | 
             
            msgid "Host '%s' image"
         | 
| 128 137 | 
             
            msgstr ""
         | 
| 129 138 |  | 
| @@ -148,9 +157,18 @@ msgstr "Imatge d'amfitrió" | |
| 148 157 | 
             
            msgid "Host image template"
         | 
| 149 158 | 
             
            msgstr ""
         | 
| 150 159 |  | 
| 160 | 
            +
            msgid "Host images"
         | 
| 161 | 
            +
            msgstr ""
         | 
| 162 | 
            +
             | 
| 163 | 
            +
            msgid "Host is not in build mode"
         | 
| 164 | 
            +
            msgstr ""
         | 
| 165 | 
            +
             | 
| 151 166 | 
             
            msgid "Host is not in build mode, so the template cannot be rendered"
         | 
| 152 167 | 
             
            msgstr ""
         | 
| 153 168 |  | 
| 169 | 
            +
            msgid "Host is not in build mode."
         | 
| 170 | 
            +
            msgstr ""
         | 
| 171 | 
            +
             | 
| 154 172 | 
             
            msgid "ISO build failed"
         | 
| 155 173 | 
             
            msgstr "No s'ha pogut construir l'ISO"
         | 
| 156 174 |  | 
| @@ -175,6 +193,9 @@ msgstr "" | |
| 175 193 | 
             
            msgid "Installation media files will be cached for full host images"
         | 
| 176 194 | 
             
            msgstr "Els fitxers dels mitjans d'instal·lació s'emmagatzemaran en memòria cau per a les imatges completes dels amfitrions"
         | 
| 177 195 |  | 
| 196 | 
            +
            msgid "List of allowed bootdisk types, remove type to disable it"
         | 
| 197 | 
            +
            msgstr ""
         | 
| 198 | 
            +
             | 
| 178 199 | 
             
            msgid "Once chainloaded, the OS bootloader and installer are downloaded directly from the installation media configured in Foreman, and the provisioning script (kickstart/preseed) is downloaded from Foreman."
         | 
| 179 200 | 
             
            msgstr ""
         | 
| 180 201 |  | 
| @@ -214,24 +235,33 @@ msgstr "" | |
| 214 235 | 
             
            msgid "Subnet boot disks"
         | 
| 215 236 | 
             
            msgstr "Discs d'arrencada de subxarxa"
         | 
| 216 237 |  | 
| 238 | 
            +
            msgid "Subnet generic image"
         | 
| 239 | 
            +
            msgstr ""
         | 
| 240 | 
            +
             | 
| 217 241 | 
             
            msgid "Subnet image"
         | 
| 218 242 | 
             
            msgstr "Imatge de subxarxa"
         | 
| 219 243 |  | 
| 220 244 | 
             
            msgid "Subnet images are similar to generic images, but chain-loading is done via the TFTP Smart Proxy assigned to the Subnet of the host. The smart proxy must have the \"Templates\" module enabled and configured."
         | 
| 221 245 | 
             
            msgstr ""
         | 
| 222 246 |  | 
| 223 | 
            -
            msgid "Subnet is not assigned to the host %s"
         | 
| 224 | 
            -
            msgstr "La subxarxa no està assignada a l'amfitrió %s"
         | 
| 225 | 
            -
             | 
| 226 247 | 
             
            msgid "TFTP feature not enabled for subnet %s"
         | 
| 227 248 | 
             
            msgstr "La funcionalitat TFTP no està habilitada per a la subxarxa %s"
         | 
| 228 249 |  | 
| 229 250 | 
             
            msgid "The OS install continues using the installation media configured in Foreman, and it will typically configure static networking, depending on how the OS iPXE template is configured."
         | 
| 230 251 | 
             
            msgstr ""
         | 
| 231 252 |  | 
| 253 | 
            +
            msgid "These images are more generic than previous images. You can find them at subnet index page."
         | 
| 254 | 
            +
            msgstr ""
         | 
| 255 | 
            +
             | 
| 256 | 
            +
            msgid "These images are used for host. You can find them at host detail page."
         | 
| 257 | 
            +
            msgstr ""
         | 
| 258 | 
            +
             | 
| 232 259 | 
             
            msgid "This image is generic for all hosts with a provisioning NIC on that subnet."
         | 
| 233 260 | 
             
            msgstr ""
         | 
| 234 261 |  | 
| 262 | 
            +
            msgid "This type of bootdisk is not allowed. Please contact administrator."
         | 
| 263 | 
            +
            msgstr ""
         | 
| 264 | 
            +
             | 
| 235 265 | 
             
            msgid "True for full, false for basic reusable image"
         | 
| 236 266 | 
             
            msgstr ""
         | 
| 237 267 |  | 
| @@ -244,7 +274,7 @@ msgstr "" | |
| 244 274 | 
             
            msgid "Unable to generate disk template, %{kind} template not found."
         | 
| 245 275 | 
             
            msgstr ""
         | 
| 246 276 |  | 
| 247 | 
            -
            msgid "Unable to mcopy %{ | 
| 277 | 
            +
            msgid "Unable to mcopy %{file}"
         | 
| 248 278 | 
             
            msgstr ""
         | 
| 249 279 |  | 
| 250 280 | 
             
            msgid "Upload ISO image to datastore for %s"
         | 
| Binary file |