foreman_bootdisk 6.0.0 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +5 -0
  3. data/README.md +46 -2
  4. data/app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb +37 -0
  5. data/app/controllers/foreman_bootdisk/disks_controller.rb +26 -3
  6. data/app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb +12 -0
  7. data/app/models/concerns/foreman_bootdisk/host_ext.rb +1 -4
  8. data/app/services/foreman_bootdisk/iso_generator.rb +4 -4
  9. data/app/services/foreman_bootdisk/renderer.rb +25 -6
  10. data/app/views/foreman_bootdisk/disks/help.html.erb +9 -1
  11. data/app/views/foreman_bootdisk/generic_host.erb +2 -1
  12. data/config/routes.rb +2 -0
  13. data/db/migrate/20140522185700_change_templatekind_to_bootdisk.rb +1 -1
  14. data/db/seeds.d/50-bootdisk_templates.rb +17 -15
  15. data/lib/foreman_bootdisk.rb +1 -2
  16. data/lib/foreman_bootdisk/engine.rb +8 -2
  17. data/lib/foreman_bootdisk/version.rb +1 -1
  18. data/lib/tasks/bootdisk.rake +12 -0
  19. data/locale/ca/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  20. data/locale/ca/foreman_bootdisk.po +167 -0
  21. data/locale/de/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  22. data/locale/de/foreman_bootdisk.po +18 -17
  23. data/locale/en/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  24. data/locale/en/foreman_bootdisk.po +85 -39
  25. data/locale/en_GB/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  26. data/locale/en_GB/foreman_bootdisk.po +26 -25
  27. data/locale/es/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  28. data/locale/es/foreman_bootdisk.po +6 -5
  29. data/locale/foreman_bootdisk.pot +145 -44
  30. data/locale/fr/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  31. data/locale/fr/foreman_bootdisk.po +10 -10
  32. data/locale/it/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  33. data/locale/it/foreman_bootdisk.po +3 -3
  34. data/locale/ja/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  35. data/locale/ja/foreman_bootdisk.po +14 -13
  36. data/locale/ko/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  37. data/locale/ko/foreman_bootdisk.po +3 -3
  38. data/locale/pt_BR/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  39. data/locale/pt_BR/foreman_bootdisk.po +8 -7
  40. data/locale/ru/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  41. data/locale/ru/foreman_bootdisk.po +28 -27
  42. data/locale/sv_SE/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  43. data/locale/sv_SE/foreman_bootdisk.po +3 -3
  44. data/locale/zh_CN/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  45. data/locale/zh_CN/foreman_bootdisk.po +3 -3
  46. data/locale/zh_TW/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  47. data/locale/zh_TW/foreman_bootdisk.po +3 -3
  48. data/test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb +4 -2
  49. data/test/functional/foreman_bootdisk/api/v2/subnet_disks_controller_test.rb +20 -0
  50. data/test/functional/foreman_bootdisk/disks_controller_test.rb +26 -2
  51. data/test/test_plugin_helper.rb +16 -4
  52. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffdf260d555ad64c9c24397f293902ab11750afe
4
- data.tar.gz: 737a352d301347d4cf8a7549822e7e1b0cb5ae95
3
+ metadata.gz: a8a61c973be01e36e750806d001adeb4787dd22c
4
+ data.tar.gz: 759b57674e0090025cbbf30bbae4b31a3ff9a994
5
5
  SHA512:
