foreman_bootdisk 15.0.0 → 17.1.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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yaml +19 -0
  3. data/.tx/config +1 -1
  4. data/AUTHORS +11 -0
  5. data/README.md +25 -0
  6. data/app/controllers/concerns/allowed_actions.rb +16 -0
  7. data/app/controllers/foreman_bootdisk/api/v2/disks_controller.rb +9 -7
  8. data/app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb +16 -4
  9. data/app/controllers/foreman_bootdisk/disks_controller.rb +14 -10
  10. data/app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb +71 -45
  11. data/app/lib/foreman_bootdisk/scope/bootdisk.rb +28 -1
  12. data/app/lib/foreman_bootdisk/scope/full_host_bootdisk_efi.rb +15 -0
  13. data/app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb +10 -1
  14. data/app/models/concerns/foreman_bootdisk/host_ext.rb +13 -6
  15. data/app/models/concerns/foreman_bootdisk/orchestration/compute.rb +38 -22
  16. data/app/models/setting/bootdisk.rb +25 -19
  17. data/app/services/foreman_bootdisk/iso_generator.rb +132 -51
  18. data/app/services/foreman_bootdisk/renderer.rb +36 -19
  19. data/app/views/foreman_bootdisk/generic_efi_host.erb +68 -0
  20. data/app/views/foreman_bootdisk/generic_static_host.erb +34 -0
  21. data/app/views/foreman_bootdisk/host.erb +29 -8
  22. data/db/seeds.d/50-bootdisk_templates.rb +15 -31
  23. data/lib/foreman_bootdisk/engine.rb +9 -6
  24. data/lib/foreman_bootdisk/version.rb +1 -1
  25. data/lib/tasks/bootdisk.rake +10 -24
  26. data/locale/action_names.rb +7 -0
  27. data/locale/ca/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  28. data/locale/ca/foreman_bootdisk.po +58 -7
  29. data/locale/de/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  30. data/locale/de/foreman_bootdisk.po +62 -11
  31. data/locale/en/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  32. data/locale/en/foreman_bootdisk.po +56 -5
  33. data/locale/en_GB/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  34. data/locale/en_GB/foreman_bootdisk.po +62 -11
  35. data/locale/es/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  36. data/locale/es/foreman_bootdisk.po +62 -11
  37. data/locale/foreman_bootdisk.pot +108 -36
  38. data/locale/fr/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  39. data/locale/fr/foreman_bootdisk.po +61 -10
  40. data/locale/it/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  41. data/locale/it/foreman_bootdisk.po +60 -9
  42. data/locale/ja/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  43. data/locale/ja/foreman_bootdisk.po +61 -10
  44. data/locale/ko/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  45. data/locale/ko/foreman_bootdisk.po +60 -9
  46. data/locale/pt_BR/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  47. data/locale/pt_BR/foreman_bootdisk.po +60 -9
  48. data/locale/ru/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  49. data/locale/ru/foreman_bootdisk.po +60 -9
  50. data/locale/sv_SE/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  51. data/locale/sv_SE/foreman_bootdisk.po +59 -8
  52. data/locale/zh_CN/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  53. data/locale/zh_CN/foreman_bootdisk.po +60 -9
  54. data/locale/zh_TW/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  55. data/locale/zh_TW/foreman_bootdisk.po +60 -9
  56. data/release-gem +2 -0
  57. data/test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb +51 -17
  58. data/test/functional/foreman_bootdisk/api/v2/subnet_disks_controller_test.rb +23 -10
  59. data/test/functional/foreman_bootdisk/disks_controller_test.rb +65 -25
  60. data/test/test_plugin_helper.rb +21 -3
  61. data/test/unit/concerns/host_test.rb +12 -1
  62. data/test/unit/concerns/orchestration/compute_test.rb +32 -13
  63. data/test/unit/foreman_bootdisk/renderer_test.rb +1 -1
  64. data/test/unit/iso_generator_test.rb +6 -7
  65. metadata +14 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4733307c911d25a22301bdb3527422e04e4ab2491c2210b914f3c27d00ca1ea2
