EnsureKvmdOnNodes is called in both LUClusterSetParams, LUNodeSetParams
to make sure ganeti-kvmd is running/stopped according to the desired
configuration. This patch silences the KVM related warnings on non-KVM
clusters.

Signed-off-by: Viktor Bachraty <[email protected]>
---
 lib/cmdlib/common.py | 19 ++++++++++++-------
 lib/cmdlib/node.py   |  5 +++--
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/lib/cmdlib/common.py b/lib/cmdlib/common.py
index 2c44ac7..d2ccf9b 100644
--- a/lib/cmdlib/common.py
+++ b/lib/cmdlib/common.py
@@ -1535,7 +1535,7 @@ def DetermineImageSize(lu, image, node_uuid):
   return math.ceil(byte_size / 1024. / 1024.)
 
 
-def EnsureKvmdOnNodes(lu, feedback_fn, nodes=None):
+def EnsureKvmdOnNodes(lu, feedback_fn, nodes=None, silent=False):
   """Ensure KVM daemon is running on nodes with KVM instances.
 
   If user shutdown is enabled in the cluster:
@@ -1558,6 +1558,9 @@ def EnsureKvmdOnNodes(lu, feedback_fn, nodes=None):
   @param nodes: if supplied, it overrides the node uuids to start/stop;
                 this is used mainly for optimization
 
+  @type silent: bool
+  @param silent: if we should issue a warning in case KVM daemon is already in
+                 the desired state
   """
   cluster = lu.cfg.GetClusterInfo()
 
@@ -1585,16 +1588,18 @@ def EnsureKvmdOnNodes(lu, feedback_fn, nodes=None):
   # Start KVM where necessary
   if start_nodes:
     results = lu.rpc.call_node_ensure_daemon(start_nodes, constants.KVMD, True)
-    for node_uuid in start_nodes:
-      results[node_uuid].Warn("Failed to start KVM daemon in node '%s'" %
-                              node_uuid, feedback_fn)
+    if not silent:
+      for node_uuid in start_nodes:
+        results[node_uuid].Warn("Failed to start KVM daemon in node '%s'" %
+                                node_uuid, feedback_fn)
 
   # Stop KVM where necessary
   if stop_nodes:
     results = lu.rpc.call_node_ensure_daemon(stop_nodes, constants.KVMD, False)
-    for node_uuid in stop_nodes:
-      results[node_uuid].Warn("Failed to stop KVM daemon in node '%s'" %
-                              node_uuid, feedback_fn)
+    if not silent:
+      for node_uuid in stop_nodes:
+        results[node_uuid].Warn("Failed to stop KVM daemon in node '%s'" %
+                                node_uuid, feedback_fn)
 
 
 def WarnAboutFailedSshUpdates(result, master_uuid, feedback_fn):
diff --git a/lib/cmdlib/node.py b/lib/cmdlib/node.py
index ddae675..4bb852b 100644
--- a/lib/cmdlib/node.py
+++ b/lib/cmdlib/node.py
@@ -469,7 +469,8 @@ class LUNodeAdd(LogicalUnit):
     else:
       self.cfg.RemoveNodeFromCandidateCerts(self.new_node.uuid, warn_fn=None)
 
-    EnsureKvmdOnNodes(self, feedback_fn, nodes=[self.new_node.uuid])
+    EnsureKvmdOnNodes(self, feedback_fn, nodes=[self.new_node.uuid],
+                      silent=True)
 
     # Update SSH setup of all nodes
     if self.op.node_setup:
@@ -857,7 +858,7 @@ class LUNodeSetParams(LogicalUnit):
       if self.old_role == self._ROLE_CANDIDATE:
         RemoveNodeCertFromCandidateCerts(self.cfg, node.uuid)
 
-    EnsureKvmdOnNodes(self, feedback_fn, nodes=[node.uuid])
+    EnsureKvmdOnNodes(self, feedback_fn, nodes=[node.uuid], silent=True)
 
     # this will trigger job queue propagation or cleanup if the mc
     # flag changed
-- 
2.7.0.rc3.207.g0ac5344

Reply via email to