foreman_bootdisk 16.0.0 → 18.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop.yaml +19 -0
- data/.tx/config +1 -1
- data/AUTHORS +9 -1
- data/README.md +11 -3
- data/app/controllers/concerns/allowed_actions.rb +16 -0
- data/app/controllers/foreman_bootdisk/api/v2/disks_controller.rb +15 -8
- data/app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb +16 -4
- data/app/controllers/foreman_bootdisk/disks_controller.rb +29 -23
- data/app/controllers/foreman_bootdisk/subnet_disks_controller.rb +41 -0
- data/app/helpers/bootdisk_links_helper.rb +46 -0
- data/app/helpers/concerns/foreman_bootdisk/hosts_helper_ext.rb +58 -44
- data/app/helpers/concerns/foreman_bootdisk/pretty_error.rb +13 -0
- data/app/helpers/concerns/foreman_bootdisk/subnets_helper_ext.rb +45 -0
- data/app/helpers/disk_helper.rb +8 -0
- data/app/lib/foreman_bootdisk/scope/bootdisk.rb +28 -1
- data/app/lib/foreman_bootdisk/scope/full_host_bootdisk_efi.rb +15 -0
- data/app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb +10 -1
- data/app/models/concerns/foreman_bootdisk/host_ext.rb +13 -6
- data/app/models/concerns/foreman_bootdisk/orchestration/compute.rb +38 -22
- data/app/models/setting/bootdisk.rb +14 -1
- data/app/services/foreman_bootdisk/iso_generator.rb +134 -56
- data/app/services/foreman_bootdisk/renderer.rb +36 -19
- data/app/views/foreman_bootdisk/disks/help.html.erb +16 -4
- data/app/views/foreman_bootdisk/generic_efi_host.erb +68 -0
- data/app/views/foreman_bootdisk/host.erb +7 -0
- data/app/views/subnets/_bootdisk_action_buttons.erb +1 -0
- data/app/views/subnets/_bootdisk_title_buttons.erb +1 -0
- data/config/routes.rb +1 -1
- data/db/seeds.d/50-bootdisk_templates.rb +1 -0
- data/lib/foreman_bootdisk/engine.rb +18 -8
- data/lib/foreman_bootdisk/version.rb +1 -1
- data/lib/tasks/bootdisk.rake +10 -24
- data/locale/action_names.rb +5 -0
- data/locale/ca/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ca/foreman_bootdisk.po +76 -13
- data/locale/de/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/de/foreman_bootdisk.po +81 -18
- data/locale/en/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en/foreman_bootdisk.po +71 -8
- data/locale/en_GB/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/en_GB/foreman_bootdisk.po +79 -16
- data/locale/es/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/es/foreman_bootdisk.po +92 -28
- data/locale/foreman_bootdisk.pot +164 -71
- data/locale/fr/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/fr/foreman_bootdisk.po +100 -36
- data/locale/it/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/it/foreman_bootdisk.po +78 -15
- data/locale/ja/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ja/foreman_bootdisk.po +90 -26
- data/locale/ko/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ko/foreman_bootdisk.po +79 -16
- data/locale/pt_BR/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/pt_BR/foreman_bootdisk.po +99 -36
- data/locale/ru/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/ru/foreman_bootdisk.po +79 -16
- data/locale/sv_SE/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/sv_SE/foreman_bootdisk.po +75 -12
- data/locale/zh_CN/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_CN/foreman_bootdisk.po +131 -68
- data/locale/zh_TW/LC_MESSAGES/foreman_bootdisk.mo +0 -0
- data/locale/zh_TW/foreman_bootdisk.po +79 -16
- data/test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb +51 -17
- data/test/functional/foreman_bootdisk/api/v2/subnet_disks_controller_test.rb +23 -10
- data/test/functional/foreman_bootdisk/disks_controller_test.rb +60 -30
- data/test/functional/foreman_bootdisk/subnet_disks_controller_test.rb +51 -0
- data/test/test_plugin_helper.rb +21 -3
- data/test/unit/concerns/host_test.rb +12 -1
- data/test/unit/concerns/orchestration/compute_test.rb +32 -13
- data/test/unit/foreman_bootdisk/renderer_test.rb +1 -1
- data/test/unit/iso_generator_test.rb +6 -7
- metadata +21 -37
@@ -5,10 +5,10 @@
|
|
5
5
|
# Translators:
|
6
6
|
msgid ""
|
7
7
|
msgstr ""
|
8
|
-
"Project-Id-Version: foreman_bootdisk
|
8
|
+
"Project-Id-Version: foreman_bootdisk 18.0.0\n"
|
9
9
|
"Report-Msgid-Bugs-To: \n"
|
10
|
-
"PO-Revision-Date:
|
11
|
-
"Last-Translator:
|
10
|
+
"PO-Revision-Date: 2021-04-29 10:23+0000\n"
|
11
|
+
"Last-Translator: Transifex Bot <>\n"
|
12
12
|
"Language-Team: Chinese (Taiwan) (http://www.transifex.com/foreman/foreman/lang"
|
13
13
|
"uage/zh_TW/)\n"
|
14
14
|
"MIME-Version: 1.0\n"
|
@@ -17,15 +17,21 @@ msgstr ""
|
|
17
17
|
"Language: zh_TW\n"
|
18
18
|
"Plural-Forms: nplurals=1; plural=0;\n"
|
19
19
|
|
20
|
+
msgid "* - These bootdisk types were disabled, you can enable them in Administer - Settings."
|
21
|
+
msgstr ""
|
22
|
+
|
20
23
|
msgid "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."
|
21
24
|
msgstr "個別主機映像檔的變體,磁碟中嵌入了 OS 的開機載入程式。這對於在特定硬體上的 chainloading 失敗時特別有幫助,不過缺點就是若要對 OS、開機載入程式或 PXELinux 範本進行任何更改,映像檔就必須重新產生。"
|
22
25
|
|
23
26
|
msgid "Action with sub plans"
|
24
|
-
msgstr ""
|
27
|
+
msgstr "有子計畫的動作"
|
25
28
|
|
26
29
|
msgid "All images are usable as either ISOs or as disk images, including being written to a USB disk with `dd`."
|
27
30
|
msgstr "所有映像檔皆能作為 ISO 或是磁碟映像檔使用,包括以 `dd` 寫入一個 USB 磁碟中。"
|
28
31
|
|
32
|
+
msgid "Allowed bootdisk types"
|
33
|
+
msgstr ""
|
34
|
+
|
29
35
|
msgid "Attach ISO image to CDROM drive for %s"
|
30
36
|
msgstr ""
|
31
37
|
|
@@ -35,6 +41,9 @@ msgstr "上一步"
|
|
35
41
|
msgid "Boot disk"
|
36
42
|
msgstr "開機磁碟"
|
37
43
|
|
44
|
+
msgid "Boot disk Help"
|
45
|
+
msgstr ""
|
46
|
+
|
38
47
|
msgid "Boot disk based"
|
39
48
|
msgstr ""
|
40
49
|
|
@@ -53,6 +62,12 @@ msgstr ""
|
|
53
62
|
msgid "Command to generate ISO image, use genisoimage or mkisofs"
|
54
63
|
msgstr "請使用 genisoimage 或是 mkisofs 來作為產生 ISO 映像檔的指令"
|
55
64
|
|
65
|
+
msgid "Creating new image failed, install truncate utility"
|
66
|
+
msgstr ""
|
67
|
+
|
68
|
+
msgid "Detach ISO image from CDROM drive for %s"
|
69
|
+
msgstr ""
|
70
|
+
|
56
71
|
msgid "Download generic image"
|
57
72
|
msgstr "下載泛型映像檔"
|
58
73
|
|
@@ -62,9 +77,21 @@ msgstr "下載主機映像檔"
|
|
62
77
|
msgid "Download subnet generic image"
|
63
78
|
msgstr "下載子網路泛型映像檔"
|
64
79
|
|
80
|
+
msgid "Ensure %{file} is readable (or update \"Grub2 directory\" setting)"
|
81
|
+
msgstr ""
|
82
|
+
|
65
83
|
msgid "Failed to attach ISO image to CDROM drive of instance %{name}: %{message}"
|
66
84
|
msgstr ""
|
67
85
|
|
86
|
+
msgid "Failed to create a directory within the ESP image"
|
87
|
+
msgstr ""
|
88
|
+
|
89
|
+
msgid "Failed to detach ISO image from CDROM drive of instance %{name}: %{message}"
|
90
|
+
msgstr ""
|
91
|
+
|
92
|
+
msgid "Failed to format the ESP image via mkfs.msdos"
|
93
|
+
msgstr ""
|
94
|
+
|
68
95
|
msgid "Failed to generate ISO image for instance %{name}: %{message}"
|
69
96
|
msgstr ""
|
70
97
|
|
@@ -83,17 +110,26 @@ msgstr "完整的主機映像檔"
|
|
83
110
|
msgid "Generating ISO image for %s"
|
84
111
|
msgstr ""
|
85
112
|
|
113
|
+
msgid "Generic Grub2 EFI image template"
|
114
|
+
msgstr ""
|
115
|
+
|
86
116
|
msgid "Generic image"
|
87
117
|
msgstr "泛型映像檔"
|
88
118
|
|
89
119
|
msgid "Generic image template"
|
90
120
|
msgstr ""
|
91
121
|
|
122
|
+
msgid "Generic images"
|
123
|
+
msgstr ""
|
124
|
+
|
92
125
|
msgid "Generic images are a reusable disk image that works for any host registered in Foreman. It requires a basic DHCP and DNS service to function and contact the server, but does not require DHCP reservations or static IP addresses."
|
93
126
|
msgstr "泛型映像檔是個可重複使用的磁碟映像檔,並且可使用於任何向 Foreman 註冊過的主機上。它需要一項基本的 DHCP 和 DNS 服務才能運作和聯絡伺服器,不過並不需要 DHCP 預留或靜態 IP 位址。"
|
94
127
|
|
95
|
-
msgid "
|
96
|
-
msgstr "
|
128
|
+
msgid "Grub2 directory"
|
129
|
+
msgstr ""
|
130
|
+
|
131
|
+
msgid "Grub2 template to use for generic EFI host boot disks"
|
132
|
+
msgstr ""
|
97
133
|
|
98
134
|
msgid "Host '%s' image"
|
99
135
|
msgstr "主機「%s」映像檔"
|
@@ -119,26 +155,35 @@ msgstr "主機映像檔"
|
|
119
155
|
msgid "Host image template"
|
120
156
|
msgstr ""
|
121
157
|
|
158
|
+
msgid "Host images"
|
159
|
+
msgstr ""
|
160
|
+
|
161
|
+
msgid "Host is not in build mode"
|
162
|
+
msgstr ""
|
163
|
+
|
122
164
|
msgid "Host is not in build mode, so the template cannot be rendered"
|
123
165
|
msgstr "主機不在組建模式下,因此無法編寫範本"
|
124
166
|
|
167
|
+
msgid "Host is not in build mode."
|
168
|
+
msgstr ""
|
169
|
+
|
125
170
|
msgid "ISO build failed"
|
126
171
|
msgstr "建立 ISO 失敗"
|
127
172
|
|
128
173
|
msgid "ISO generation command"
|
129
174
|
msgstr ""
|
130
175
|
|
131
|
-
msgid "ISO hybrid conversion failed"
|
132
|
-
msgstr "
|
176
|
+
msgid "ISO hybrid conversion failed: %s"
|
177
|
+
msgstr ""
|
133
178
|
|
134
179
|
msgid "ISOLINUX directory"
|
135
180
|
msgstr ""
|
136
181
|
|
137
182
|
msgid "Import Puppet classes"
|
138
|
-
msgstr ""
|
183
|
+
msgstr "匯入 Puppet 類別"
|
139
184
|
|
140
185
|
msgid "Import facts"
|
141
|
-
msgstr ""
|
186
|
+
msgstr "匯入詳情"
|
142
187
|
|
143
188
|
msgid "Installation media caching"
|
144
189
|
msgstr ""
|
@@ -146,9 +191,15 @@ msgstr ""
|
|
146
191
|
msgid "Installation media files will be cached for full host images"
|
147
192
|
msgstr "安裝媒介檔案將會被快取以作為完整的主機映像檔"
|
148
193
|
|
194
|
+
msgid "List of allowed bootdisk types, remove type to disable it"
|
195
|
+
msgstr ""
|
196
|
+
|
149
197
|
msgid "Once chainloaded, the OS bootloader and installer are downloaded directly from the installation media configured in Foreman, and the provisioning script (kickstart/preseed) is downloaded from Foreman."
|
150
198
|
msgstr "在 chainload 之後,OS 開機載入程式和安裝程式將會直接從 Foreman 中所配置的安裝媒介下載,而佈建 script(kickstart/preseed)則會由 Foreman 下載。"
|
151
199
|
|
200
|
+
msgid "Path to directory containing grubx64.efi and shimx64.efi"
|
201
|
+
msgstr ""
|
202
|
+
|
152
203
|
msgid "Path to directory containing iPXE images"
|
153
204
|
msgstr "包含 iPXE 映像檔的目錄之路徑"
|
154
205
|
|
@@ -171,7 +222,7 @@ msgid "Plugin for Foreman that creates iPXE-based boot disks to provision hosts
|
|
171
222
|
msgstr "能建立基於 iPXE 的開機磁碟的 Foreman 外掛程式,以在不需要 PXE 設備的情況下佈建主機。"
|
172
223
|
|
173
224
|
msgid "Remote action:"
|
174
|
-
msgstr ""
|
225
|
+
msgstr "遠端動作:"
|
175
226
|
|
176
227
|
msgid "SYSLINUX directory"
|
177
228
|
msgstr ""
|
@@ -182,34 +233,46 @@ msgstr "子網路「%s」泛型映像檔"
|
|
182
233
|
msgid "Subnet boot disks"
|
183
234
|
msgstr "子網路開機磁碟"
|
184
235
|
|
236
|
+
msgid "Subnet generic image"
|
237
|
+
msgstr ""
|
238
|
+
|
185
239
|
msgid "Subnet image"
|
186
240
|
msgstr "子網路映像檔"
|
187
241
|
|
188
242
|
msgid "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."
|
189
243
|
msgstr "子網路映像檔跟泛型映像檔類似,但連鎖載入(chain-loading)是透過 TFTP 智慧型代理指定至主機的子網路。智慧型代理必須啟用並配置了「模版」(Templates)模組。"
|
190
244
|
|
191
|
-
msgid "Subnet is not assigned to the host %s"
|
192
|
-
msgstr "子網路並未指定給主機 %s"
|
193
|
-
|
194
245
|
msgid "TFTP feature not enabled for subnet %s"
|
195
246
|
msgstr "TFTP 功能並未啟動給子網路 %s 使用"
|
196
247
|
|
197
248
|
msgid "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."
|
198
249
|
msgstr "OS 安裝程序會繼續使用配置於 Foreman 中的安裝媒介,並且它一般會根據 OS iPXE 範本的配置方法來配置靜態網路。"
|
199
250
|
|
251
|
+
msgid "These images are more generic than previous images. You can find them at subnet index page."
|
252
|
+
msgstr ""
|
253
|
+
|
254
|
+
msgid "These images are used for host. You can find them at host detail page."
|
255
|
+
msgstr ""
|
256
|
+
|
200
257
|
msgid "This image is generic for all hosts with a provisioning NIC on that subnet."
|
201
258
|
msgstr "這映像檔對在該子網路上配有網路卡的所有主機來說,是通用的。"
|
202
259
|
|
260
|
+
msgid "This type of bootdisk is not allowed. Please contact administrator."
|
261
|
+
msgstr ""
|
262
|
+
|
203
263
|
msgid "True for full, false for basic reusable image"
|
204
264
|
msgstr "「true」代表完整,「false」則代表可重複使用的基本映像檔"
|
205
265
|
|
206
266
|
msgid "Unable to find template specified by %s setting"
|
207
267
|
msgstr "找不到 %s 設定所指定的範本"
|
208
268
|
|
209
|
-
msgid "Unable to generate disk
|
269
|
+
msgid "Unable to generate disk %{kind} template: %{error}"
|
270
|
+
msgstr ""
|
271
|
+
|
272
|
+
msgid "Unable to generate disk template, %{kind} template not found."
|
210
273
|
msgstr ""
|
211
274
|
|
212
|
-
msgid "Unable to
|
275
|
+
msgid "Unable to mcopy %{file}"
|
213
276
|
msgstr ""
|
214
277
|
|
215
278
|
msgid "Upload ISO image to datastore for %s"
|
@@ -5,33 +5,67 @@ require 'test_plugin_helper'
|
|
5
5
|
class ForemanBootdisk::Api::V2::DisksControllerTest < ActionController::TestCase
|
6
6
|
include ForemanBootdiskTestHelper
|
7
7
|
setup :setup_bootdisk
|
8
|
+
setup :setup_referer
|
9
|
+
setup :setup_org_loc
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
def perform_generic_generate
|
12
|
+
tmp = create_tempfile
|
13
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
|
12
14
|
get :generic
|
13
15
|
assert_response :success
|
14
|
-
|
16
|
+
ensure
|
17
|
+
tmp.unlink
|
15
18
|
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
def perform_host_generate
|
21
|
+
tmp = create_tempfile
|
22
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
|
23
|
+
get :host, params: { id: @host.name }
|
24
|
+
assert_response :success
|
25
|
+
ensure
|
26
|
+
tmp.unlink
|
27
|
+
end
|
28
|
+
|
29
|
+
def perform_full_host_generate
|
30
|
+
tmp = create_tempfile
|
31
|
+
ForemanBootdisk::ISOGenerator.expects(:generate_full_host).yields(create_tempfile.path)
|
32
|
+
get :host, params: { id: @host.name, full: true }
|
33
|
+
assert_response :success
|
34
|
+
ensure
|
35
|
+
tmp.unlink
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#generic with TFTP' do
|
39
|
+
setup :setup_subnet_with_tftp
|
40
|
+
setup :setup_host
|
41
|
+
|
42
|
+
test 'should generate generic image' do
|
43
|
+
perform_generic_generate
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'should generate host image' do
|
47
|
+
perform_host_generate
|
48
|
+
end
|
49
|
+
|
50
|
+
test 'should generate full host image' do
|
51
|
+
perform_full_host_generate
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#subnet_host with TFTP and HTTPBOOT' do
|
56
|
+
setup :setup_subnet_with_tftp_httpboot_template
|
57
|
+
setup :setup_host
|
58
|
+
|
59
|
+
test 'should generate generic image' do
|
60
|
+
perform_generic_generate
|
61
|
+
end
|
20
62
|
|
21
63
|
test 'should generate host image' do
|
22
|
-
|
23
|
-
@controller.expects(:read_file).with('temp ISO').returns('ISO image')
|
24
|
-
get :host, params: { id: @host.name }
|
25
|
-
assert_response :success
|
26
|
-
assert_equal 'ISO image', @response.body
|
64
|
+
perform_host_generate
|
27
65
|
end
|
28
66
|
|
29
67
|
test 'should generate full host image' do
|
30
|
-
|
31
|
-
@controller.expects(:read_file).with('temp ISO').returns('ISO image')
|
32
|
-
get :host, params: { id: @host.name, full: true }
|
33
|
-
assert_response :success
|
34
|
-
assert_equal 'ISO image', @response.body
|
68
|
+
perform_full_host_generate
|
35
69
|
end
|
36
70
|
end
|
37
71
|
|
@@ -5,20 +5,33 @@ require 'test_plugin_helper'
|
|
5
5
|
class ForemanBootdisk::Api::V2::SubnetDisksControllerTest < ActionController::TestCase
|
6
6
|
include ForemanBootdiskTestHelper
|
7
7
|
setup :setup_bootdisk
|
8
|
+
setup :setup_referer
|
9
|
+
setup :setup_org_loc
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def perform_subnet_generate
|
12
|
+
tmp = create_tempfile
|
13
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
|
14
|
+
get :subnet, params: { id: @host.subnet.id }
|
15
|
+
assert_response :success
|
16
|
+
ensure
|
17
|
+
tmp.unlink
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#subnet_host with TFTP' do
|
21
|
+
setup :setup_subnet_with_tftp
|
22
|
+
setup :setup_host
|
23
|
+
|
24
|
+
test 'should generate subnet generic host image' do
|
25
|
+
perform_subnet_generate
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#subnet_host with TFTP and HTTPBOOT' do
|
30
|
+
setup :setup_subnet_with_tftp_httpboot_template
|
13
31
|
setup :setup_host
|
14
32
|
|
15
33
|
test 'should generate subnet generic host image' do
|
16
|
-
|
17
|
-
ForemanBootdisk::Renderer.any_instance.stubs(:bootdisk_chain_url).yields('http://smart-proxy.lan')
|
18
|
-
File.expects(:read).with('temp ISO').returns('ISO image')
|
19
|
-
get :subnet, params: { id: @host.subnet.id }
|
20
|
-
assert_response :success
|
21
|
-
assert_equal 'ISO image', @response.body
|
34
|
+
perform_subnet_generate
|
22
35
|
end
|
23
36
|
end
|
24
37
|
end
|
@@ -5,45 +5,67 @@ require 'test_plugin_helper'
|
|
5
5
|
class ForemanBootdisk::DisksControllerTest < ActionController::TestCase
|
6
6
|
include ForemanBootdiskTestHelper
|
7
7
|
setup :setup_bootdisk
|
8
|
+
setup :setup_referer
|
9
|
+
setup :setup_org_loc
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
def perform_generic_generate
|
12
|
+
tmp = create_tempfile
|
13
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
|
12
14
|
get :generic, session: set_session_user
|
13
15
|
assert_response :success
|
14
|
-
|
16
|
+
ensure
|
17
|
+
tmp.unlink
|
15
18
|
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
def perform_host_generate
|
21
|
+
tmp = create_tempfile
|
22
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
|
23
|
+
get :host, params: { id: @host.name }, session: set_session_user
|
24
|
+
assert_response :success
|
25
|
+
ensure
|
26
|
+
tmp.unlink
|
27
|
+
end
|
28
|
+
|
29
|
+
def perform_full_host_generate
|
30
|
+
tmp = create_tempfile
|
31
|
+
ForemanBootdisk::ISOGenerator.expects(:generate_full_host).yields(create_tempfile.path)
|
32
|
+
get :full_host, params: { id: @host.name }, session: set_session_user
|
33
|
+
assert_response :success
|
34
|
+
ensure
|
35
|
+
tmp.unlink
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#generic with TFTP' do
|
39
|
+
setup :setup_subnet_with_tftp
|
21
40
|
setup :setup_host
|
22
41
|
|
42
|
+
test 'should generate generic image' do
|
43
|
+
perform_generic_generate
|
44
|
+
end
|
45
|
+
|
23
46
|
test 'should generate host image' do
|
24
|
-
|
25
|
-
@controller.expects(:read_file).with('temp ISO').returns('ISO image')
|
26
|
-
get :host, params: { id: @host.name }, session: set_session_user
|
27
|
-
assert_response :success
|
28
|
-
assert_equal 'ISO image', @response.body
|
47
|
+
perform_host_generate
|
29
48
|
end
|
30
49
|
|
31
50
|
test 'should generate full host image' do
|
32
|
-
|
33
|
-
@controller.expects(:read_file).with('temp ISO').returns('ISO image')
|
34
|
-
get :full_host, params: { id: @host.name }, session: set_session_user
|
35
|
-
assert_response :success
|
36
|
-
assert_equal 'ISO image', @response.body
|
51
|
+
perform_full_host_generate
|
37
52
|
end
|
53
|
+
end
|
38
54
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
55
|
+
describe '#subnet_host with TFTP and HTTPBOOT' do
|
56
|
+
setup :setup_subnet_with_tftp_httpboot_template
|
57
|
+
setup :setup_host
|
58
|
+
|
59
|
+
test 'should generate generic image' do
|
60
|
+
perform_generic_generate
|
61
|
+
end
|
62
|
+
|
63
|
+
test 'should generate host image' do
|
64
|
+
perform_host_generate
|
65
|
+
end
|
66
|
+
|
67
|
+
test 'should generate full host image' do
|
68
|
+
perform_full_host_generate
|
47
69
|
end
|
48
70
|
end
|
49
71
|
|
@@ -53,10 +75,18 @@ class ForemanBootdisk::DisksControllerTest < ActionController::TestCase
|
|
53
75
|
setup :setup_subnet_no_tftp
|
54
76
|
setup :setup_host
|
55
77
|
|
56
|
-
test 'should
|
57
|
-
|
58
|
-
|
59
|
-
|
78
|
+
test 'should prolong token for host image' do
|
79
|
+
Setting[:token_duration] = 60
|
80
|
+
@host.set_token
|
81
|
+
past = Time.now
|
82
|
+
assert @host.token.expires > past
|
83
|
+
travel_to(past + 2.hours)
|
84
|
+
assert @host.token_expired?
|
85
|
+
|
86
|
+
perform_full_host_generate
|
87
|
+
|
88
|
+
assert_equal @host.token_expired?, true
|
89
|
+
assert @host.token.expires > past
|
60
90
|
end
|
61
91
|
end
|
62
92
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
|
5
|
+
class ForemanBootdisk::SubnetDisksControllerTest < ActionController::TestCase
|
6
|
+
include ForemanBootdiskTestHelper
|
7
|
+
setup :setup_bootdisk
|
8
|
+
setup :setup_referer
|
9
|
+
setup :setup_org_loc
|
10
|
+
|
11
|
+
def perform_subnet_generate
|
12
|
+
tmp = create_tempfile
|
13
|
+
ForemanBootdisk::ISOGenerator.expects(:generate).yields(create_tempfile.path)
|
14
|
+
get :subnet, params: { id: @subnet.id }, session: set_session_user
|
15
|
+
assert_empty flash[:error]
|
16
|
+
assert_response :success
|
17
|
+
ensure
|
18
|
+
tmp.unlink
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#generic with TFTP' do
|
22
|
+
setup :setup_subnet_with_tftp
|
23
|
+
setup :setup_host
|
24
|
+
|
25
|
+
test 'should generate subnet image' do
|
26
|
+
perform_subnet_generate
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#subnet_host with TFTP and HTTPBOOT' do
|
31
|
+
setup :setup_subnet_with_tftp_httpboot_template
|
32
|
+
setup :setup_host
|
33
|
+
|
34
|
+
test 'should generate subnet image' do
|
35
|
+
perform_subnet_generate
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#host without tftp' do
|
40
|
+
setup :setup_referer
|
41
|
+
setup :setup_org_loc
|
42
|
+
setup :setup_subnet_no_tftp
|
43
|
+
setup :setup_host
|
44
|
+
|
45
|
+
test 'should not generate subnet image' do
|
46
|
+
get :subnet, params: { id: @subnet.id }, session: set_session_user
|
47
|
+
assert_match(/Failed.*: TFTP feature not enabled/, flash[:error])
|
48
|
+
assert_response :redirect
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -5,15 +5,23 @@ require 'webmock/minitest'
|
|
5
5
|
require 'webmock'
|
6
6
|
|
7
7
|
module ForemanBootdiskTestHelper
|
8
|
+
def create_tempfile
|
9
|
+
file = Tempfile.new('bootdisk-test', '/tmp')
|
10
|
+
file.close
|
11
|
+
file
|
12
|
+
end
|
13
|
+
|
8
14
|
def setup_bootdisk
|
15
|
+
ForemanBootdisk::Scope::Bootdisk.any_instance.stubs(:bootdisk_chain_url).returns('http://smart-proxy.example.com/unattended/iPXE?mac=')
|
9
16
|
setup_routes
|
10
17
|
setup_settings
|
11
18
|
setup_templates
|
12
19
|
end
|
13
20
|
|
21
|
+
# TODO remove me
|
14
22
|
def setup_host_env
|
15
23
|
setup_org_loc
|
16
|
-
|
24
|
+
setup_subnet_with_tftp
|
17
25
|
setup_host
|
18
26
|
end
|
19
27
|
|
@@ -39,7 +47,17 @@ module ForemanBootdiskTestHelper
|
|
39
47
|
@loc = FactoryBot.create(:location)
|
40
48
|
end
|
41
49
|
|
42
|
-
def
|
50
|
+
def setup_subnet_with_tftp_httpboot_template
|
51
|
+
ProxyAPI::V2::Features.any_instance.stubs(:features).returns(:httpboot => { :settings => { :https_port => 1234 }, :state => 'running' }, :templates => {}, :tftp => {})
|
52
|
+
SmartProxy.any_instance.stubs(:httpboot_http_port).returns('8888')
|
53
|
+
SmartProxy.any_instance.stubs(:httpboot_https_port).returns('9999')
|
54
|
+
|
55
|
+
proxy = FactoryBot.create(:smart_proxy, features: [FactoryBot.create(:tftp_feature), FactoryBot.create(:feature, :templates), FactoryBot.create(:feature, :httpboot)])
|
56
|
+
proxy.reload
|
57
|
+
setup_subnet_no_tftp.update! tftp: proxy, httpboot: proxy, template: proxy
|
58
|
+
end
|
59
|
+
|
60
|
+
def setup_subnet_with_tftp
|
43
61
|
tftp_proxy = FactoryBot.create(:smart_proxy, features: [FactoryBot.create(:tftp_feature)])
|
44
62
|
setup_subnet_no_tftp.update! tftp: tftp_proxy
|
45
63
|
end
|
@@ -49,6 +67,6 @@ module ForemanBootdiskTestHelper
|
|
49
67
|
end
|
50
68
|
|
51
69
|
def setup_host
|
52
|
-
@host = FactoryBot.create(:host, :managed, subnet: @subnet, ip: @subnet.network.sub(/0$/, '4'), organization: @org, location: @loc)
|
70
|
+
@host = FactoryBot.create(:host, :managed, subnet: @subnet, ip: @subnet.network.sub(/0$/, '4'), organization: @org, location: @loc, build: true)
|
53
71
|
end
|
54
72
|
end
|
@@ -36,7 +36,7 @@ module ForemanBootdisk
|
|
36
36
|
test 'host should not have bootdisk' do
|
37
37
|
if unattended?
|
38
38
|
h = FactoryBot.create(:host)
|
39
|
-
|
39
|
+
assert_not(h.bootdisk?)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -69,5 +69,16 @@ module ForemanBootdisk
|
|
69
69
|
assert host.bootdisk_downloadable?
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
context '#bootdisk_build?' do
|
74
|
+
test 'should be false for hosts without bootdisk' do
|
75
|
+
host = FactoryBot.create(:host)
|
76
|
+
assert_not host.bootdisk_build?
|
77
|
+
end
|
78
|
+
|
79
|
+
test 'should be available in safe mode' do
|
80
|
+
assert Host::Managed::Jail.allowed?(:bootdisk_build?)
|
81
|
+
end
|
82
|
+
end
|
72
83
|
end
|
73
84
|
end
|
@@ -22,29 +22,48 @@ module ForemanBootdisk
|
|
22
22
|
@host.send(:setAttachIsoImage)
|
23
23
|
end
|
24
24
|
|
25
|
-
test 'provisioning a host with provision method bootdisk should
|
25
|
+
test 'provisioning a host with provision method bootdisk should detach iso' do
|
26
|
+
@cr.expects(:iso_detach)
|
27
|
+
@host.send(:setDetachIsoImage)
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'provisioning a new host with provision method bootdisk should queue bootdisk tasks' do
|
26
31
|
@host.stubs(:compute?).returns(true)
|
32
|
+
@host.stubs(:build?).returns(true)
|
27
33
|
@host.send(:queue_bootdisk_compute)
|
28
34
|
tasks = @host.queue.all.map(&:name)
|
29
35
|
assert_includes tasks, "Generating ISO image for #{@host.name}"
|
30
36
|
assert_includes tasks, "Upload ISO image to datastore for #{@host.name}"
|
31
37
|
assert_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
|
38
|
+
assert_not_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
|
32
39
|
end
|
33
40
|
|
34
|
-
test 'should
|
35
|
-
@host.
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
test 'rebuilding a host with provision method bootdisk should queue bootdisk tasks' do
|
42
|
+
@host.stubs(:compute?).returns(true)
|
43
|
+
old = stub()
|
44
|
+
old.stubs(:build?).returns(false)
|
45
|
+
@host.stubs(:old).returns(old)
|
46
|
+
@host.stubs(:build?).returns(true)
|
47
|
+
@host.send(:queue_bootdisk_compute)
|
48
|
+
tasks = @host.queue.all.map(&:name)
|
49
|
+
assert_includes tasks, "Generating ISO image for #{@host.name}"
|
50
|
+
assert_includes tasks, "Upload ISO image to datastore for #{@host.name}"
|
51
|
+
assert_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
|
52
|
+
assert_not_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
|
39
53
|
end
|
40
54
|
|
41
|
-
test 'should
|
42
|
-
host
|
43
|
-
|
44
|
-
|
45
|
-
host.
|
46
|
-
host.
|
47
|
-
|
55
|
+
test 'the iso should be detached when the host leaves build mode' do
|
56
|
+
@host.stubs(:compute?).returns(true)
|
57
|
+
old = stub()
|
58
|
+
old.stubs(:build?).returns(true)
|
59
|
+
@host.stubs(:old).returns(old)
|
60
|
+
@host.stubs(:build?).returns(false)
|
61
|
+
@host.send(:queue_bootdisk_compute)
|
62
|
+
tasks = @host.queue.all.map(&:name)
|
63
|
+
assert_not_includes tasks, "Generating ISO image for #{@host.name}"
|
64
|
+
assert_not_includes tasks, "Upload ISO image to datastore for #{@host.name}"
|
65
|
+
assert_not_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
|
66
|
+
assert_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
|
48
67
|
end
|
49
68
|
end
|
50
69
|
end
|
@@ -21,7 +21,7 @@ module ForemanBootdisk
|
|
21
21
|
|
22
22
|
test 'does not include a host token' do
|
23
23
|
rendered_template = renderer.generic_template_render
|
24
|
-
assert_includes rendered_template, 'http://
|
24
|
+
assert_includes rendered_template, 'http://smart-proxy.example.com/unattended/iPXE?mac=${net0/mac}'
|
25
25
|
assert_not_includes rendered_template, 'token'
|
26
26
|
end
|
27
27
|
end
|