Commit 2584d4a4 authored by Alexander Schreiber's avatar Alexander Schreiber
Browse files

cleanup for hypervisor constants

Move constant definitions for hypervisor into constants.py

Reviewed-by: ultrotter
parent 79caa9ed
......@@ -538,7 +538,7 @@ class LUInitCluster(LogicalUnit):
raise errors.OpPrereqError("Invalid mac prefix given '%s'" %
self.op.mac_prefix)
if self.op.hypervisor_type not in hypervisor.VALID_HTYPES:
if self.op.hypervisor_type not in constants.HYPER_TYPES:
raise errors.OpPrereqError("Invalid hypervisor type given '%s'" %
self.op.hypervisor_type)
......
......@@ -147,3 +147,9 @@ SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
INSTANCE_REBOOT_SOFT = "soft"
INSTANCE_REBOOT_HARD = "hard"
INSTANCE_REBOOT_FULL = "full"
# Hypervisor constants
HT_XEN30 = "xen-3.0"
HT_FAKE = "fake"
HYPER_TYPES = frozenset([HT_XEN30, HT_FAKE])
......@@ -33,10 +33,6 @@ from ganeti import ssconf
from ganeti import constants
from ganeti.errors import HypervisorError
_HT_XEN30 = "xen-3.0"
_HT_FAKE = "fake"
VALID_HTYPES = (_HT_XEN30, _HT_FAKE)
def GetHypervisor():
"""Return a Hypervisor instance.
......@@ -46,9 +42,9 @@ def GetHypervisor():
"""
ht_kind = ssconf.SimpleStore().GetHypervisorType()
if ht_kind == _HT_XEN30:
if ht_kind == constants.HT_XEN30:
cls = XenHypervisor
elif ht_kind == _HT_FAKE:
elif ht_kind == constants.HT_FAKE:
cls = FakeHypervisor
else:
raise HypervisorError("Unknown hypervisor type '%s'" % ht_kind)
......
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