4
- data.tar.gz: 14955cfafbe62b393e45927a36805173a00e41f8bf0e4868f7f11026bc260fac
3
+ metadata.gz: ca80bb43629c291c9d6b27bb8c94ebd10fcc2e6e267378e4852ab42bdcee0088
4
+ data.tar.gz: 743d4a31beef4d80d6ab5b025cf6261bbbb11cb62eb82b65d8f7c5aaed58c9fb
5
5
  SHA512:
6
- metadata.gz: b605a6809d4cfa2c2fee39e1744c54f4114b1b05d64e46e983cf2f4d3344766b4173d6a4519e1758e2afc30d0f0aa12b64e013208d2f706828ae8aa8fb8381d7
7
- data.tar.gz: 2497d42c876c57097cde13de621696b3fb60140238ef00585e49e76980a6d28d12bd0c4931120648f2af20ef55d9f9865522eb59a2a74a71673d3634a169e66d
6
+ metadata.gz: 1915d2f7f01f58ec795f343707fe7a6d24f49af0ce6fb6ee9577f3279749e74f5cfb74b7ee707f3eea0e972b92344bc7d10a30f7be9556bffe8be2a39315526d
7
+ data.tar.gz: b21943b356b209d60ad7cd1bc655a81c042ef93534fb94f719c271688f64f42a2f2ea3ba21a10280b388861fd061d1e08df498de216dc233f27a92e10065c942
@@ -0,0 +1,19 @@
1
+ name: Rubocop
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ rubocop:
7
+ runs-on: ubuntu-latest
8
+ env:
9
+ BUNDLE_FOREMAN: '0'
10
+ BUNDLE_WITHOUT: development:test
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - name: Setup Ruby
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: 2.5
17
+ bundler-cache: true
18
+ - name: Run rubocop
19
+ run: bundle exec rubocop -P --format github
data/.tx/config CHANGED
@@ -1,7 +1,7 @@
1
1
  [main]
2
2
  host = https://www.transifex.com
3
3
 
4
- [foreman.bootdisk]
4
+ [foreman.foreman_bootdisk]
5
5
  file_filter = locale/<lang>/foreman_bootdisk.edit.po
6
6
  source_file = locale/foreman_bootdisk.pot
7
7
  source_lang = en
data/AUTHORS CHANGED
@@ -1,20 +1,31 @@
1
+ Adam Ruzicka
2
+ Bernhard Suttner
1
3
  Bryan Kearney
4
+ crito
5
+ Damon Maria
2
6
  Dominic Cleal
7
+ Dominik Matoulek
3
8
  Greg Sutcliffe
4
9
  Ido Kanner
5
10
  Jon Fautley
6
11
  Justin Sherrill
12
+ Leos Stejskal
7
13
  Lukas Zapletal
8
14
  Lukáš Zapletal
9
15
  Marek Hulan
10
16
  Marek Hulán
17
+ Markus Bucher
11
18
  Martin Bačovský
12
19
  Michael Hofer
13
20
  Michael Moll
14
21
  Ohad Levy
22
+ Oleh Fedorenko
15
23
  Ondrej Prazak
24
+ Ondřej Ezr
16
25
  Ondřej Pražák
26
+ Pat Riehecky
17
27
  Robert Antoni Buj Gelonch
28
+ Rohan21Lobo
18
29
  Ronald van Zantvoort
19
30
  Sam Kottler
20
31
  Sean O'Keeffe
data/README.md CHANGED
@@ -50,6 +50,10 @@ gPXE images are unsupported due to lack of initrd support.
50
50
  | >= 1.19 | ~> 13.0 |
51
51
  | >= 1.20 | ~> 14.0 |
52
52
  | >= 1.21 | ~> 15.0 |
53
+ | >= 1.23 | ~> 16.0 |
54
+ | >= 1.24 | ~> 16.1 |
55
+ | >= 2.0 | ~> 16.1 |
56
+ | >= 2.1 | ~> 17.0 |
53
57
 
54
58
  # Usage
