Revision 835528af
b/lib/constants.py | ||
---|---|---|
356 | 356 |
VNC_PASSWORD_FILE = _autoconf.SYSCONFDIR + "/ganeti/vnc-cluster-password" |
357 | 357 |
VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0' |
358 | 358 |
|
359 |
# Device types
|
|
359 |
# NIC types
|
|
360 | 360 |
HT_NIC_RTL8139 = "rtl8139" |
361 | 361 |
HT_NIC_NE2K_PCI = "ne2k_pci" |
362 | 362 |
HT_NIC_NE2K_ISA = "ne2k_isa" |
... | ... | |
366 | 366 |
HT_NIC_PCNET = "pcnet" |
367 | 367 |
HT_NIC_E1000 = "e1000" |
368 | 368 |
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual" |
369 |
HT_DISK_IOEMU = "ioemu" |
|
370 |
HT_DISK_IDE = "ide" |
|
371 |
HT_DISK_SCSI = "scsi" |
|
372 |
HT_DISK_SD = "sd" |
|
373 |
HT_DISK_MTD = "mtd" |
|
374 |
HT_DISK_PFLASH = "pflash" |
|
375 | 369 |
|
376 | 370 |
HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI, |
377 | 371 |
HT_NIC_NE2K_ISA, HT_NIC_PARAVIRTUAL]) |
378 |
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU]) |
|
379 | 372 |
HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI, |
380 | 373 |
HT_NIC_NE2K_ISA, HT_NIC_I82551, |
381 | 374 |
HT_NIC_I85557B, HT_NIC_I8259ER, |
382 | 375 |
HT_NIC_PCNET, HT_NIC_E1000, |
383 | 376 |
HT_NIC_PARAVIRTUAL]) |
377 |
# Disk types |
|
378 |
HT_DISK_IOEMU = "ioemu" |
|
379 |
HT_DISK_IDE = "ide" |
|
380 |
HT_DISK_SCSI = "scsi" |
|
381 |
HT_DISK_SD = "sd" |
|
382 |
HT_DISK_MTD = "mtd" |
|
383 |
HT_DISK_PFLASH = "pflash" |
|
384 |
|
|
385 |
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU]) |
|
384 | 386 |
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE, |
385 | 387 |
HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD, |
386 | 388 |
HT_DISK_PFLASH]) |
387 | 389 |
|
390 |
# Mouse types: |
|
391 |
HT_MOUSE_MOUSE = "mouse" |
|
392 |
HT_MOUSE_TABLET = "tablet" |
|
393 |
|
|
394 |
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET]) |
|
395 |
|
|
396 |
# Boot order |
|
397 |
HT_BO_CDROM = "cdrom" |
|
398 |
HT_BO_DISK = "disk" |
|
399 |
HT_BO_NETWORK = "network" |
|
400 |
|
|
401 |
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK]) |
|
402 |
|
|
388 | 403 |
# Cluster Verify steps |
389 | 404 |
VERIFY_NPLUSONE_MEM = 'nplusone_mem' |
390 | 405 |
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM]) |
... | ... | |
501 | 516 |
HV_VNC_X509: '', |
502 | 517 |
HV_VNC_X509_VERIFY: False, |
503 | 518 |
HV_CDROM_IMAGE_PATH: '', |
504 |
HV_BOOT_ORDER: "disk",
|
|
519 |
HV_BOOT_ORDER: HT_BO_DISK,
|
|
505 | 520 |
HV_NIC_TYPE: HT_NIC_PARAVIRTUAL, |
506 | 521 |
HV_DISK_TYPE: HT_DISK_PARAVIRTUAL, |
507 | 522 |
HV_USB_MOUSE: '', |
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
236 | 236 |
kvm_cmd.extend(['-no-acpi']) |
237 | 237 |
|
238 | 238 |
hvp = instance.hvparams |
239 |
boot_disk = hvp[constants.HV_BOOT_ORDER] == "disk"
|
|
240 |
boot_cdrom = hvp[constants.HV_BOOT_ORDER] == "cdrom"
|
|
241 |
boot_network = hvp[constants.HV_BOOT_ORDER] == "network"
|
|
239 |
boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK
|
|
240 |
boot_cdrom = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_CDROM
|
|
241 |
boot_network = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_NETWORK
|
|
242 | 242 |
|
243 | 243 |
if boot_network: |
244 | 244 |
kvm_cmd.extend(['-boot', 'n']) |
... | ... | |
723 | 723 |
" an absolute path, if defined") |
724 | 724 |
|
725 | 725 |
boot_order = hvparams[constants.HV_BOOT_ORDER] |
726 |
if boot_order not in ('cdrom', 'disk', 'network'): |
|
727 |
raise errors.HypervisorError("The boot order must be 'cdrom', 'disk' or" |
|
728 |
" 'network'") |
|
726 |
if boot_order not in constants.HT_KVM_VALID_BO_TYPES: |
|
727 |
raise errors.HypervisorError(\ |
|
728 |
"The boot order must be one of %s" % |
|
729 |
utils.CommaJoin(constants.HT_KVM_VALID_BO_TYPES)) |
|
729 | 730 |
|
730 |
if boot_order == 'cdrom' and not iso_path: |
|
731 |
raise errors.HypervisorError("Cannot boot from cdrom without an ISO path") |
|
731 |
if boot_order == constants.HT_BO_CDROM and not iso_path: |
|
732 |
raise errors.HypervisorError("Cannot boot from cdrom without an" |
|
733 |
" ISO path") |
|
732 | 734 |
|
733 | 735 |
nic_type = hvparams[constants.HV_NIC_TYPE] |
734 | 736 |
if nic_type not in constants.HT_KVM_VALID_NIC_TYPES: |
735 |
raise errors.HypervisorError("Invalid NIC type %s specified for the KVM" |
|
736 |
" hypervisor. Please choose one of: %s" % |
|
737 |
(nic_type, |
|
738 |
constants.HT_KVM_VALID_NIC_TYPES)) |
|
739 |
elif boot_order == 'network' and nic_type == constants.HT_NIC_PARAVIRTUAL: |
|
737 |
raise errors.HypervisorError(\ |
|
738 |
"Invalid NIC type %s specified for the KVM" |
|
739 |
" hypervisor. Please choose one of: %s" % |
|
740 |
(nic_type, utils.CommaJoin(constants.HT_KVM_VALID_NIC_TYPES))) |
|
741 |
elif (boot_order == constants.HT_BO_NETWORK and |
|
742 |
nic_type == constants.HT_NIC_PARAVIRTUAL): |
|
740 | 743 |
raise errors.HypervisorError("Cannot boot from a paravirtual NIC. Please" |
741 |
" change the nic type.")
|
|
744 |
" change the NIC type.")
|
|
742 | 745 |
|
743 | 746 |
disk_type = hvparams[constants.HV_DISK_TYPE] |
744 | 747 |
if disk_type not in constants.HT_KVM_VALID_DISK_TYPES: |
745 |
raise errors.HypervisorError("Invalid disk type %s specified for the KVM"
|
|
746 |
" hypervisor. Please choose one of: %s" %
|
|
747 |
(disk_type,
|
|
748 |
constants.HT_KVM_VALID_DISK_TYPES))
|
|
748 |
raise errors.HypervisorError(\
|
|
749 |
"Invalid disk type %s specified for the KVM"
|
|
750 |
" hypervisor. Please choose one of: %s" %
|
|
751 |
(disk_type, utils.CommaJoin(constants.HT_KVM_VALID_DISK_TYPES)))
|
|
749 | 752 |
|
750 | 753 |
mouse_type = hvparams[constants.HV_USB_MOUSE] |
751 |
if mouse_type and mouse_type not in ('mouse', 'tablet'): |
|
752 |
raise errors.HypervisorError("Invalid usb mouse type %s specified for" |
|
753 |
" the KVM hyervisor. Please choose" |
|
754 |
" 'mouse' or 'tablet'" % mouse_type) |
|
754 |
if mouse_type and mouse_type not in constants.HT_KVM_VALID_MOUSE_TYPES: |
|
755 |
raise errors.HypervisorError(\ |
|
756 |
"Invalid usb mouse type %s specified for the KVM hypervisor. Please" |
|
757 |
" choose one of %s" % |
|
758 |
utils.CommaJoin(constants.HT_KVM_VALID_MOUSE_TYPES)) |
|
755 | 759 |
|
756 | 760 |
def ValidateParameters(self, hvparams): |
757 | 761 |
"""Check the given parameters for validity. |
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
535 | 535 |
# device type checks |
536 | 536 |
nic_type = hvparams[constants.HV_NIC_TYPE] |
537 | 537 |
if nic_type not in constants.HT_HVM_VALID_NIC_TYPES: |
538 |
raise errors.HypervisorError("Invalid NIC type %s specified for the Xen"
|
|
539 |
" HVM hypervisor. Please choose one of: %s"
|
|
540 |
% (nic_type,
|
|
541 |
constants.HT_HVM_VALID_NIC_TYPES))
|
|
538 |
raise errors.HypervisorError(\
|
|
539 |
"Invalid NIC type %s specified for the Xen"
|
|
540 |
" HVM hypervisor. Please choose one of: %s"
|
|
541 |
% (nic_type, utils.CommaJoin(constants.HT_HVM_VALID_NIC_TYPES)))
|
|
542 | 542 |
disk_type = hvparams[constants.HV_DISK_TYPE] |
543 | 543 |
if disk_type not in constants.HT_HVM_VALID_DISK_TYPES: |
544 |
raise errors.HypervisorError("Invalid disk type %s specified for the Xen"
|
|
545 |
" HVM hypervisor. Please choose one of: %s"
|
|
546 |
% (disk_type,
|
|
547 |
constants.HT_HVM_VALID_DISK_TYPES))
|
|
544 |
raise errors.HypervisorError(\
|
|
545 |
"Invalid disk type %s specified for the Xen"
|
|
546 |
" HVM hypervisor. Please choose one of: %s"
|
|
547 |
% (disk_type, utils.CommaJoin(constants.HT_HVM_VALID_DISK_TYPES)))
|
|
548 | 548 |
# vnc_bind_address verification |
549 | 549 |
vnc_bind_address = hvparams[constants.HV_VNC_BIND_ADDRESS] |
550 | 550 |
if vnc_bind_address: |
b/lib/utils.py | ||
---|---|---|
1833 | 1833 |
return text |
1834 | 1834 |
|
1835 | 1835 |
|
1836 |
def CommaJoin(names): |
|
1837 |
"""Nicely join a set of identifiers. |
|
1838 |
|
|
1839 |
@param names: set, list or tuple |
|
1840 |
@return: a string with the formatted results |
|
1841 |
|
|
1842 |
""" |
|
1843 |
return ", ".join(["'%s'" % val for val in names]) |
|
1844 |
|
|
1845 |
|
|
1836 | 1846 |
def LockedMethod(fn): |
1837 | 1847 |
"""Synchronized object access decorator. |
1838 | 1848 |
|
Also available in: Unified diff