foreman_bootdisk 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dbe2e8426146b25ce78dea249b33ba9f35293b1
4
- data.tar.gz: 0741b50ad7795889f4f694687c25fef87f1c39fa
3
+ metadata.gz: e51cb397e2135c07a5e7d3964e190cefe4852e04
4
+ data.tar.gz: db451601c84e35db1492de7a5246fd4f8143c920
5
5
  SHA512:
6
- metadata.gz: c8c7dd29e0e76766b8408a1611bf5c7a5d18d54adb7fa4961929f8d642418a853b271c85d2b3c2db69179f053c4b29ddad10aae05a8b5dd3f4cd5f8c42653e2b
7
- data.tar.gz: 99eabe8b84e51cb47ca8a7503a2d2663c92d6a27ea7409116ed3594c5a1f0cc62165d8d01d98275c43d4e81cff30992214e32ccaf7f99f259bbd411446122734
6
+ metadata.gz: 7c750aeff74a5fb650288c67f540227ccaa765ef0544402fdf912de87fb9123fae5a547bf542a53171b25a1b68cb38692a070732fc6106cd2a4dea3b6c71d5dc
7
+ data.tar.gz: 72b036286e3d93af852e05fc2c5c56430037ecb50b15cba5b6d44ddfcf5274cf09cda537d19093305e1c68426fd7722396c24435423cd1ada301c48100cab631
data/CHANGES.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.0.5
4
+ * safemode compatibility under Foreman 1.5
5
+
3
6
  ## v2.0.4
4
7
  * fix Foreman 1.5 host show page compatibility
5
8
  * updates to README
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  module Bootdisk::HostExt
2
4
  extend ActiveSupport::Concerns
3
5
 
@@ -6,10 +8,22 @@ module Bootdisk::HostExt
6
8
  end
7
9
 
8
10
  def bootdisk_template_render
9
- # Waiting on additional whitelisted items, #2948
10
- Setting[:safemode_render] && raise(::Foreman::Exception.new(N_('Bootdisk is not supported with safemode rendering, please disable safemode_render under Adminster>Settings')))
11
+ if (Gem::Version.new(SETTINGS[:version].notag) < Gem::Version.new('1.5')) && Setting[:safemode_render]
12
+ raise(::Foreman::Exception.new(N_('Bootdisk is not supported with safemode rendering, please disable safemode_render under Adminster>Settings')))
13
+ end
11
14
 
12
15
  @host = self
13
16
  pxe_render(bootdisk_template.template)
14
17
  end
18
+
19
+ def bootdisk_chain_url(mac = self.mac, action = 'iPXE')
20
+ u = URI.parse(foreman_url(action))
21
+ u.query = "#{u.query}&mac=#{mac}"
22
+ u.fragment = nil
23
+ u.to_s
24
+ end
25
+
26
+ def bootdisk_raise(*args)
27
+ raise ::Foreman::Exception.new(*args)
28
+ end
15
29
  end
@@ -1,15 +1,25 @@
1
+ require 'uri'
2
+
1
3
  module Bootdisk
2
4
  class Renderer
3
5
  include ::Foreman::Renderer
4
6
  include Rails.application.routes.url_helpers
5
7
 
6
8
  def generic_template_render
7
- # Waiting on additional whitelisted items, #2948
8
- Setting[:safemode_render] && raise(::Foreman::Exception.new(N_('Bootdisk is not supported with safemode rendering, please disable safemode_render under Adminster>Settings')))
9
+ if (Gem::Version.new(SETTINGS[:version].notag) < Gem::Version.new('1.5')) && Setting[:safemode_render]
10
+ raise(::Foreman::Exception.new(N_('Bootdisk is not supported with safemode rendering, please disable safemode_render under Adminster>Settings')))
11
+ end
9
12
 
10
13
  tmpl = ConfigTemplate.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'))
11
14
  @host = Struct.new(:token).new(nil)
12
15
  unattended_render(tmpl.template)
13
16
  end
17
+
18
+ def bootdisk_chain_url(action = 'iPXE')
19
+ u = URI.parse(foreman_url(action))
20
+ u.query = "#{u.query}&mac="
21
+ u.fragment = nil
22
+ u.to_s
23
+ end
14
24
  end
15
25
  end
@@ -15,7 +15,7 @@
15
15
  isset ${net<%= i -%>/mac} || goto no_nic
16
16
  echo net<%= i -%> is a ${net<%= i -%>/chip} with MAC ${net<%= i -%>/mac}
17
17
  dhcp net<%= i %> || goto net<%= i+1 %>
18
- chain <%= (u = URI.parse(foreman_url("iPXE")); u.query = "#{u.query}&mac="; u.to_s) %>${net<%= i -%>/mac} || goto net<%= i+1 %>
18
+ chain <%= bootdisk_chain_url %>${net<%= i -%>/mac} || goto net<%= i+1 %>
19
19
  exit 0
20
20
  <% end -%>
21
21
 
@@ -5,11 +5,11 @@
5
5
  # Copy this template to customize it, the original is read-only.
6
6
 
7
7
  <%
8
- raise ::Foreman::Exception.new(N_('Host has no IP address defined')) if @host.ip.empty?
9
- raise ::Foreman::Exception.new(N_('Host has no subnet defined')) if @host.subnet.nil?
10
- raise ::Foreman::Exception.new(N_('Host has no domain defined')) if @host.domain.nil?
11
- raise ::Foreman::Exception.new(N_('Subnet (%s) has no gateway defined'), @host.subnet) if @host.subnet.gateway.empty?
12
- raise ::Foreman::Exception.new(N_('Subnet (%s) has no primary DNS server defined'), @host.subnet) if @host.subnet.dns_primary.empty?
8
+ bootdisk_raise(N_('Host has no IP address defined')) if @host.ip.empty?
9
+ bootdisk_raise(N_('Host has no subnet defined')) unless @host.subnet
10
+ bootdisk_raise(N_('Host has no domain defined')) unless @host.domain
11
+ bootdisk_raise(N_('Subnet (%s) has no gateway defined'), @host.subnet) if @host.subnet.gateway.empty?
12
+ bootdisk_raise(N_('Subnet (%s) has no primary DNS server defined'), @host.subnet) if @host.subnet.dns_primary.empty?
13
13
  %>
14
14
 
15
15
  # loop over net* until the host's MAC matches
@@ -37,7 +37,7 @@ set domain <%= @host.domain.to_s %>
37
37
 
38
38
  # Chainload from Foreman rather than embedding OS info here, so the behaviour
39
39
  # is entirely dynamic.
40
- chain <%= (u = URI.parse(foreman_url("iPXE")); u.query ="#{u.query}&mac=#{@host.mac}"; u.to_s) %>
40
+ chain <%= bootdisk_chain_url %>
41
41
  exit 0
42
42
 
43
43
  :no_nic
@@ -28,6 +28,8 @@ module Bootdisk
28
28
  end
29
29
 
30
30
  role "Boot disk access", [:download_bootdisk] unless (Role.count rescue nil).nil?
31
+
32
+ allowed_template_helpers :bootdisk_chain_url, :bootdisk_raise if respond_to? :allowed_template_helpers
31
33
  end
32
34
  end
33
35
 
@@ -1,3 +1,3 @@
1
1
  module Bootdisk
2
- VERSION = '2.0.4'
2
+ VERSION = '2.0.5'
3
3
  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: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Cleal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
11
+ date: 2014-05-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Plugin for Foreman that creates iPXE-based boot disks to provision hosts
14
14
  without the need for PXE infrastructure.