55
59
 
@@ -119,6 +123,7 @@ TFTP settings are needed.
119
123
  <th>DHCP reservation</th>
120
124
  <th>Pre-register host</th>
121
125
  <th>OS-specific</th>
126
+ <th>EFI supported</th>
122
127
  </tr>
123
128
  <tr>
124
129
  <td>Per-host image</td>
@@ -127,6 +132,7 @@ TFTP settings are needed.
127
132
  <td>No</td>
128
133
  <td>Yes</td>
129
134
  <td>No</td>
135
+ <td>No</td>
130
136
  </tr>
131
137
  <tr>
132
138
  <td>Full host image</td>
@@ -135,6 +141,7 @@ TFTP settings are needed.
135
141
  <td>No</td>
136
142
  <td>Yes</td>
137
143
  <td>Yes</td>
144
+ <td>Yes</td>
138
145
  </tr>
139
146
  <tr>
140
147
  <td>Generic image</td>
@@ -143,6 +150,7 @@ TFTP settings are needed.
143
150
  <td>No</td>
144
151
  <td>Yes</td>
145
152
  <td>No</td>
153
+ <td>No</td>
146
154
  </tr>
147
155
  <tr>
148
156
  <td>Subnet image</td>
@@ -151,6 +159,7 @@ TFTP settings are needed.
151
159
  <td>No</td>
152
160
  <td>Yes</td>
153
161
  <td>No</td>
162
+ <td>Yes</td>
154
163
  </tr>
155
164
  </table>
156
165
 
@@ -236,6 +245,22 @@ To generate from the command line on the Foreman server:
236
245
  Set `OUTPUT=/path` to change the output destination path (directory or file).
237
246
  It must be writable by the 'foreman' user.
238
247
 
248
+ ### Generic static image
249
+
250
+ This is generic image type which asks for network credentials instead of doing
251
+ DHCP request. Tokens must be turned off in order to find the host by MAC
252
+ address. To do that, set Token duration to 0 in Administer - Settings.
253
+
254
+ - Network interface name
255
+ - IP Address
256
+ - Netmask
257
+ - Gateway
258
+ - DNS
259
+
260
+ To use generic static host image, set "Generic image template" to "Bootdisk
261
+ iPXE - host template" in Administer - Settings - Boot disk. Only one template
262
+ can be used at one time across all hosts.
263
+
239
264
  ### Subnet images
240
265
 
241
266
  Subnet images are similar to generic images, but chain-loading is done via the
@@ -0,0 +1,16 @@
1
+ module AllowedActions
2
+ extend ActiveSupport::Concern
3
+
4
+ def bootdisk_type_allowed?(action = params[:action])
5
+ return true if Setting::Bootdisk.allowed_types&.include?(action)
6
+
7
+ message = _('This type of bootdisk is not allowed. Please contact administrator.')
8
+ if api_request?
9
+ render_error :custom_error, status: :unprocessable_entity, locals: { message: message}
10
+ else
11
+ error(message)
12
+ redirect_back(fallback_location: '/')
13
+ end
14
+ false
15
+ end
16
+ end
@@ -7,11 +7,13 @@ module ForemanBootdisk
7
7
  module V2
8
8
  class DisksController < ::Api::V2::BaseController
9
9
  include ::Api::Version2
10
+ include AllowedActions
10
11
 
11
12
  resource_description do
12
13
  api_base_url '/bootdisk/api'
13
14
  end
14
15
 
16
+ before_action :bootdisk_type_allowed?, only: :generic
15
17
  before_action :find_resource, only: :host
16
18
  skip_after_action :log_response_body
17
19
 
@@ -21,9 +23,10 @@ module ForemanBootdisk
21
23
 
22
24
  api :GET, '/generic', N_('Download generic image')
23
25
  def generic
26
+ # EFI not supported for iPXE generic bootdisk
24
27
  tmpl = ForemanBootdisk::Renderer.new.generic_template_render
25
28
  ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
26
- send_data read_file(iso), filename: "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso"
29
+ send_file(iso, filename: "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso")
27
30
  end
