Commit 00cd937c authored by Iustin Pop's avatar Iustin Pop
Browse files

Sanitize the hypervisor names

Since in 2.0 the user will possibly have more interaction with the
hypervisor names, we sanitize them by removing the version numbers
(the version can be a prerequisite for the ganeti installation, we
shouldn't document it in variable names).

Reviewed-by: schreiberal
parent 188fbf41
......@@ -114,7 +114,7 @@ def InitCluster(cluster_name, hypervisor_type, mac_prefix, def_bridge,
if config.ConfigWriter.IsCluster():
raise errors.OpPrereqError("Cluster is already initialised")
if hypervisor_type == constants.HT_XEN_HVM31:
if hypervisor_type == constants.HT_XEN_HVM:
if not os.path.exists(constants.VNC_PASSWORD_FILE):
raise errors.OpPrereqError("Please prepare the cluster VNC"
"password file %s" %
......
......@@ -1814,7 +1814,7 @@ class LUAddNode(LogicalUnit):
(fname, to_node))
to_copy = []
if constants.HT_XEN_HVM31 in self.cfg.GetClusterInfo().enabled_hypervisors:
if constants.HT_XEN_HVM in self.cfg.GetClusterInfo().enabled_hypervisors:
to_copy.append(constants.VNC_PASSWORD_FILE)
for fname in to_copy:
result = rpc.call_upload_file([node], fname)
......@@ -3493,7 +3493,7 @@ class LUCreateInstance(LogicalUnit):
self.op.vnc_bind_address)
# Xen HVM device type checks
if self.op.hypervisor == constants.HT_XEN_HVM31:
if self.op.hypervisor == constants.HT_XEN_HVM:
if self.op.hvm_nic_type not in constants.HT_HVM_VALID_NIC_TYPES:
raise errors.OpPrereqError("Invalid NIC type %s specified for Xen HVM"
" hypervisor" % self.op.hvm_nic_type)
......@@ -4433,11 +4433,11 @@ class LUQueryInstanceData(NoHooksLU):
}
htkind = instance.hypervisor
if htkind == constants.HT_XEN_PVM30:
if htkind == constants.HT_XEN_PVM:
idict["kernel_path"] = instance.kernel_path
idict["initrd_path"] = instance.initrd_path
if htkind == constants.HT_XEN_HVM31:
if htkind == constants.HT_XEN_HVM:
idict["hvm_boot_order"] = instance.hvm_boot_order
idict["hvm_acpi"] = instance.hvm_acpi
idict["hvm_pae"] = instance.hvm_pae
......@@ -4659,7 +4659,7 @@ class LUSetInstanceParams(LogicalUnit):
" node %s" % node)
# Xen HVM device type checks
if instance.hypervisor == constants.HT_XEN_HVM31:
if instance.hypervisor == constants.HT_XEN_HVM:
if self.op.hvm_nic_type is not None:
if self.op.hvm_nic_type not in constants.HT_HVM_VALID_NIC_TYPES:
raise errors.OpPrereqError("Invalid NIC type %s specified for Xen"
......
......@@ -253,12 +253,12 @@ INSTANCE_REBOOT_HARD = "hard"
INSTANCE_REBOOT_FULL = "full"
# Hypervisor constants
HT_XEN_PVM30 = "xen-3.0"
HT_XEN_PVM = "xen-pvm"
HT_FAKE = "fake"
HT_XEN_HVM31 = "xen-hvm-3.1"
HT_XEN_HVM = "xen-hvm"
HT_KVM = "kvm"
HYPER_TYPES = frozenset([HT_XEN_PVM30, HT_FAKE, HT_XEN_HVM31, HT_KVM])
HTS_REQ_PORT = frozenset([HT_XEN_HVM31])
HYPER_TYPES = frozenset([HT_XEN_PVM, HT_FAKE, HT_XEN_HVM, HT_KVM])
HTS_REQ_PORT = frozenset([HT_XEN_HVM])
HT_HVM_VNC_BASE_PORT = 5900
HT_HVM_DEFAULT_BOOT_ORDER = 'dc'
......
......@@ -32,8 +32,8 @@ from ganeti.hypervisor import hv_kvm
_HYPERVISOR_MAP = {
constants.HT_XEN_PVM30: hv_xen.XenPvmHypervisor,
constants.HT_XEN_HVM31: hv_xen.XenHvmHypervisor,
constants.HT_XEN_PVM: hv_xen.XenPvmHypervisor,
constants.HT_XEN_HVM: hv_xen.XenHvmHypervisor,
constants.HT_FAKE: hv_fake.FakeHypervisor,
constants.HT_KVM: hv_kvm.KVMHypervisor,
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment