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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2070a1537aa93375ca77a16c0e96de2594bddd4b
|
4
|
+
data.tar.gz: 83d507a61bf420703190bc30ac07111054546579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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
|
-
|
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
|
|