28
31
  end
29
32
 
@@ -33,23 +36,22 @@ module ForemanBootdisk
33
36
  def host
34
37
  host = @disk
35
38
  if params[:full]
39
+ return unless bootdisk_type_allowed?('full_host')
36
40
  ForemanBootdisk::ISOGenerator.generate_full_host(host) do |iso|
37
- send_data read_file(iso), filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso"
41
+ send_file(iso, filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso")
38
42
  end
39
43
  else
44
+ return unless bootdisk_type_allowed?
45
+ # EFI not supported for iPXE host bootdisk
40
46
  tmpl = host.bootdisk_template_render
41
47
  ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
42
- send_data read_file(iso), filename: "#{host.name}.iso"
48
+ send_file(iso, filename: "#{host.name}.iso")
43
49
  end
44
50
  end
45
51
  end
46
52
 
47
53
  private
48
54
 
49
- def read_file(filename)
50
- File.read(filename)
51
- end
52
-
53
55
  def resource_scope
54
56
  Host::Managed.authorized('view_hosts')
55
57
  end
@@ -7,11 +7,14 @@ module ForemanBootdisk
7
7
  module V2
8
8
  class SubnetDisksController < ::Api::V2::BaseController
9
9
  include ::Api::Version2
10
+ include AllowedActions
10
11
 
11
12
  resource_description do
12
13
  api_base_url '/bootdisk/api'
13
14
  end
14
15
 
16
+ rescue_from ActiveRecord::RecordNotFound, :with => :subnet_not_found
17
+ before_action :bootdisk_type_allowed?, only: :subnet
15
18
  before_action :find_resource, only: :subnet
16
19
 
17
20
  skip_after_action :log_response_body
@@ -25,10 +28,15 @@ module ForemanBootdisk
25
28
  def subnet
26
29
  subnet = @subnet_disk
27
30
  subnet.tftp || raise(::Foreman::Exception.new(N_('TFTP feature not enabled for subnet %s'), subnet.name))
28
- tmpl = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
29
- ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
30
- name = subnet.name
31
- send_data File.read(iso), filename: "bootdisk_subnet_#{name}.iso"
31
+ tmpl_bios = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
32
+ tmpl_efi = nil
33
+ if subnet.httpboot
34
+ tmpl_efi = ForemanBootdisk::Renderer.new.generic_efi_template_render(subnet)
35
+ else
36
+ ForemanBootdisk.logger.warn('HTTPBOOT feature is not enabled for subnet %s, UEFI may not be available for bootdisk' % subnet.name)
37
+ end
38
+ ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl_bios, grub: tmpl_efi) do |temp_iso_filename|
39
+ send_file(temp_iso_filename, filename: subnet.name)
32
40
  end
33
41
  end
34
42
 
@@ -37,6 +45,10 @@ module ForemanBootdisk
37
45
  def resource_scope
38
46
  Subnet.authorized('view_subnets')
39
47
  end
48
+
49
+ def subnet_not_found
50
+ not_found ("Subnet not found by id '%s'") % params[:id]
51
+ end
40
52
  end
41
53
  end
42
54
  end
@@ -4,6 +4,9 @@ require 'uri'
4
4
 
5
5
  module ForemanBootdisk
6
6
  class DisksController < ::ApplicationController
7
+ include AllowedActions
8
+
9
+ before_action :bootdisk_type_allowed?, except: :help
7
10
  before_action :find_resource, only: %w[host full_host subnet]
8
11
 
9
12
  # as this engine is isolated, we need to include url helpers from core explicitly
@@ -12,6 +15,7 @@ module ForemanBootdisk
12
15
 
13
16
  def generic
14
17
  begin
18
+ # EFI not supported for iPXE generic bootdisk
15
19
  tmpl = ForemanBootdisk::Renderer.new.generic_template_render
16
20
  rescue StandardError => e
17
21
  error_rendering(e)
@@ -20,13 +24,14 @@ module ForemanBootdisk
20
24
  end
21
25
 
22
26
  ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
