From 2584d4a40f00b6c667580225d5440e41633b9728 Mon Sep 17 00:00:00 2001
From: Alexander Schreiber <als@google.com>
Date: Tue, 18 Dec 2007 14:05:11 +0000
Subject: [PATCH] cleanup for hypervisor constants

Move constant definitions for hypervisor into constants.py

Reviewed-by: ultrotter
---
 lib/cmdlib.py     | 2 +-
 lib/constants.py  | 6 ++++++
 lib/hypervisor.py | 8 ++------
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index d572a1d13..37b2bb968 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -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)
 
diff --git a/lib/constants.py b/lib/constants.py
index 6c6598342..5dfba2b48 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -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])
diff --git a/lib/hypervisor.py b/lib/hypervisor.py
index 3eb5368c5..24efa0163 100644
--- a/lib/hypervisor.py
+++ b/lib/hypervisor.py
@@ -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)
-- 
GitLab