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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
# File '../../src/modules/VirtConfig.rb', line 191
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.")
def Information
widgets = Frame(_("Choose Hypervisor(s) to install"),
HBox(
VBox(
Left(Label(_("Server: Minimal system to get a running Hypervisor"))),
Left(Label(_("Tools: Configure, manage and monitor virtual machines"))),
),
HSpacing(2),
),
)
end
def VMButtonBox
widgetB = ButtonBox(
PushButton(Id(:accept), Label.AcceptButton),
PushButton(Id(:cancel), Label.CancelButton),
)
end
def KVMDialog
widgetKVM = Frame(_("KVM Hypervisor"),
HBox(
Left(CheckBox(Id(:kvm_server), Opt(:key_F6), _("KVM server"))),
Left(CheckBox(Id(:kvm_tools), Opt(:key_F7), _("KVM tools"))),
),
)
end
def LXCDialog
widgetLXC = Frame(_("libvirt LXC containers"),
HBox(
Left(CheckBox(Id(:lxc), Opt(:key_F4), _("libvirt LXC daemon"))),
),
)
end
if is_s390 == true
UI.OpenDialog(
HBox(
HSpacing(2),
VBox(
Information(),
VSpacing(1),
KVMDialog(),
LXCDialog(),
VMButtonBox(),
),
),
)
elsif isSLED == true
progress_stages = [
_("Verify Installed Packages")
]
UI.OpenDialog(
HBox(
HSpacing(2),
VBox(
VSpacing(1),
Frame(_("Software to connect to Virtualization server"),
HBox(
Left(CheckBox(Id(:client_tools), _("Virtualization client tools"))),
),
),
LXCDialog(),
VMButtonBox(),
),
),
)
else
UI.OpenDialog(
HBox(
HSpacing(2),
VBox(
VSpacing(1),
Information(),
VSpacing(1),
Frame(_("Xen Hypervisor"),
HBox(
Left(CheckBox(Id(:xen_server), Opt(:key_F8), _("Xen server"))),
Left(CheckBox(Id(:xen_tools), Opt(:key_F9), _("Xen tools"))),
),
),
KVMDialog(),
LXCDialog(),
VMButtonBox(),
),
),
)
end
widget_id = UI.UserInput
if widget_id == :accept
install_xen_server = UI.QueryWidget(Id(:xen_server), :Value)
install_xen_tools = UI.QueryWidget(Id(:xen_tools), :Value)
install_kvm_server = UI.QueryWidget(Id(:kvm_server), :Value)
install_kvm_tools = UI.QueryWidget(Id(:kvm_tools), :Value)
install_client_tools = UI.QueryWidget(Id(:client_tools), :Value)
install_lxc = UI.QueryWidget(Id(:lxc), :Value)
end
UI.CloseDialog
install_vm = false
install_vm = true if install_xen_server
install_vm = true if install_xen_tools
install_xen = true if install_xen_server || install_xen_tools
install_vm = true if install_kvm_server
install_vm = true if install_kvm_tools
install_kvm = true if install_kvm_server || install_kvm_tools
install_vm = true if install_client_tools
if widget_id == :cancel || !install_vm && !install_lxc
Builtins.y2milestone(
"VirtConfig::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 = []
common_vm_packages = []
if install_vm == true
common_vm_packages = ["libvirt-client"]
if isSLED == false
common_vm_packages = common_vm_packages + ["vm-install", "virt-install", "bridge-utils"]
end
end
result = true
if isOpenSuse == true
packages = ["patterns-openSUSE-xen_server"] if install_xen_server
packages = packages + ["xen-tools", "xen-libs", "libvirt-daemon-xen", "tigervnc"] if install_xen_tools
packages = packages + ["patterns-openSUSE-kvm_server"] if install_kvm_server
packages = packages + ["libvirt-daemon-qemu", "tigervnc"] if install_kvm_tools
packages = packages + ["libvirt-daemon-lxc", "libvirt-daemon-config-network"] if install_lxc
result = Package.DoInstall(common_vm_packages + packages)
if result == false
Report.Error(_("Package installation failed\n"))
return false
end
else
if install_lxc
packages = ["libvirt-daemon-lxc", "libvirt-daemon-config-network"]
result = Package.DoInstall(packages)
if result == false
Report.Error(_("Package installation failed for lxc\n"))
return false
end
end
if isSLED == true
result = Package.DoInstall(["pattern-sled-virtualization_client"]) if install_client_tools
if result == false
Report.Error(_("Package installation failed for sled client pattern\n"))
return false
end
else
packages = packages + ["patterns-sles-xen_server"] if install_xen_server
packages = packages + ["patterns-sles-xen_tools"] if install_xen_tools
packages = packages + ["patterns-sles-kvm_server"] if install_kvm_server
packages = packages + ["patterns-sles-kvm_tools"] if install_kvm_tools
result = Package.DoInstall(packages)
if result == false
Report.Error(_("Package installation failed for sles patterns\n"))
return false
end
end
end
inst_gui = true
Builtins.y2milestone("VirtConfig::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" || Bootloader.getLoaderType == "grub2-efi"
Progress.Title(_("Updating grub2 configuration files..."))
BootCommon.location_changed = true
old_progress = Progress.set(false)
Bootloader.Write
Progress.set(old_progress)
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
if isSLED == 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...")
Lan.Read(:cache)
Lan.ProposeVirtualized
Lan.Write
end
end
end
else
switch_amode = Bootloader.kernel_param(:common, "switch_amode")
if switch_amode == :missing
Builtins.y2milestone(
"No switch_amode kernel boot parameter in /etc/zipl.conf, adding ..."
)
Bootloader.modify_kernel_params(:common, "switch_amode", :present)
if Bootloader.Write
zipl_updated = true
Builtins.y2milestone(
"Successful update of /etc/zipl.conf with the switch_amode kernel boot parameter"
)
else
Builtins.y2milestone(
"Failed to correctly update /etc/zipl.conf with switch_amode kernel boot parameter"
)
end
end
end
reloadApparmor
cmd = "systemctl enable libvirtd.service"
Builtins.y2milestone("Enable libvirtd.service: %1", cmd)
SCR.Execute(path(".target.bash"), cmd)
cmd = "systemctl start libvirtd.service"
Builtins.y2milestone("Start libvirtd.service: %1", cmd)
SCR.Execute(path(".target.bash"), cmd)
Progress.Finish
message_kvm_ready = _(
"KVM components are installed. Your host is ready to install KVM guests."
)
message_kvm_reboot = _(
"KVM components are installed. Reboot the machine and select the native kernel in the boot loader menu to install KVM guests."
)
message_xen_reboot = _(
"For installing Xen guests, reboot the machine and select the Xen section in the boot loader menu."
)
message_xen_ready = _("Xen Hypervisor and tools are installed.")
message_client_ready = _("Virtualization client tools are installed.")
message_lxc_ready = _("Libvirt LXC components are installed.")
message = ""
if Arch.is_xen == false
if install_kvm
message.concat(message_kvm_ready)
message.concat("\n\n")
end
if install_xen
message.concat(message_xen_reboot)
message.concat("\n\n")
end
else
if install_xen
message.concat(message_xen_ready)
message.concat("\n\n")
end
if install_kvm
message.concat(message_kvm_reboot)
message.concat("\n\n")
end
end
if install_client_tools
message.concat(message_client_ready)
message.concat("\n\n")
end
if install_lxc
message.concat(message_lxc_ready)
end
Popup.LongMessage(message)
Wizard.CloseDialog
Builtins.y2milestone("VirtConfig::ConfigureDom0 returned: %1", success)
success
end
|