23
- send_data read_file(iso), filename: "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso"
27
+ send_file(iso, filename: "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso")
24
28
  end
25
29
  end
26
30
 
27
31
  def host
28
32
  host = @disk
29
33
  begin
34
+ # EFI not supported for iPXE host bootdisk
30
35
  tmpl = host.bootdisk_template_render
31
36
  rescue StandardError => e
32
37
  error_rendering(e)
@@ -35,14 +40,14 @@ module ForemanBootdisk
35
40
  end
36
41
 
37
42
  ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
38
- send_data read_file(iso), filename: "#{host.name}.iso"
43
+ send_file(iso, filename: "#{host.name}.iso")
39
44
  end
40
45
  end
41
46
 
42
47
  def full_host
43
48
  host = @disk
44
49
  ForemanBootdisk::ISOGenerator.generate_full_host(host) do |iso|
45
- send_data read_file(iso), filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso"
50
+ send_file(iso, filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso")
46
51
  end
47
52
  end
48
53
 
@@ -51,15 +56,18 @@ module ForemanBootdisk
51
56
  begin
52
57
  subnet = host.try(:subnet) || raise(::Foreman::Exception.new(N_('Subnet is not assigned to the host %s'), host.name))
53
58
  subnet.tftp || raise(::Foreman::Exception.new(N_('TFTP feature not enabled for subnet %s'), subnet.name))
54
- tmpl = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
59
+ subnet.httpboot || ForemanBootdisk.logger.warn('HTTPBOOT feature is not enabled for subnet %s, UEFI may not be available for bootdisk' % subnet.name)
60
+
61
+ tmpl_bios = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
62
+ tmpl_efi = ForemanBootdisk::Renderer.new.generic_efi_template_render(subnet)
55
63
  rescue StandardError => e
56
64
  error_rendering(e)
57
65
  redirect_back(fallback_location: '/')
58
66
  return
59
67
  end
60
68
 
61
- ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
62
- send_data read_file(iso), filename: "bootdisk_subnet_#{subnet.name}.iso"
69
+ ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl_bios, grub: tmpl_efi) do |iso|
70
+ send_file(iso, filename: "bootdisk_subnet_#{subnet.name}.iso")
63
71
  end
64
72
  end
65
73
 
@@ -67,10 +75,6 @@ module ForemanBootdisk
67
75
 
68
76
  private
69
77
 
70
- def read_file(filename)
71
- File.read(filename)
72
- end
73
-
74
78
  def resource_scope(_controller = controller_name)
75
79
  Host::Managed.authorized(:view_hosts)
76
80
  end
@@ -2,75 +2,40 @@
2
2
 
3
3
  module ForemanBootdisk
4
4
  module HostsHelperExt
5
- def host_title_actions(*args)
6
- if @host.bootdisk_downloadable?
5
+ def host_title_actions(host)
6
+ if host.bootdisk_downloadable?
7
7
  title_actions(
8
8
  button_group(
9
9
  select_action_button(
10
10
  _('Boot disk'), { class: 'btn btn-group' },
11
- display_bootdisk_link_if_authorized(
12
- _("Host '%s' image") % @host.name.split('.')[0],
13
- {
14
- controller: 'foreman_bootdisk/disks',
15
- action: 'host',
16
- id: @host
17
- },
18
- class: 'la'
19
- ),
20
- display_bootdisk_link_if_authorized(
21
- _("Full host '%s' image") % @host.name.split('.')[0],
22
- {
23
- controller: 'foreman_bootdisk/disks',
24
- action: 'full_host',
25
- id: @host
26
- },
27
- class: 'la'
28
- ),
29
- content_tag(:li, '', class: 'divider'),
30
- display_bootdisk_link_if_authorized(
31
- _('Generic image'),
32
- {
33
- controller: 'foreman_bootdisk/disks',
34
- action: 'generic'
35
- },
36
- class: 'la'
37
- ),
38
- display_bootdisk_for_subnet,
39
- content_tag(:li, '', class: 'divider'),
40
- display_bootdisk_link_if_authorized(
41
- _('Help'), {
42
- controller: 'foreman_bootdisk/disks',
43
- action: 'help'
44
- },
45
- class: 'la'
46
- )
11
+ host_action_buttons(host)
47
12
  )
48
13
  )
49
14
  )
