For now the rpc is always called with this parameter set to False.
When the parameter is set to True and start_daemons is also True,
ganeti-masterd will be started with the new --no-voting --yes-do-it
system.

Signed-off-by: Guido Trotter <[email protected]>
---
 daemons/ganeti-masterd |    2 +-
 daemons/ganeti-noded   |    2 +-
 lib/backend.py         |   20 ++++++++++++++++----
 lib/bootstrap.py       |    4 ++--
 lib/cmdlib.py          |    2 +-
 lib/rpc.py             |    4 ++--
 6 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd
index 7456d4e..ca864e9 100755
--- a/daemons/ganeti-masterd
+++ b/daemons/ganeti-masterd
@@ -517,7 +517,7 @@ def main():
     try:
       # activate ip
       master_node = ssconf.SimpleConfigReader().GetMasterNode()
-      if not rpc.RpcRunner.call_node_start_master(master_node, False):
+      if not rpc.RpcRunner.call_node_start_master(master_node, False, False):
         logging.error("Can't activate master IP address")
 
       master.setup_queue()
diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded
index 9600e30..1f2862f 100755
--- a/daemons/ganeti-noded
+++ b/daemons/ganeti-noded
@@ -520,7 +520,7 @@ class NodeHttpServer(http.server.HttpServer):
     """Promote this node to master status.
 
     """
-    return backend.StartMaster(params[0])
+    return backend.StartMaster(params[0], params[1])
 
   @staticmethod
   def perspective_node_stop_master(params):
diff --git a/lib/backend.py b/lib/backend.py
index bca3512..f9d9df8 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -147,7 +147,7 @@ def GetMasterInfo():
   return (master_netdev, master_ip, master_node)
 
 
-def StartMaster(start_daemons):
+def StartMaster(start_daemons, no_voting):
   """Activate local node as master node.
 
   The function will always try activate the IP address of the master
@@ -155,8 +155,11 @@ def StartMaster(start_daemons):
   based on the start_daemons parameter.
 
   @type start_daemons: boolean
-  @param start_daemons: whther to also start the master
+  @param start_daemons: whether to also start the master
       daemons (ganeti-masterd and ganeti-rapi)
+  @type no_voting: boolean
+  @param no_voting: whether to start ganeti-masterd without a node vote
+      (if start_daemons is True), but still non-interactively
   @rtype: None
 
   """
@@ -186,8 +189,17 @@ def StartMaster(start_daemons):
 
   # and now start the master and rapi daemons
   if start_daemons:
-    for daemon in 'ganeti-masterd', 'ganeti-rapi':
-      result = utils.RunCmd([daemon])
+    daemons_params = {
+        'ganeti-masterd': [],
+        'ganeti-rapi': [],
+        }
+    if no_voting:
+      daemons_params['ganeti-masterd'].append('--no-voting')
+      daemons_params['ganeti-masterd'].append('--yes-do-it')
+    for daemon in daemons_params:
+      cmd = [daemon]
+      cmd.extend(daemons_params[daemon])
+      result = utils.RunCmd(cmd)
       if result.failed:
         logging.error("Can't start daemon %s: %s", daemon, result.output)
         ok = False
diff --git a/lib/bootstrap.py b/lib/bootstrap.py
index 0308484..1990fc4 100644
--- a/lib/bootstrap.py
+++ b/lib/bootstrap.py
@@ -264,7 +264,7 @@ def InitCluster(cluster_name, mac_prefix, def_bridge,
 
   # start the master ip
   # TODO: Review rpc call from bootstrap
-  rpc.RpcRunner.call_node_start_master(hostname.name, True)
+  rpc.RpcRunner.call_node_start_master(hostname.name, True, False)
 
 
 def InitConfig(version, cluster_config, master_node_config,
@@ -436,7 +436,7 @@ def MasterFailover():
   # cluster info
   cfg.Update(cluster_info)
 
-  result = rpc.RpcRunner.call_node_start_master(new_master, True)
+  result = rpc.RpcRunner.call_node_start_master(new_master, True, False)
   if result.failed or not result.data:
     logging.error("Could not start the master role on the new master"
                   " %s, please check", new_master)
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index cb3bb31..fdb77a6 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -1403,7 +1403,7 @@ class LURenameCluster(LogicalUnit):
                         constants.SSH_KNOWN_HOSTS_FILE, to_node)
 
     finally:
-      result = self.rpc.call_node_start_master(master, False)
+      result = self.rpc.call_node_start_master(master, False, False)
       if result.failed or not result.data:
         self.LogWarning("Could not re-enable the master role on"
                         " the master, please restart manually.")
diff --git a/lib/rpc.py b/lib/rpc.py
index b50c3d1..1ce44ac 100644
--- a/lib/rpc.py
+++ b/lib/rpc.py
@@ -682,14 +682,14 @@ class RpcRunner(object):
                                [checkdict, cluster_name])
 
   @classmethod
-  def call_node_start_master(cls, node, start_daemons):
+  def call_node_start_master(cls, node, start_daemons, no_voting):
     """Tells a node to activate itself as a master.
 
     This is a single-node call.
 
     """
     return cls._StaticSingleNodeCall(node, "node_start_master",
-                                     [start_daemons])
+                                     [start_daemons, no_voting])
 
   @classmethod
   def call_node_stop_master(cls, node, stop_daemons):
-- 
1.5.6.5

Reply via email to