From 4f7a6a10561a8725a250b0132c1c5a477c8df1c8 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 22 Mar 2010 13:27:07 +0100
Subject: [PATCH] Distribute list of enabled hypervisors in ssconf
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This can be used by nodes to know which hypervisors they are supposed to
support.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 lib/config.py    | 4 ++++
 lib/constants.py | 1 +
 lib/ssconf.py    | 9 +++++++++
 3 files changed, 14 insertions(+)

diff --git a/lib/config.py b/lib/config.py
index c0dc69d46..15fc1f64b 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -1369,6 +1369,9 @@ class ConfigWriter:
 
     cluster = self._config_data.cluster
     cluster_tags = fn(cluster.GetTags())
+
+    hypervisor_list = fn(cluster.enabled_hypervisors)
+
     return {
       constants.SS_CLUSTER_NAME: cluster.cluster_name,
       constants.SS_CLUSTER_TAGS: cluster_tags,
@@ -1385,6 +1388,7 @@ class ConfigWriter:
       constants.SS_ONLINE_NODES: on_data,
       constants.SS_INSTANCE_LIST: instance_data,
       constants.SS_RELEASE_VERSION: constants.RELEASE_VERSION,
+      constants.SS_HYPERVISOR_LIST: hypervisor_list,
       }
 
   @locking.ssynchronized(_config_lock, shared=1)
diff --git a/lib/constants.py b/lib/constants.py
index f84147110..0691a2011 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -660,6 +660,7 @@ SS_OFFLINE_NODES = "offline_nodes"
 SS_ONLINE_NODES = "online_nodes"
 SS_INSTANCE_LIST = "instance_list"
 SS_RELEASE_VERSION = "release_version"
+SS_HYPERVISOR_LIST = "hypervisor_list"
 
 # cluster wide default parameters
 DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
diff --git a/lib/ssconf.py b/lib/ssconf.py
index ffb2ddfe8..4bee1a644 100644
--- a/lib/ssconf.py
+++ b/lib/ssconf.py
@@ -282,6 +282,7 @@ class SimpleStore(object):
     constants.SS_ONLINE_NODES,
     constants.SS_INSTANCE_LIST,
     constants.SS_RELEASE_VERSION,
+    constants.SS_HYPERVISOR_LIST,
     )
   _MAX_SIZE = 131072
 
@@ -423,6 +424,14 @@ class SimpleStore(object):
     nl = data.splitlines(False)
     return nl
 
+  def GetHypervisorList(self):
+    """Return the list of enabled hypervisors.
+
+    """
+    data = self._ReadFile(constants.SS_HYPERVISOR_LIST)
+    nl = data.splitlines(False)
+    return nl
+
 
 def GetMasterAndMyself(ss=None):
   """Get the master node and my own hostname.
-- 
GitLab