From 00cd937c3b2428494d6a612e0614aad2e92262e9 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 8 Oct 2008 14:31:43 +0000 Subject: [PATCH] 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 --- lib/bootstrap.py | 2 +- lib/cmdlib.py | 10 +++++----- lib/constants.py | 8 ++++---- lib/hypervisor/__init__.py | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/bootstrap.py b/lib/bootstrap.py index af9cb9297..a873a63a0 100644 --- a/lib/bootstrap.py +++ b/lib/bootstrap.py @@ -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" % diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 8c0384588..eaefed1d8 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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" diff --git a/lib/constants.py b/lib/constants.py index afd40c772..56896645a 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -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' diff --git a/lib/hypervisor/__init__.py b/lib/hypervisor/__init__.py index d87219597..83604022d 100644 --- a/lib/hypervisor/__init__.py +++ b/lib/hypervisor/__init__.py @@ -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, } -- GitLab