foreman_bootdisk 19.0.5 → 21.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_bootdisk/api/v2/disks_controller.rb +0 -4
- data/app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb +0 -4
- data/app/controllers/foreman_bootdisk/disks_controller.rb +5 -3
- data/config/routes/mount_engine.rb +1 -1
- data/lib/foreman_bootdisk/engine.rb +8 -4
- data/lib/foreman_bootdisk/version.rb +1 -1
- data/package.json +5 -6
- data/webpack/src/extensions/host/HostBootdiskButtons.js +22 -1
- metadata +3 -8
- data/app/views/foreman_bootdisk/generic_efi_host.erb +0 -76
- data/app/views/foreman_bootdisk/generic_host.erb +0 -51
- data/app/views/foreman_bootdisk/generic_static_host.erb +0 -39
- data/app/views/foreman_bootdisk/host.erb +0 -80
- data/db/seeds.d/50-bootdisk_templates.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 637d590cf13dbcf6512da5bd13ccb380304c0affff50e1528581bf61ca0603e6
|
4
|
+
data.tar.gz: 315c48d5f916315f6893bb3c69d4dae17567d4b8c7a073eb887ffbe80ecedeb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79b5f0a3d831e29ef08539710a39f5557d11122a44b2ebfbc0fbc0c9c9a9b9753816affdaf7450e82780aaa03c60eda8daae47e4d79cf183442566d67a68705e
|
7
|
+
data.tar.gz: c8a27d561bcfe068088b895468cbca4b8834946d27d74bf6bc873a9213ae8deab625a5eb4975e50e3c49c3ed5d081080e8f0311e8977f9ed46ce1eaff76e6f8f
|
@@ -9,10 +9,6 @@ module ForemanBootdisk
|
|
9
9
|
include ::Api::Version2
|
10
10
|
include AllowedActions
|
11
11
|
|
12
|
-
resource_description do
|
13
|
-
api_base_url '/bootdisk/api'
|
14
|
-
end
|
15
|
-
|
16
12
|
before_action :bootdisk_type_allowed?, only: :generic
|
17
13
|
before_action :find_resource, only: :host
|
18
14
|
skip_after_action :log_response_body
|
@@ -9,10 +9,6 @@ module ForemanBootdisk
|
|
9
9
|
include ::Api::Version2
|
10
10
|
include AllowedActions
|
11
11
|
|
12
|
-
resource_description do
|
13
|
-
api_base_url '/bootdisk/api'
|
14
|
-
end
|
15
|
-
|
16
12
|
rescue_from ActiveRecord::RecordNotFound, :with => :subnet_not_found
|
17
13
|
before_action :bootdisk_type_allowed?, only: :subnet
|
18
14
|
before_action :find_resource, only: :subnet
|
@@ -121,16 +121,18 @@ module ForemanBootdisk
|
|
121
121
|
disable_full_host = action == 'full_host' && !host.build?
|
122
122
|
actions << {
|
123
123
|
title: title,
|
124
|
-
link: "/
|
124
|
+
link: "/disks/#{action}s/#{host.id}",
|
125
125
|
disabled: disable_full_host ? true : false,
|
126
|
-
description: disable_full_host ? _('Host is not in build mode') : nil
|
126
|
+
description: disable_full_host ? _('Host is not in build mode') : nil,
|
127
|
+
icon: action,
|
127
128
|
}
|
128
129
|
end
|
129
130
|
return allowed unless User.current.allowed_to?({controller: 'foreman_bootdisk/disks', action: 'help'})
|
130
131
|
|
131
132
|
allowed.push({
|
132
133
|
title: _('Boot disk help'),
|
133
|
-
link: '/
|
134
|
+
link: '/disks/help',
|
135
|
+
icon: 'help'
|
134
136
|
})
|
135
137
|
end
|
136
138
|
end
|
@@ -6,6 +6,7 @@ require 'gettext_i18n_rails'
|
|
6
6
|
|
7
7
|
module ForemanBootdisk
|
8
8
|
class Engine < ::Rails::Engine
|
9
|
+
engine_name 'foreman_bootdisk'
|
9
10
|
isolate_namespace ForemanBootdisk
|
10
11
|
|
11
12
|
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
@@ -29,7 +30,7 @@ module ForemanBootdisk
|
|
29
30
|
|
30
31
|
initializer 'foreman_bootdisk.register_plugin', before: :finisher_hook do |_app|
|
31
32
|
Foreman::Plugin.register :foreman_bootdisk do
|
32
|
-
requires_foreman '>= 3.
|
33
|
+
requires_foreman '>= 3.4'
|
33
34
|
# Add Global files for extending foreman-core components and routes
|
34
35
|
register_global_js_file 'global'
|
35
36
|
|
@@ -48,7 +49,6 @@ module ForemanBootdisk
|
|
48
49
|
"#{ForemanBootdisk::Engine.root}/app/lib/foreman_bootdisk/scope/*.rb"
|
49
50
|
]
|
50
51
|
provision_method 'bootdisk', N_('Boot disk based')
|
51
|
-
template_labels 'Bootdisk' => N_('Boot disk embedded template')
|
52
52
|
allowed_template_helpers :bootdisk_chain_url, :bootdisk_raise
|
53
53
|
|
54
54
|
extend_page "subnets/index" do |cx|
|
@@ -139,12 +139,16 @@ module ForemanBootdisk
|
|
139
139
|
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
140
140
|
end
|
141
141
|
|
142
|
+
# Temporary workaround fix for helpers
|
143
|
+
initializer 'foreman_bootdisk.rails_loading_workaround' do
|
144
|
+
HostsHelper.prepend ForemanBootdisk::HostsHelperExt
|
145
|
+
SubnetsHelper.prepend ForemanBootdisk::SubnetsHelperExt
|
146
|
+
end
|
147
|
+
|
142
148
|
config.to_prepare do
|
143
149
|
begin
|
144
150
|
Host::Managed.prepend ForemanBootdisk::HostExt
|
145
151
|
Host::Managed.include ForemanBootdisk::Orchestration::Compute
|
146
|
-
HostsHelper.prepend ForemanBootdisk::HostsHelperExt
|
147
|
-
SubnetsHelper.prepend ForemanBootdisk::SubnetsHelperExt
|
148
152
|
Foreman::Model::Vmware.prepend ForemanBootdisk::ComputeResources::Vmware if Foreman::Model::Vmware.available?
|
149
153
|
rescue StandardError => e
|
150
154
|
Rails.logger.warn "#{ForemanBootdisk::ENGINE_NAME}: skipping engine hook (#{e})"
|
data/package.json
CHANGED
@@ -26,12 +26,11 @@
|
|
26
26
|
"devDependencies": {
|
27
27
|
"@babel/core": "^7.7.0",
|
28
28
|
"@sheerun/mutationobserver-shim": "^0.3.3",
|
29
|
-
"@theforeman/builder": "
|
30
|
-
"@theforeman/eslint-plugin-foreman": "8.15.0",
|
31
|
-
"@theforeman/find-foreman": "
|
32
|
-
"@theforeman/stories": "
|
33
|
-
"@theforeman/test": "
|
34
|
-
"@theforeman/vendor-dev": "^8.15.0",
|
29
|
+
"@theforeman/builder": ">= 8.15.0",
|
30
|
+
"@theforeman/eslint-plugin-foreman": ">= 8.15.0",
|
31
|
+
"@theforeman/find-foreman": ">= 8.15.0",
|
32
|
+
"@theforeman/stories": ">= 8.15.0",
|
33
|
+
"@theforeman/test": ">= 8.15.0",
|
35
34
|
"babel-eslint": "^10.0.3",
|
36
35
|
"eslint": "^6.7.2",
|
37
36
|
"prettier": "^1.19.1",
|
@@ -2,6 +2,12 @@ import React, { useEffect } from 'react';
|
|
2
2
|
import { useSelector, useDispatch } from 'react-redux';
|
3
3
|
|
4
4
|
import { DropdownItem, DropdownGroup } from '@patternfly/react-core';
|
5
|
+
import {
|
6
|
+
BanIcon,
|
7
|
+
BuildIcon,
|
8
|
+
BuilderImageIcon,
|
9
|
+
OutlinedQuestionCircleIcon,
|
10
|
+
} from '@patternfly/react-icons';
|
5
11
|
|
6
12
|
import { get } from 'foremanReact/redux/API';
|
7
13
|
import { foremanUrl } from 'foremanReact/common/helpers';
|
@@ -23,11 +29,24 @@ const HostBootdiskButtons = () => {
|
|
23
29
|
const isLoading = useSelector(selectIsLoading);
|
24
30
|
const options = useSelector(selectBootdiskOptions);
|
25
31
|
|
32
|
+
const iconComponent = icon => {
|
33
|
+
switch (icon) {
|
34
|
+
case 'host':
|
35
|
+
return <BuildIcon />;
|
36
|
+
case 'full_host':
|
37
|
+
return <BuilderImageIcon />;
|
38
|
+
case 'help':
|
39
|
+
return <OutlinedQuestionCircleIcon />;
|
40
|
+
default:
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
26
45
|
useEffect(() => {
|
27
46
|
dispatch(
|
28
47
|
get({
|
29
48
|
key: HOST_BOOTDISK_BUTTONS_REQUEST_KEY,
|
30
|
-
url: foremanUrl(`/
|
49
|
+
url: foremanUrl(`/disks/bootdisk_options/${hostId}`),
|
31
50
|
})
|
32
51
|
);
|
33
52
|
}, [dispatch, hostId]);
|
@@ -40,6 +59,7 @@ const HostBootdiskButtons = () => {
|
|
40
59
|
href={foremanUrl(action.link)}
|
41
60
|
isDisabled={action.disabled}
|
42
61
|
description={action.description}
|
62
|
+
icon={iconComponent(action.icon)}
|
43
63
|
>
|
44
64
|
{action.title}
|
45
65
|
</DropdownItem>
|
@@ -55,6 +75,7 @@ const HostBootdiskButtons = () => {
|
|
55
75
|
options.architectureName
|
56
76
|
)}
|
57
77
|
tooltipProps={{ entryDelay: 0, exitDelay: 0 }}
|
78
|
+
icon={<BanIcon />}
|
58
79
|
>
|
59
80
|
{__('Not available')}
|
60
81
|
</DropdownItem>
|
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:
|
4
|
+
version: 21.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominic Cleal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: theforeman-rubocop
|
@@ -72,10 +72,6 @@ files:
|
|
72
72
|
- app/services/foreman_bootdisk/iso_generator.rb
|
73
73
|
- app/services/foreman_bootdisk/renderer.rb
|
74
74
|
- app/views/foreman_bootdisk/disks/help.html.erb
|
75
|
-
- app/views/foreman_bootdisk/generic_efi_host.erb
|
76
|
-
- app/views/foreman_bootdisk/generic_host.erb
|
77
|
-
- app/views/foreman_bootdisk/generic_static_host.erb
|
78
|
-
- app/views/foreman_bootdisk/host.erb
|
79
75
|
- app/views/hosts/provision_method/bootdisk/_form.html.erb
|
80
76
|
- app/views/subnets/_bootdisk_action_buttons.erb
|
81
77
|
- app/views/subnets/_bootdisk_title_buttons.erb
|
@@ -88,7 +84,6 @@ files:
|
|
88
84
|
- db/migrate/20131021095100_edit_host_bootdisk_template_dns_secondary.rb
|
89
85
|
- db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
|
90
86
|
- db/migrate/20171009225200_remove_duplicate_bootdisk_templates.rb
|
91
|
-
- db/seeds.d/50-bootdisk_templates.rb
|
92
87
|
- lib/foreman_bootdisk.rb
|
93
88
|
- lib/foreman_bootdisk/engine.rb
|
94
89
|
- lib/foreman_bootdisk/version.rb
|
@@ -161,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
156
|
- !ruby/object:Gem::Version
|
162
157
|
version: '0'
|
163
158
|
requirements: []
|
164
|
-
rubygems_version: 3.1.
|
159
|
+
rubygems_version: 3.1.6
|
165
160
|
signing_key:
|
166
161
|
specification_version: 4
|
167
162
|
summary: Create boot disks to provision hosts with Foreman
|
@@ -1,76 +0,0 @@
|
|
1
|
-
<%#
|
2
|
-
name: Boot disk Grub2 EFI - generic host
|
3
|
-
snippet: false
|
4
|
-
model: ProvisioningTemplate
|
5
|
-
kind: Bootdisk
|
6
|
-
description: |
|
7
|
-
Boot disk Grub2 EFI - generic host
|
8
|
-
-%>
|
9
|
-
#
|
10
|
-
# Boot disk Grub2 EFI - generic host
|
11
|
-
#
|
12
|
-
#set debug="http,efinet,net"
|
13
|
-
#set debug=all
|
14
|
-
echo "Foreman Bootdisk: 'Boot disk Grub2 EFI - generic host' template"
|
15
|
-
echo
|
16
|
-
echo "********************************************************"
|
17
|
-
echo " REQUIREMENTS:"
|
18
|
-
echo " * SUBNET GENERIC IMAGE ONLY (host image not supported)"
|
19
|
-
echo " * HOST PARAM default_grub_install_entry set to efi_http"
|
20
|
-
echo " * PROXY WITH HTTPBOOT FEATURE"
|
21
|
-
echo " * HTTP UEFI BOOT ONLY (Legacy/PXE not supported)"
|
22
|
-
echo " * IPv4 ONLY (IPv6 not tested, change the template)"
|
23
|
-
echo " * HTTP ONLY (change the template for HTTPS)"
|
24
|
-
echo " * ISC DHCP (other servers not tested)"
|
25
|
-
echo " * GRUB FROM RHEL 8.3+/7.9+ (when generating the image)"
|
26
|
-
echo " * EFI HTTP or HTTPS grub entry must be selected in menu"
|
27
|
-
echo " * DNS must resolve proxy hostname via DNS proxy if set"
|
28
|
-
echo "*******************************************************"
|
29
|
-
sleep 5
|
30
|
-
<%
|
31
|
-
# possible values are: "http" or "https"
|
32
|
-
proxy_proto = "http"
|
33
|
-
|
34
|
-
@subnet || bootdisk_raise("Generic disk not supported for EFI, use subnet disk")
|
35
|
-
@subnet.template? || bootdisk_raise("Requires a proxy with template feature")
|
36
|
-
proxy_port = if proxy_proto == "http"
|
37
|
-
@subnet.httpboot.httpboot_http_port
|
38
|
-
else
|
39
|
-
@subnet.httpboot.httpboot_https_port
|
40
|
-
end
|
41
|
-
# Workaround for "no DNS server configured" https://bugzilla.redhat.com/show_bug.cgi?id=1842509
|
42
|
-
proxy_httpboot_host = dns_lookup(@subnet.httpboot.hostname)
|
43
|
-
proxy_template_host = dns_lookup(@subnet.template.hostname)
|
44
|
-
-%>
|
45
|
-
echo
|
46
|
-
net_ls_cards
|
47
|
-
echo "Configuring ALL cards via BOOTP/IPv4"
|
48
|
-
net_bootp
|
49
|
-
# uncomment here for IPv6 support (not tested)
|
50
|
-
#echo "Configuring ALL cards via BOOTP/IPv6"
|
51
|
-
#net_ipv6_autoconf
|
52
|
-
net_ls_addr
|
53
|
-
net_ls_routes
|
54
|
-
net_ls_dns
|
55
|
-
echo Trying to ping proxy_httpboot_host: <%= proxy_httpboot_host %>
|
56
|
-
ping --count 1 <%= proxy_httpboot_host %> || echo Ping to proxy_httpboot_host failed or ping command not available.
|
57
|
-
echo Trying to ping proxy_template_host: <%= proxy_template_host %>
|
58
|
-
ping --count 1 <%= proxy_template_host %> || echo Ping to proxy_template_host failed or ping command not available.
|
59
|
-
sleep 5
|
60
|
-
set root=(<%= proxy_proto %>,<%= proxy_httpboot_host %>:<%= proxy_port %>)
|
61
|
-
# The variable will not survive configfile fetch, therefore absolute path
|
62
|
-
# must be used in the chainloaded template.
|
63
|
-
# https://bugzilla.redhat.com/show_bug.cgi?id=1842893
|
64
|
-
set http_path=/httpboot/
|
65
|
-
set default=efi_<%= proxy_proto %>
|
66
|
-
<% (0..32).each do |i| -%>
|
67
|
-
echo "Trying efinet<%= i %> via <%= proxy_proto %>://<%= proxy_template_host %>:<%= proxy_port %>/unattended/PXEGrub2?mac=$net_efinet<%= i %>_dhcp_mac"
|
68
|
-
set net_default_mac=$net_efinet<%= i %>_dhcp_mac
|
69
|
-
sleep 5
|
70
|
-
configfile (<%= proxy_proto %>,<%= proxy_template_host %>:<%= proxy_port %>)/unattended/PXEGrub2?mac=$net_efinet<%= i %>_dhcp_mac
|
71
|
-
<% end -%>
|
72
|
-
|
73
|
-
echo "Could not find a host with PXEGrub2 template and one of the MAC addresses!"
|
74
|
-
echo "The system will poweroff in few minutes..."
|
75
|
-
sleep 500
|
76
|
-
poweroff
|
@@ -1,51 +0,0 @@
|
|
1
|
-
<%#
|
2
|
-
name: Boot disk iPXE - generic host
|
3
|
-
snippet: false
|
4
|
-
model: ProvisioningTemplate
|
5
|
-
kind: Bootdisk
|
6
|
-
description: |
|
7
|
-
Example foreman_bootdisk generic host template
|
8
|
-
|
9
|
-
This template is generic, but it will chainload to Foreman so expects the
|
10
|
-
host to be registered already.
|
11
|
-
|
12
|
-
It loops through all interfaces using DHCP, requesting a template from
|
13
|
-
Foreman in the hope that one of the MACs or IPs matches.
|
14
|
-
-%>
|
15
|
-
#!ipxe
|
16
|
-
|
17
|
-
echo Foreman Bootdisk: Generic image
|
18
|
-
|
19
|
-
# loop over net* until we can get a template
|
20
|
-
<% url = bootdisk_chain_url %>
|
21
|
-
<% (0..32).each do |i| -%>
|
22
|
-
:net<%= i %>
|
23
|
-
isset ${net<%= i -%>/mac} || goto no_nic
|
24
|
-
echo net<%= i -%> is a ${net<%= i -%>/chip} with MAC ${net<%= i -%>/mac}
|
25
|
-
dhcp net<%= i %> || goto net<%= i+1 %>
|
26
|
-
chain <%= url %>${net<%= i -%>/mac} || goto net<%= i+1 %>
|
27
|
-
exit 0
|
28
|
-
<% end -%>
|
29
|
-
echo Failed to chainload from any network interface, fallback to static.
|
30
|
-
ifstat
|
31
|
-
|
32
|
-
:no_nic
|
33
|
-
echo -n Enter interface name to boot from (e.g. net0): && read interface
|
34
|
-
isset ${${interface}/mac} && goto get_static_ip
|
35
|
-
echo Interface ${interface} is not initialized, try again
|
36
|
-
goto no_nic
|
37
|
-
|
38
|
-
:get_static_ip
|
39
|
-
ifopen ${interface}
|
40
|
-
echo Please enter IP details for ${interface}
|
41
|
-
echo
|
42
|
-
echo -n IP address : && read ${interface}/ip
|
43
|
-
echo -n Subnet mask : && read ${interface}/netmask
|
44
|
-
echo -n Default gateway : && read ${interface}/gateway
|
45
|
-
echo -n DNS server : && read dns
|
46
|
-
chain <%= url %>${${interface}/mac} || goto boot_failure
|
47
|
-
exit 0
|
48
|
-
|
49
|
-
:boot_failure
|
50
|
-
echo Cannot continue, spawning shell
|
51
|
-
shell
|
@@ -1,39 +0,0 @@
|
|
1
|
-
<%#
|
2
|
-
name: Boot disk iPXE - generic static host
|
3
|
-
snippet: false
|
4
|
-
model: ProvisioningTemplate
|
5
|
-
kind: Bootdisk
|
6
|
-
description: |
|
7
|
-
Generic host template with interactive static IP configuration. Tokens
|
8
|
-
must be disabled in order to access templates via MAC addresses.
|
9
|
-
-%>
|
10
|
-
#!ipxe
|
11
|
-
|
12
|
-
<% (0..32).each do |i| -%>
|
13
|
-
:net<%= i %>
|
14
|
-
isset ${net<%= i -%>/mac} || goto configure
|
15
|
-
echo Found ${net<%= i -%>/mac} as net<%= i -%> on a ${net<%= i -%>/chip}
|
16
|
-
goto net<%= i+1 %>
|
17
|
-
<% end -%>
|
18
|
-
|
19
|
-
:configure
|
20
|
-
echo -n Interface (e.g. net0): && read interface
|
21
|
-
iseq ${interface} n && goto reboot ||
|
22
|
-
iseq ${interface} N && goto reboot ||
|
23
|
-
|
24
|
-
ifopen ${interface}
|
25
|
-
echo Please enter IPv4 details for ${interface}
|
26
|
-
echo
|
27
|
-
|
28
|
-
echo -n IP address: && read ${interface}/ip
|
29
|
-
echo -n Subnet mask: && read ${interface}/netmask
|
30
|
-
echo -n Default gateway: && read ${interface}/gateway
|
31
|
-
echo -n DNS server: && read dns
|
32
|
-
|
33
|
-
chain <%= bootdisk_chain_url %>${${interface}/mac} || goto reboot
|
34
|
-
exit 0
|
35
|
-
|
36
|
-
:reboot
|
37
|
-
echo Unable to continue, rebooting...
|
38
|
-
sleep 30
|
39
|
-
exit 1
|
@@ -1,80 +0,0 @@
|
|
1
|
-
<%#
|
2
|
-
name: Boot disk iPXE - host
|
3
|
-
snippet: false
|
4
|
-
model: ProvisioningTemplate
|
5
|
-
kind: Bootdisk
|
6
|
-
description: |
|
7
|
-
Example foreman_bootdisk host template
|
8
|
-
This template is rendered for use inside a host-specific boot disk.
|
9
|
-
-%>
|
10
|
-
#!ipxe
|
11
|
-
|
12
|
-
<%
|
13
|
-
interface = @host.provision_interface
|
14
|
-
bootdisk_raise(N_('Host has no provisioning interface defined')) unless interface
|
15
|
-
bootdisk_raise(N_('Host has no IPv4 or IPv6 address defined')) unless interface.ip.present? || interface.ip6.present?
|
16
|
-
bootdisk_raise(N_('Host has no subnet defined')) unless interface.subnet || interface.subnet6
|
17
|
-
bootdisk_raise(N_('Host has no domain defined')) unless interface.domain
|
18
|
-
if interface.ip.present? && interface.subnet
|
19
|
-
ip = interface.ip
|
20
|
-
subnet = interface.subnet
|
21
|
-
elsif interface.ip6.present? && interface.subnet6
|
22
|
-
ip = interface.ip6
|
23
|
-
subnet = interface.subnet6
|
24
|
-
bootdisk_raise(N_('Host bootdisk does not work with static IPv6'))
|
25
|
-
else
|
26
|
-
bootdisk_raise(N_('Both IP and Subnet must be set'))
|
27
|
-
end
|
28
|
-
|
29
|
-
mask = subnet.mask
|
30
|
-
gw = subnet.gateway
|
31
|
-
dns = subnet.dns_servers.first
|
32
|
-
%>
|
33
|
-
|
34
|
-
echo Foreman Bootdisk: Host image (<%= @host.name %>)
|
35
|
-
|
36
|
-
# loop over net* until the host's MAC matches
|
37
|
-
<% (0..32).each do |i| -%>
|
38
|
-
:net<%= i %>
|
39
|
-
isset ${net<%= i -%>/mac} || goto no_nic
|
40
|
-
echo net<%= i -%> is a ${net<%= i -%>/chip} with MAC ${net<%= i -%>/mac}
|
41
|
-
iseq ${net<%= i -%>/mac} <%= interface.mac -%> || goto net<%= i+1 %>
|
42
|
-
set idx:int32 <%= i %>
|
43
|
-
goto loop_success
|
44
|
-
<% end -%>
|
45
|
-
|
46
|
-
:loop_success
|
47
|
-
echo Configuring net${idx} for static IP address <%= ip %>
|
48
|
-
ifopen net${idx}
|
49
|
-
# netX = last opened NIC
|
50
|
-
set netX/ip <%= ip %>
|
51
|
-
set netX/netmask <%= mask %>
|
52
|
-
<% if gw.present? %>
|
53
|
-
set netX/gateway <%= gw %>
|
54
|
-
<% end %>
|
55
|
-
ifstat net${idx}
|
56
|
-
route
|
57
|
-
|
58
|
-
# Note: When multiple DNS servers are specified, only the first
|
59
|
-
# server will be used. See: http://ipxe.org/cfg/dns
|
60
|
-
<% if dns.present? -%>
|
61
|
-
echo Using DNS <%= dns %>
|
62
|
-
set dns <%= dns %>
|
63
|
-
set domain <%= interface.domain.to_s %>
|
64
|
-
<% end %>
|
65
|
-
|
66
|
-
echo Trying to ping Gateway: ${netX/gateway}
|
67
|
-
ping --count 1 ${netX/gateway} || echo Ping to Gateway failed or ping command not available.
|
68
|
-
<% if dns.present? -%>
|
69
|
-
echo Trying to ping DNS: ${netX/dns}
|
70
|
-
ping --count 1 ${netX/dns} || echo Ping to DNS failed or ping command not available.
|
71
|
-
<% end %>
|
72
|
-
|
73
|
-
# Chainload from Foreman rather than embedding OS info here, so the behaviour
|
74
|
-
# is entirely dynamic.
|
75
|
-
chain <%= bootdisk_chain_url %>
|
76
|
-
exit 0
|
77
|
-
|
78
|
-
:no_nic
|
79
|
-
echo Cannot find interface with MAC <%= interface.mac %>, spawning shell
|
80
|
-
shell
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
def read_bootdisk_template(filename)
|
4
|
-
File.read(File.join(ForemanBootdisk::Engine.root, 'app', 'views', 'foreman_bootdisk', filename))
|
5
|
-
end
|
6
|
-
|
7
|
-
def ensure_bootdisk_template(name, content)
|
8
|
-
kind = TemplateKind.unscoped.where(name: 'Bootdisk').first_or_create
|
9
|
-
tmpl = ProvisioningTemplate.unscoped.where(name: name).first_or_create do |template|
|
10
|
-
template.attributes = {
|
11
|
-
template_kind_id: kind.id,
|
12
|
-
snippet: false,
|
13
|
-
template: content
|
14
|
-
}
|
15
|
-
end
|
16
|
-
tmpl.attributes = {
|
17
|
-
template: content,
|
18
|
-
default: true,
|
19
|
-
vendor: "Foreman boot disk"
|
20
|
-
}
|
21
|
-
tmpl.locked = true
|
22
|
-
tmpl.organizations = Organization.unscoped.all if SETTINGS[:organizations_enabled]
|
23
|
-
tmpl.locations = Location.unscoped.all if SETTINGS[:locations_enabled]
|
24
|
-
tmpl.save!(validate: false) if tmpl.changes.present?
|
25
|
-
end
|
26
|
-
|
27
|
-
ProvisioningTemplate.without_auditing do
|
28
|
-
ensure_bootdisk_template("Boot disk iPXE - host", read_bootdisk_template("host.erb"))
|
29
|
-
ensure_bootdisk_template("Boot disk iPXE - generic host", read_bootdisk_template("generic_host.erb"))
|
30
|
-
ensure_bootdisk_template("Boot disk Grub2 EFI - generic host", read_bootdisk_template("generic_efi_host.erb"))
|
31
|
-
ensure_bootdisk_template("Boot disk iPXE - generic static host", read_bootdisk_template("generic_static_host.erb"))
|
32
|
-
end
|