172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
# File '../../src/modules/VM_XEN.rb', line 172
def ConfigureDom0(is_s390)
progress_stages = [
_("Verify Installed Packages"),
_("Network Bridge Configuration")
]
progress_descriptions = []
bridge_exists = false
install_xen = false
install_kvm = false
widget_id = nil
bridge_path = ""
progress_length = Builtins.size(progress_stages)
headline = _("Configuring the VM Server (domain 0)")
help_text = _(
"<p><big><b>VM Server Configuration</b></big></p><p>Configuration of the VM Server (domain 0) has two parts.</p>"
) +
_(
"<p>The required packages are installed into the system first. Then the boot loader is switched to GRUB (if not already used) and the Xen section is added to the boot loader menu if it is missing.</p>"
) +
_(
"<p>GRUB is needed because it supports the multiboot standard required to boot Xen and the Linux kernel.</p>"
) +
_(
"<p>When the configuration has finished successfully, you can boot the VM Server from the boot loader menu.</p>"
)
abortmsg = _("The installation will be aborted.")
if is_s390 == true
UI.OpenDialog(
VBox(
Label(_("Select the virtualization platform to install.")),
Left(CheckBox(Id(:xen), Opt(:disabled), "Xen")),
Left(CheckBox(Id(:kvm), "KVM")),
ButtonBox(
PushButton(Id(:accept), Label.AcceptButton),
PushButton(Id(:cancel), Label.CancelButton)
)
)
)
else
UI.OpenDialog(
VBox(
Label(_("Select the virtualization platform to install.")),
Left(CheckBox(Id(:xen), "Xen")),
Left(CheckBox(Id(:kvm), "KVM")),
ButtonBox(
PushButton(Id(:accept), Label.AcceptButton),
PushButton(Id(:cancel), Label.CancelButton)
)
)
)
end
widget_id = UI.UserInput
if widget_id == :accept
install_xen = Convert.to_boolean(UI.QueryWidget(Id(:xen), :Value))
install_kvm = Convert.to_boolean(UI.QueryWidget(Id(:kvm), :Value))
end
UI.CloseDialog
if widget_id == :cancel || install_xen == false && install_kvm == false
Builtins.y2milestone(
"VM_XEN::ConfigureDom0 Cancel Selected or no platform selected."
)
return false
end
Wizard.OpenNextBackDialog
Wizard.SetDesktopTitleAndIcon("xen")
progress = Progress.set(true)
Progress.New(
headline,
"",
progress_length,
progress_stages,
progress_descriptions,
help_text
)
Progress.NextStage
packages = ["libvirt-python", "vm-install"]
if install_xen
packages = Builtins.add(packages, "libvirt-daemon-xen")
packages = Builtins.add(packages, "xen")
packages = Builtins.add(packages, "xen-libs")
packages = Builtins.add(packages, "xen-tools")
packages = Builtins.add(packages, "kernel-xen")
end
if install_kvm
packages = Builtins.add(packages, "libvirt-daemon-qemu")
packages = Builtins.add(packages, "kvm")
end
inst_gui = true
Builtins.y2milestone("VM_XEN::ConfigureDom0 Checking for packages...")
if Ops.get_boolean(UI.GetDisplayInfo, "TextMode", true) == true
inst_gui = Popup.YesNo(
_("Running in text mode. Install graphical components anyway?")
)
end
if inst_gui == true
packages = Builtins.add(packages, "python-gtk")
packages = Builtins.add(packages, "virt-manager")
packages = Builtins.add(packages, "virt-viewer")
end
success = true
Progress.Title(_("Checking packages..."))
if Package.InstalledAll(packages) == false
Progress.Title(_("Installing packages..."))
success = Package.InstallAll(packages)
if success == false
Report.Error(
Ops.add(_("Cannot install required packages.") + "\n", abortmsg)
)
return false
end
if Package.InstalledAll(packages) == false
Report.Error(
Ops.add(_("Cannot install required packages.") + "\n", abortmsg)
)
return false
end
end
if install_xen
Builtins.y2milestone("Checking for bootloader type")
if Bootloader.getLoaderType == "grub2"
Progress.Title(_("Updating grub2 configuration files..."))
cmd = "/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg"
Builtins.y2milestone("Executing: %1", cmd)
SCR.Execute(path(".target.bash"), cmd)
end
end
if is_s390 == false
Progress.NextStage
Progress.Title(_("Configuring Default Network Bridge..."))
interfaces = Convert.convert(
SCR.Read(path(".target.dir"), @net_path),
:from => "any",
:to => "list <string>"
)
Builtins.foreach(interfaces) do |i|
Builtins.y2milestone("Checking for bridges...")
bridge_path = Ops.add(Ops.add(Ops.add(@net_path, "/"), i), "/bridge")
if Ops.greater_or_equal(SCR.Read(path(".target.dir"), bridge_path), 0)
Builtins.y2milestone("Dom0 already has a configured bridge.")
bridge_exists = true
raise Break
end
end
if bridge_exists == false
if Popup.AnyQuestionRichText(
_("Network Bridge."),
_(
"<p>For normal network configurations hosting virtual machines, a network bridge is recommended.</p><p>Configure a default network bridge?</p>"
),
45,
5,
Label.YesButton,
Label.NoButton,
:focus_yes
)
Builtins.y2milestone("Configuring default bridge for Xen or KVM...")
WFM.call("lan_proposal", ["MakeProposal"])
UI.OpenDialog(VBox())
WFM.call("lan_proposal", ["Write"])
UI.CloseDialog
end
end
if isOpenSuse == true
cmd = "systemctl enable libvirtd.service"
Builtins.y2milestone("Executing: %1", cmd)
SCR.Execute(path(".target.bash"), cmd)
end
else
def_section = Bootloader.getDefaultSection
switch_amode = Bootloader.getKernelParam(def_section, "switch_amode")
if switch_amode == "false"
zipl_updated = false
Builtins.y2milestone(
"No switch_amode kernel boot parameter in /etc/zipl.conf, adding ..."
)
if Bootloader.setKernelParam(def_section, "switch_amode", "true") == true
if Bootloader.Write == true
zipl_updated = true
cmd = "/sbin/zipl"
Builtins.y2milestone("Executing: %1", cmd)
SCR.Execute(path(".target.bash"), cmd)
Builtins.y2milestone(
"Successful update of /etc/zipl.conf with the switch_amode kernel boot parameter"
)
end
end
if zipl_updated == false
Builtins.y2milestone(
"Failed to correctly update /etc/zipl.conf with switch_amode kernel boot parameter"
)
end
end
end
Progress.Finish
message_kvm = _(
"For installing KVM guests, reboot the machine to load the necessary drivers."
)
message_xen_reboot = _(
"For installing Xen guests, reboot the machine and select the Xen section in the boot loader menu.\n"
)
message_xen_ready = _("Hypervisor and tools are installed.")
message = nil
if install_xen == false
Popup.LongMessage(message_kvm)
else
if Arch.is_xen == false
if install_kvm == true
message = Builtins.sformat(
"%1\n\n%2",
message_kvm,
message_xen_reboot
)
else
message = message_xen_reboot
end
Popup.LongMessage(message)
else
if install_kvm == true
message = Builtins.sformat(
"%1\n\n%2",
message_kvm,
message_xen_ready
)
else
message = message_xen_ready
end
Popup.Message(message)
end
end
Wizard.CloseDialog
Builtins.y2milestone("VM_XEN::ConfigureDom0 returned: %1", success)
success
end
|