50
15
  else
51
- bootdisk_button_disabled
16
+ bootdisk_button_disabled(host)
52
17
  end
53
18
 
54
19
  super
55
20
  end
56
21
 
57
- def bootdisk_button_disabled
22
+ def bootdisk_button_disabled(host)
58
23
  title_actions(
59
24
  button_group(
60
25
  link_to(_('Boot disk'), '#', disabled: true, class: 'btn btn-default',
61
- title: _('Boot disk download not available for %s architecture') % @host.architecture.name)
26
+ title: _('Boot disk download not available for %s architecture') % host.architecture.name)
62
27
  )
63
28
  )
64
29
  end
65
30
 
66
31
  # need to wrap this one in a test for template proxy presence
67
- def display_bootdisk_for_subnet
68
- if (proxy = @host.try(:subnet).try(:tftp)) && proxy.has_feature?('Templates')
32
+ def display_bootdisk_for_subnet(host)
33
+ if (proxy = host.try(:subnet).try(:tftp) || host.try(:subnet).try(:httpboot)) && proxy.has_feature?('Templates')
69
34
  display_bootdisk_link_if_authorized(
70
- _("Subnet '%s' generic image") % @host.subnet.name, {
35
+ _("Subnet '%s' generic image") % host.subnet.name, {
71
36
  controller: 'foreman_bootdisk/disks',
72
37
  action: 'subnet',
73
- id: @host
38
+ id: host
74
39
  },
75
40
  class: 'la'
76
41
  )
@@ -95,5 +60,66 @@ module ForemanBootdisk
95
60
  def bootdisk_authorized_for(options)
96
61
  User.current.allowed_to?(options)
97
62
  end
63
+
64
+ def host_action_buttons(host)
65
+ actions = []
66
+
67
+ allowed_actions = Setting::Bootdisk.allowed_types
68
+ return '' unless allowed_actions
69
+
70
+ host_image_link = display_bootdisk_link_if_authorized(
71
+ _("Host '%s' image") % host.name.split('.')[0],
72
+ {
73
+ controller: 'foreman_bootdisk/disks',
74
+ action: 'host',
75
+ id: host
76
+ },
77
+ class: 'la'
78
+ )
79
+
80
+ full_host_image_link = display_bootdisk_link_if_authorized(
81
+ _("Full host '%s' image") % host.name.split('.')[0],
82
+ {
83
+ controller: 'foreman_bootdisk/disks',
84
+ action: 'full_host',
85
+ id: host
86
+ },
87
+ class: 'la'
88
+ )
89
+
90
+ generic_image_link = display_bootdisk_link_if_authorized(
91
+ _('Generic image'),
92
+ {
93
+ controller: 'foreman_bootdisk/disks',
94
+ action: 'generic'
95
+ },
96
+ class: 'la'
97
+ )
98
+
99
+ help_link = display_bootdisk_link_if_authorized(
100
+ _('Help'),
101
+ {
102
+ controller: 'foreman_bootdisk/disks',
103
+ action: 'help'
104
+ },
105
+ class: 'la'
106
+ )
107
+
108
+ divider = tag(:li, '', class: 'divider')
109
+
110
+ actions << host_image_link if allowed_actions.include?('host')
111
+ actions << full_host_image_link if allowed_actions.include?('full_host')
112
+
113
+ subnet_link = display_bootdisk_for_subnet(host)
114
+ actions << divider if allowed_actions.include?('generic') || (allowed_actions.include?('subnet') && subnet_link.present?)
115
+
116
+ actions << generic_image_link if allowed_actions.include?('generic')
117
+ actions << subnet_link if allowed_actions.include?('subnet')
118
+
119
+ actions << divider
120
+ actions << help_link
121
+
122
+ actions
123
+ end
98
124
  end
99
125
  end