Explicitly pass params to activate_master_ip
authorAndrea Spadaccini <spadaccio@google.com>
Thu, 27 Oct 2011 16:08:34 +0000 (17:08 +0100)
committerAndrea Spadaccini <spadaccio@google.com>
Wed, 2 Nov 2011 13:03:00 +0000 (13:03 +0000)
To remove the usage of ssconf in the backend, the master needs to push
the parameters of activate_master_ip to the backend.

This patch changes the entire call path of activate_master_ip to use the
new interface.

Signed-off-by: Andrea Spadaccini <spadaccio@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/backend.py
lib/cmdlib.py
lib/rpc_defs.py
lib/server/masterd.py
lib/server/noded.py

index 6d218e3..1184a56 100644 (file)
@@ -298,9 +298,14 @@ def _BuildMasterIpHookEnv():
 
 @RunLocalHooks(constants.FAKE_OP_MASTER_TURNUP, "master-ip-turnup",
                _BuildMasterIpHookEnv)
-def ActivateMasterIp():
+def ActivateMasterIp(master_ip, master_netmask, master_netdev, family):
   """Activate the IP address of the master daemon.
 
+  @param master_ip: the master IP
+  @param master_netmask: the master IP netmask
+  @param master_netdev: the master network device
+  @param family: the IP family
+
   """
   # GetMasterInfo will raise an exception if not able to return data
   master_netdev, master_ip, _, family, master_netmask = GetMasterInfo()
index 6442937..55ff635 100644 (file)
@@ -3323,17 +3323,17 @@ class LUClusterRename(LogicalUnit):
 
     """
     clustername = self.op.name
-    ip = self.ip
+    new_ip = self.ip
 
     # shutdown the master IP
-    master = self.cfg.GetMasterNode()
+    (master, _, dev, netmask, family) = self.cfg.GetMasterNetworkParameters()
     result = self.rpc.call_node_deactivate_master_ip(master)
     result.Raise("Could not disable the master role")
 
     try:
       cluster = self.cfg.GetClusterInfo()
       cluster.cluster_name = clustername
-      cluster.master_ip = ip
+      cluster.master_ip = new_ip
       self.cfg.Update(cluster, feedback_fn)
 
       # update the known hosts file
@@ -3345,7 +3345,8 @@ class LUClusterRename(LogicalUnit):
         pass
       _UploadHelper(self, node_list, constants.SSH_KNOWN_HOSTS_FILE)
     finally:
-      result = self.rpc.call_node_activate_master_ip(master)
+      result = self.rpc.call_node_activate_master_ip(master, new_ip, netmask,
+                                                     dev, family)
       msg = result.fail_msg
       if msg:
         self.LogWarning("Could not re-enable the master role on"
@@ -3723,9 +3724,11 @@ class LUClusterSetParams(LogicalUnit):
     self.cfg.Update(self.cluster, feedback_fn)
 
     if self.op.master_netdev:
+      (master, ip, dev, netmask, family) = self.cfg.GetMasterNetworkParameters()
       feedback_fn("Starting the master ip on the new master netdev (%s)" %
                   self.op.master_netdev)
-      result = self.rpc.call_node_activate_master_ip(master)
+      result = self.rpc.call_node_activate_master_ip(master, ip, netmask, dev,
+                                                     family)
       if result.fail_msg:
         self.LogWarning("Could not re-enable the master ip on"
                         " the master, please restart manually: %s",
@@ -3887,8 +3890,8 @@ class LUClusterActivateMasterIp(NoHooksLU):
     """Activate the master IP.
 
     """
-    master = self.cfg.GetMasterNode()
-    self.rpc.call_node_activate_master_ip(master)
+    (master, ip, dev, netmask, family) = self.cfg.GetMasterNetworkParameters()
+    self.rpc.call_node_activate_master_ip(master, ip, netmask, dev, family)
 
 
 class LUClusterDeactivateMasterIp(NoHooksLU):
index 3615b5a..d0bd67f 100644 (file)
@@ -398,8 +398,13 @@ CALLS = {
     ("node_start_master_daemons", SINGLE, TMO_FAST, [
       ("no_voting", None, None),
       ], None, "Starts master daemons on a node"),
-    ("node_activate_master_ip", SINGLE, TMO_FAST, [], None,
-     "Activates master IP on a node"),
+    ("node_activate_master_ip", SINGLE, TMO_FAST, [
+      ("master_ip", None, "The master IP"),
+      ("master_netmask", None, "The master IP netmask"),
+      ("master_netdev", None, "The master network device"),
+      ("ip_family", None, "The cluster IP family"),
+      ], None,
+      "Activates master IP on a node"),
     ("node_stop_master", SINGLE, TMO_FAST, [], None,
      "Deactivates master IP and stops master daemons on a node"),
     ("node_deactivate_master_ip", SINGLE, TMO_FAST, [], None,
index 198a899..2948bb0 100644 (file)
@@ -533,8 +533,11 @@ def CheckAgreement():
 @rpc.RunWithRPC
 def ActivateMasterIP():
   # activate ip
-  master_node = ssconf.SimpleStore().GetMasterNode()
-  result = rpc.BootstrapRunner().call_node_activate_master_ip(master_node)
+  cfg = config.ConfigWriter()
+  (master, ip, dev, netmask, family) = cfg.GetMasterNetworkParameters()
+  runner = rpc.BootstrapRunner()
+  result = runner.call_node_activate_master_ip(master, ip, netmask, dev, family)
+
   msg = result.fail_msg
   if msg:
     logging.error("Can't activate master IP address: %s", msg)
index 2f951c7..06dfee0 100644 (file)
@@ -697,7 +697,7 @@ class NodeHttpServer(http.server.HttpServer):
     """Activate the master IP on this node.
 
     """
-    return backend.ActivateMasterIp()
+    return backend.ActivateMasterIp(params[0], params[1], params[2], params[3])
 
   @staticmethod
   def perspective_node_deactivate_master_ip(params):