foreman_specifictemplate 0.0.3 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68c89daabed0d9840a00c03bab26781138fff284
4
- data.tar.gz: a8c92586e630eef6abb8c26b9e53fb997a9fa220
3
+ metadata.gz: 2070a1537aa93375ca77a16c0e96de2594bddd4b
4
+ data.tar.gz: 83d507a61bf420703190bc30ac07111054546579
5
5
  SHA512:
6
- metadata.gz: 75414573f75af2218e99f4ac9fbbc3d6e687b20a904934515602fe47e1cfda076db6a3184b3dae739cbde6e288936b0ac6dbb61abb4266ea4acec68557523e0a
7
- data.tar.gz: 2a72ea4003e421fc8f62806b8dbf712d3d10e291b53e7946c2b243ccd19aa93e81378d8b0318849730c7fa04dfcd9739f1c2ef5161c5f8d959590a7a09d0507d
6
+ metadata.gz: 6562231212835d63c74caca7e2591207e37b6d8cb0aa1aa3d0ae156b6af08708a048b421278c6fbb4924ae8e3889d41094b0b8f295d719203718ffd9f09c3557
7
+ data.tar.gz: 9f5a6192298e2c55d8243f4e2a470f6932ac4be6ef1ca6101ffd896b5f30f5692c37cb0e1a0b6d8108c14c69d59af5b5f54d5f64febcc69fdb3e6dc3fe08c324
@@ -1,3 +1,5 @@
1
+ require 'ipaddr'
2
+
1
3
  class SpecifictemplateController < ApplicationController
2
4
  # Skip default filters for specific template actions
3
5
  FILTERS = [
@@ -17,7 +19,7 @@ class SpecifictemplateController < ApplicationController
17
19
  before_action :find_host
18
20
 
19
21
  def update
20
- return false unless @host and @host.build?
22
+ return render(:plain => 'Host not in build mode') unless @host and @host.build?
21
23
 
22
24
  # TODO? Detect PXELinux/PXEGrub/PXEGrub2/iPXE, @host.pxe_loader.split.first maybe
23
25
  # Would mean templates could be provided with 'template_name=default local boot'
@@ -27,6 +29,8 @@ class SpecifictemplateController < ApplicationController
27
29
  template = ProvisioningTemplate.find_by_name(template_name)
28
30
  raise Foreman::Exception.new(N_("Template '%s' was not found"), template_name) unless template
29
31
 
32
+ # TODO; Check that the template is of the correct PXE type, not just that the OS
33
+ # allows using that type. Don't want to deploy PXELinux on a PXEGrub2 host.
30
34
  kind = template.template_kind.name
31
35
  raise Foreman::Exception.new(N_("%s does not support templates of type %s"), @host.operatingsystem, kind) unless @host.operatingsystem.template_kinds.include?(kind)
32
36
 
@@ -38,7 +42,7 @@ class SpecifictemplateController < ApplicationController
38
42
  next unless iface.tftp? || iface.tftp6?
39
43
 
40
44
  iface.send(:unique_feasible_tftp_proxies).each do |proxy|
41
- mac_addresses = iface.respond_to?(:mac_addresses_for_tftp, true) && iface.send(:mac_addresses_for_tftp) || [mac]
45
+ mac_addresses = iface.try(:mac_addresses_for_tftp) || [iface.mac]
42
46
  mac_addresses.each do |mac_addr|
43
47
  proxy.set(kind, mac_addr, :pxeconfig => content)
44
48
  end
@@ -107,7 +111,13 @@ class SpecifictemplateController < ApplicationController
107
111
  ip = ip.split(',').first
108
112
 
109
113
  # host is readonly because of association so we reload it if we find it
110
- host = Host.joins(:provision_interface).where(:nics => { :ip => ip }).first
114
+ if IPAddr.new(ip).ipv6?
115
+ search = { :ip6 => ip }
116
+ else
117
+ search = { :ip => ip }
118
+ end
119
+
120
+ host = Host.joins(:provision_interface).where(:nics => search).first
111
121
  host ? Host.find(host.id) : nil
112
122
  end
113
123
 
@@ -1,3 +1,3 @@
1
1
  module ForemanSpecificTemplate
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_specifictemplate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Olofsson