6
- metadata.gz: 51d13826e62222446b190c2d031f24a9cbd360f8e3e8f7aab0024b2b392edafd1b56a01c6f000594581cef58c8e8fed27e529fdb434ca737f5d91c5afc7e01e0
7
- data.tar.gz: d3c6946fe6fbdede2d47edeb0844dbbc3625bf46ad1e7dfdf07e4aa695967de44d70aef37dc8ad7f1dfbe635fdfb4ffc5a7eb1ed00b3f6481940316349db222d
6
+ metadata.gz: 0e1f1a9790e67338e9e846f075da4ad20da44c8d659c15a973712d5f020c3f40fe40225593339c2b704bec1c956179eb316039b11e462433ed449eef3d649054
7
+ data.tar.gz: 76bcadb8a821cd544a2d912058e6c72e920134b01f5e216cb1ed6a638ed08a14e6e85413d622302b9f41aede0e18bedfbf42462cdaeef43011707d1cda7e9656
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v6.1.0
4
+ * add subnet-level generic image relying on template smart proxy (#8146)
5
+ * add Catalan translation
6
+ * fix compatibility with Rails 4 for Foreman 1.11
7
+
3
8
  ## v6.0.0
4
9
  * compatibility with Foreman 1.9 template changes (#10773)
5
10
  * generate correct links under sub-URI (#10494)
data/README.md CHANGED
@@ -123,6 +123,14 @@ TFTP settings are needed.
123
123
  <td>Yes</td>
124
124
  <td>No</td>
125
125
  </tr>
126
+ <tr>
127
+ <td>Subnet image</td>
128
+ <td>Yes</td>
129
+ <td>Yes</td>
130
+ <td>No</td>
131
+ <td>Yes</td>
132
+ <td>No</td>
133
+ </tr>
126
134
  </table>
127
135
 
128
136
  ### Per-host images
@@ -154,8 +162,9 @@ It must be writable by the 'foreman' user.
154
162
  A variant of the per-host image, this version doesn't chainload from Foreman,
155
163
  but contains the initial OS bootloader. It can be useful for hosts that fail
156
164
  to chainload correctly, but has the downsides that it may become out of date
157
- if the host OS, bootloader or templates change, or build tokens are required
158
- and expire.
165
+ if the host OS, bootloader or PXELinux templates change, or build tokens are
166
+ required and expire. The provisioning template is still fetched from the
167
+ Foreman server.
159
168
 
160
169
  To generate the image from the web interface, view the host page, click the
161
170
  "Boot disk" button and select "Full host 'FQDN' image". This image may take
@@ -204,6 +213,33 @@ To generate from the command line on the Foreman server:
204
213
  Set `OUTPUT=/path` to change the output destination path (directory or file).
205
214
  It must be writable by the 'foreman' user.
206
215
 
216
+ ### Subnet images
217
+
218
+ Subnet images are similar to generic images, but chain-loading is done via the
219
+ TFTP Smart Proxy assigned to the Subnet of the host. The smart proxy must have
220
+ the "Templates" module enabled and configured.
221
+
222
+ This image is generic for all hosts with a provisioning NIC on that subnet.
223
+
224
+ To generate the image from the web interface, view a host page, click the
225
+ "Boot disk" button and select "Subnet image".
226
+
227
+ To generate using the Hammer CLI, install the [hammer_cli_foreman_bootdisk](https://github.com/theforeman/hammer_cli_foreman_bootdisk)
228
+ plugin and run:
229
+
230
+ hammer bootdisk subnet --subnet local.lan
231
+
232
+ See the hammer_cli_foreman_bootdisk documentation for more advanced usage.
233
+
234
+ To generate from the command line on the Foreman server:
235
+
236
+ foreman-rake bootdisk:generate:subnet NAME=subnet-name
237
+
238
+ Note that foreman-rake does connect to the foreman-proxy.
239
+
240
+ Set `OUTPUT=/path` to change the output destination path (directory or file).
241
+ It must be writable by the 'foreman' user.
242
+
207
243
  ### Host group images
208
244
 
209
245
  TODO
@@ -244,6 +280,14 @@ the Foreman UI.
244
280
  * `bootdisk_cache_media` controls whether to cache OS boot files from
245
281
  installation media for full host images
246
282
 
283
+ ### RBAC
284
+
285
+ This plugin provides "Boot disk access" role which requires the following
286
+ permissions to be present to allow host and subnet image downloading:
287
+
288
+ * `view_hosts`
289
+ * `view_subnets`
290
+
247
291
  # Issues
248
292
 
249
293
  Report issues on the Redmine project: [foreman_bootdisk](http://projects.theforeman.org/projects/bootdisk/issues/new)
@@ -0,0 +1,37 @@
1
+ require 'uri'
2
+
3
+ module ForemanBootdisk::Api::V2
4
+ class SubnetDisksController < ::Api::V2::BaseController
5
+ include ::Api::Version2
6
+
7
+ resource_description do
8
+ api_base_url "/bootdisk/api"
9
+ end
10
+
11
+ before_filter :find_resource, :only => :subnet
12
+
13
+ skip_after_filter :log_response_body
14
+
15
+ # no-op, but required for apipie documentation
16
+ api :GET, '', N_('Subnet boot disks')
17
+ def index; end
18
+
19
+ api :GET, '/subnets/:subnet_id', N_('Download subnet generic image')
20
+ param :subnet_id, :identifier_dottable, :required => true
21
+ def subnet
22
+ subnet = @subnet_disk
23
+ subnet.tftp || raise(::Foreman::Exception.new(N_("TFTP feature not enabled for subnet %s"), subnet.name))
24
+ tmpl = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
25
+ ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl) do |iso|
26
+ name=subnet.name
27
+ send_data File.read(iso), :filename => "bootdisk_subnet_#{name}.iso"
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def resource_scope
34
+ Subnet.authorized('view_subnets')
35
+ end
36
+ end
37
+ end
@@ -2,13 +2,13 @@ require 'uri'
2
2
 
3
3
  module ForemanBootdisk
4
4
  class DisksController < ::ApplicationController
5
- before_filter :find_resource, :only => %w[host full_host]
5
+ before_filter :find_resource, :only => %w[host full_host subnet]
6
6
 
7
7
  def generic
8
8
  begin
9
9
  tmpl = ForemanBootdisk::Renderer.new.generic_template_render
10
10
  rescue => e
11
- error _('Failed to render boot disk template: %s') % e
11
+ error_rendering(e)
12
12
  redirect_to :back
13
13
  return
14
14
  end
@@ -23,7 +23,7 @@ module ForemanBootdisk
23
23
  begin
24
24
  tmpl = host.bootdisk_template_render
25
25
  rescue => e
26
- error _('Failed to render boot disk template: %s') % e
26
+ error_rendering(e)
27
27
  redirect_to :back
28
28
  return
29
29
  end
@@ -40,6 +40,23 @@ module ForemanBootdisk
40
40
  end
41
41
  end
42
42
 
43
+ def subnet
44
+ host = @disk
45
+ begin
46
+ subnet = host.try(:subnet) || raise(::Foreman::Exception.new(N_("Subnet is not assigned to the host %s"), host.name))
47
+ subnet.tftp || raise(::Foreman::Exception.new(N_("TFTP feature not enabled for subnet %s"), subnet.name))
48
+ tmpl = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
49
+ rescue => e
50
+ error_rendering(e)
51
+ redirect_to :back
52
+ return
53
+ end
54
+
55
+ ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl) do |iso|
56
+ send_data File.read(iso), :filename => "bootdisk_subnet_#{subnet.name}.iso"
57
+ end
58
+ end
59
+
43
60
  def help
44
61
  end
45
62
 
@@ -48,5 +65,11 @@ module ForemanBootdisk
48
65
  def resource_scope(controller = controller_name)
49
66
  Host::Managed.authorized(:view_hosts)
50
67
  end
68
+
69
+ def error_rendering(e)
70
+ msg = _('Failed to render boot disk template')
71
+ error("#{msg}: #{e.message}")
72
+ ::Foreman::Logging.exception(msg, e)
73
+ end
51
74
  end
52
75
  end
@@ -11,7 +11,10 @@ module ForemanBootdisk::HostsHelperExt
11
11
  select_action_button(_('Boot disk'), {},
12
12
  display_bootdisk_link_if_authorized(_("Host '%s' image") % @host.name.split('.')[0], {:controller => 'foreman_bootdisk/disks', :action => 'host', :id => @host}, :class=>'btn'),
13
13
  display_bootdisk_link_if_authorized(_("Full host '%s' image") % @host.name.split('.')[0], {:controller => 'foreman_bootdisk/disks', :action => 'full_host', :id => @host}, :class=>'btn'),
14
+ content_tag(:li, "", :class => "divider"),
14
15
  display_bootdisk_link_if_authorized(_("Generic image"), {:controller => 'foreman_bootdisk/disks', :action => 'generic'}, :class=>'btn'),
16
+ display_bootdisk_for_subnet,
17
+ content_tag(:li, "", :class => "divider"),
15
18
  display_bootdisk_link_if_authorized(_("Help"), {:controller => 'foreman_bootdisk/disks', :action => 'help'}, :class=>'btn')
16
19
  )
17
20
  )
@@ -19,6 +22,15 @@ module ForemanBootdisk::HostsHelperExt
19
22
  host_title_actions_without_bootdisk(*args)
20
23
  end
21
24
 
25
+ # need to wrap this one in a test for template proxy presence
26
+ def display_bootdisk_for_subnet
27
+ if (proxy = @host.try(:subnet).try(:tftp)) && proxy.has_feature?('Templates')
28
+ display_bootdisk_link_if_authorized(_("Subnet '%s' generic image") % @host.subnet.name, {:controller => 'foreman_bootdisk/disks', :action => 'subnet', :id => @host}, :class=>'btn')
29
+ else
30
+ ""
31
+ end
32
+ end
33
+
22
34
  # Core Foreman helpers can't look up a URL against a mounted engine
23
35
  def display_bootdisk_link_if_authorized(name, options = {}, html_options = {})
24
36
  if bootdisk_authorized_for(options)
@@ -13,10 +13,7 @@ module ForemanBootdisk::HostExt
13
13
  end
14
14
 
15
15
  def bootdisk_chain_url(mac = self.mac, action = 'iPXE')
16
- u = URI.parse(foreman_url(action))
17
- u.query = "#{u.query}&mac=#{mac}"
18
- u.fragment = nil
19
- u.to_s
16
+ ForemanBootdisk::Renderer.format_bootdisk_chain_url(foreman_url(action), mac)
20
17
  end
21
18
 
22
19
  def bootdisk_raise(*args)
@@ -23,7 +23,7 @@ class ForemanBootdisk::ISOGenerator
23
23
  iso_suffix = iso9660_filename(suffix)
24
24
  iso_f0 = iso9660_filename(f[0].to_s) + '_' + iso_suffix
25
25
  tmpl.gsub!(f[0].to_s + '-' + suffix, iso_f0)
26
- Rails.logger.debug("Boot file #{iso_f0}, source #{f[1]}")
26
+ ForemanBootdisk.logger.debug("Boot file #{iso_f0}, source #{f[1]}")
27
27
  [iso_f0, f[1]]
28
28
  end
29
29
  end
@@ -107,10 +107,10 @@ class ForemanBootdisk::ISOGenerator
107
107
  file.binmode
108
108
 
109
109
  if use_cache && !(contents = Rails.cache.fetch(uri, :raw => true)).nil?
110
- Rails.logger.info("Retrieved #{uri} from local cache (use foreman-rake tmp:cache:clear to empty)")
110
+ ForemanBootdisk.logger.info("Retrieved #{uri} from local cache (use foreman-rake tmp:cache:clear to empty)")
111
111
  file.write(contents)
112
112
  else
113
- Rails.logger.info("Fetching #{uri}")
113
+ ForemanBootdisk.logger.info("Fetching #{uri}")
114
114
  write_cache = use_cache
115
115
  uri = URI(uri)
116
116
  Net::HTTP.start(uri.host, uri.port) do |http|
@@ -126,7 +126,7 @@ class ForemanBootdisk::ISOGenerator
126
126
  end
127
127
 
128
128
  if write_cache
129
- Rails.logger.debug("Caching contents of #{uri}")
129
+ ForemanBootdisk.logger.debug("Caching contents of #{uri}")
130
130
  Rails.cache.write(uri, File.read(path), :raw => true)
131
131
  end
132
132
  end
@@ -4,16 +4,35 @@ module ForemanBootdisk
4
4
  class Renderer
5
5
  include ::Foreman::Renderer
6
6
  include Rails.application.routes.url_helpers
7
+ delegate :logger, :to => :ForemanBootdisk
7
8
 
8
- def generic_template_render
9
+ def generic_template_render(subnet = nil)
9
10
  tmpl = ProvisioningTemplate.find_by_name(Setting[:bootdisk_generic_host_template]) || raise(::Foreman::Exception.new(N_('Unable to find template specified by %s setting'), 'bootdisk_generic_host_template'))
10
- @host = Struct.new(:token, :subnet).new(nil, nil)
11
- unattended_render(tmpl.template)
11
+
12
+ if subnet.present?
13
+ # rendering a subnet-level bootdisk requires tricking the renderer into thinking it has a
14
+ # valid host, with a token, and with a tftp proxy
15
+ @host = Struct.new(:token, :subnet).new(
16
+ Struct.new(:value).new('faketoken'),
17
+ subnet
18
+ )
19
+ else
20
+ @host = Struct.new(:token, :subnet).new(nil,nil)
21
+ end
22
+ modified_template = unattended_render(tmpl.template)
23
+ # remove the token from subnet-level generation, since this is meant to be generic
24
+ modified_template.gsub!(/(?<=iPXE\?)token=faketoken\&(?=mac=)/,'')
25
+ modified_template
26
+ end
27
+
28
+ def bootdisk_chain_url(mac = '', action = 'iPXE')
29
+ Renderer.format_bootdisk_chain_url(foreman_url(action), mac)
12
30
  end
13
31
 
14
- def bootdisk_chain_url(action = 'iPXE')
15
- u = URI.parse(foreman_url(action))
16
- u.query = "#{u.query}&mac="
32
+ def self.format_bootdisk_chain_url(url, mac)
33
+ u = URI.parse(url)
34
+ ForemanBootdisk.logger.warn("Foreman or proxy is configured with HTTPS, probably not supported by iPXE: #{u}") if u.scheme == 'https'
35
+ u.query = "#{u.query}&mac=#{mac}"
17
36
  u.fragment = nil
18
37
  u.to_s
19
38
  end
@@ -19,7 +19,7 @@
19
19
 
20
20
  <h2><%= _('Full host image') %></h2>
21
21
  <p>
22
- <%= _('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 templates.') %>
22
+ <%= _('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
23
  </p>
24
24
 
25
25
  <h2><%= _('Generic image') %></h2>
@@ -29,4 +29,12 @@
29
29
  <p>
30
30
  <%= _('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
31
  </p>
32
+
33
+ <h2><%= _('Subnet image') %></h2>
34
+ <p>
35
+ <%= _('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
+ </p>
37
+ <p>
38
+ <%= _('This image is generic for all hosts with a provisioning NIC on that subnet.') %>
39
+ </p>
32
40
  </div>
@@ -10,12 +10,13 @@
10
10
  # Copy this template to customize it, the original is read-only.
11
11
 
12
12
  # loop over net* until we can get a template
13
+ <% url = bootdisk_chain_url %>
13
14
  <% (0..32).each do |i| -%>
14
15
  :net<%= i %>
15
16
  isset ${net<%= i -%>/mac} || goto no_nic
16
17
  echo net<%= i -%> is a ${net<%= i -%>/chip} with MAC ${net<%= i -%>/mac}
17
18
  dhcp net<%= i %> || goto net<%= i+1 %>
18
- chain <%= bootdisk_chain_url %>${net<%= i -%>/mac} || goto net<%= i+1 %>
19
+ chain <%= url %>${net<%= i -%>/mac} || goto net<%= i+1 %>
19
20
  exit 0
20
21
  <% end -%>
21
22
 
data/config/routes.rb CHANGED
@@ -5,6 +5,7 @@ ForemanBootdisk::Engine.routes.draw do
5
5
  constraints(:id => /[^\/]+/) do
6
6
  get 'hosts/:id', :on => :collection, :to => 'disks#host'
7
7
  get 'full_hosts/:id', :on => :collection, :to => 'disks#full_host'
8
+ get 'subnet/:id', :on => :collection, :to => 'disks#subnet'
8
9
  end
9
10
  end
10
11
 
@@ -13,6 +14,7 @@ ForemanBootdisk::Engine.routes.draw do
13
14
  get 'generic', :to => 'disks#generic'
14
15
  constraints(:id => /[^\/]+/) do
15
16
  get 'hosts/:id', :to => 'disks#host'
17
+ get 'subnets/:id', :to => 'subnet_disks#subnet'
16
18
  end
17
19
  end
18
20
  end
@@ -8,7 +8,7 @@ class ChangeTemplatekindToBootdisk < ActiveRecord::Migration
8
8
  end
9
9
 
10
10
  def self.up
11
- kind = TemplateKind.find_or_create_by_name('Bootdisk')
11
+ kind = TemplateKind.where(:name => 'Bootdisk').first_or_create
12
12
 
13
13
  tmpl_h = Setting.find_by_name('bootdisk_host_template').try(:value)
14
14
  tmpl_g = Setting.find_by_name('bootdisk_generic_host_template').try(:value)
@@ -1,33 +1,35 @@
1
- kind = TemplateKind.find_or_create_by_name('Bootdisk')
1
+ kind = TemplateKind.where(:name => 'Bootdisk').first_or_create
2
2
 
3
3
  ProvisioningTemplate.without_auditing do
4
4
  content = File.read(File.join(ForemanBootdisk::Engine.root, 'app', 'views', 'foreman_bootdisk', 'host.erb'))
5
- tmpl = ProvisioningTemplate.find_or_create_by_name(
6
- :name => 'Boot disk iPXE - host',
7
- :template_kind_id => kind.id,
8
- :snippet => false,
9
- :template => content
10
- )
5
+ tmpl = ProvisioningTemplate.where(:name => 'Boot disk iPXE - host').first_or_create do |template|
6
+ template.attributes = {
7
+ :template_kind_id => kind.id,
8
+ :snippet => false,
9
+ :template => content
10
+ }
11
+ end
11
12
  tmpl.attributes = {
12
13
  :template => content,
13
14
  :default => true,
14
15
  :vendor => "Foreman boot disk",
15
- :locked => true
16
16
  }
17
+ tmpl.locked = true
17
18
  tmpl.save!(:validate => false) if tmpl.changes.present?
18
19
 
19
20
  content = File.read(File.join(ForemanBootdisk::Engine.root, 'app', 'views', 'foreman_bootdisk', 'generic_host.erb'))
20
- tmpl = ProvisioningTemplate.find_or_create_by_name(
21
- :name => 'Boot disk iPXE - generic host',
22
- :template_kind_id => kind.id,
23
- :snippet => false,
24
- :template => content
25
- )
21
+ tmpl = ProvisioningTemplate.where(:name => 'Boot disk iPXE - generic host').first_or_create do |template|
22
+ template.attributes = {
23
+ :template_kind_id => kind.id,
24
+ :snippet => false,
25
+ :template => content
26
+ }
27
+ end
26
28
  tmpl.attributes = {
27
29
  :template => content,
28
30
  :default => true,
29
31
  :vendor => "Foreman boot disk",
30
- :locked => true
31
32
  }
33
+ tmpl.locked = true
32
34
  tmpl.save!(:validate => false) if tmpl.changes.present?
33
35
  end
@@ -1,7 +1,6 @@
1
1
  require 'foreman_bootdisk/version'
2
+ require 'foreman_bootdisk/engine'
2
3
 
3
4
  module ForemanBootdisk
4
5
  ENGINE_NAME = 'foreman_bootdisk'
5
-
6
- require 'foreman_bootdisk/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
7
6
  end
@@ -19,7 +19,9 @@ module ForemanBootdisk
19
19
  end
20
20
 
21
21
  initializer "foreman_bootdisk.load_app_instance_data" do |app|
22
- app.config.paths['db/migrate'] += ForemanBootdisk::Engine.paths['db/migrate'].existent
22
+ ForemanBootdisk::Engine.paths['db/migrate'].existent.each do |path|
23
+ app.config.paths['db/migrate'] << path
24
+ end
23
25
  end
24
26
 
25
27
  initializer "foreman_bootdisk.apipie" do
@@ -31,7 +33,7 @@ module ForemanBootdisk
31
33
  requires_foreman '>= 1.9'
32
34
 
33
35
  security_block :bootdisk do |map|
34
- permission :download_bootdisk, {:'foreman_bootdisk/disks' => [:generic, :host, :full_host, :help],
36
+ permission :download_bootdisk, {:'foreman_bootdisk/disks' => [:generic, :host, :full_host, :subnet, :help],
35
37
  :'foreman_bootdisk/api/v2/disks' => [:generic, :host]}
36
38
  end
37
39
 
@@ -58,4 +60,8 @@ module ForemanBootdisk
58
60
  end
59
61
  end
60
62
  end
63
+
64
+ def self.logger
65
+ Foreman::Logging.logger('foreman_bootdisk')
66
+ end
61
67
  end