Revision a3fad332

b/tools/cluster-merge
40 40
from ganeti import errors
41 41
from ganeti import ssh
42 42
from ganeti import utils
43
from ganeti import netutils
44 43

  
45 44

  
46 45
_GROUPS_MERGE = "merge"
......
111 110

  
112 111
  """
113 112
  def __init__(self, cluster, key_path, nodes, instances, master_node,
114
               master_ip, config_path=None):
113
               config_path=None):
115 114
    """Initialize the container.
116 115

  
117 116
    @param cluster: The name of the cluster
......
119 118
    @param nodes: List of online nodes in the merging cluster
120 119
    @param instances: List of instances running on merging cluster
121 120
    @param master_node: Name of the master node
122
    @param master_ip: Cluster IP
123 121
    @param config_path: Path to the merging cluster config
124 122

  
125 123
    """
......
128 126
    self.nodes = nodes
129 127
    self.instances = instances
130 128
    self.master_node = master_node
131
    self.master_ip = master_ip
132 129
    self.config_path = config_path
133 130

  
134 131

  
......
221 218
                                 (cluster, result.fail_reason, result.output))
222 219
      master_node = result.stdout.strip()
223 220

  
224
      path = utils.PathJoin(constants.DATA_DIR, "ssconf_%s" %
225
                            constants.SS_MASTER_IP)
226
      result = self._RunCmd(cluster, "cat %s" % path, private_key=key_path)
227
      if result.failed:
228
        raise errors.RemoteError("Unable to retrieve the master IP from"
229
                                 " %s. Fail reason: %s; output: %s" %
230
                                 (cluster, result.fail_reason, result.output))
231
      master_ip = result.stdout.strip()
232

  
233 221
      self.merger_data.append(MergerData(cluster, key_path, nodes, instances,
234
                                         master_node, master_ip))
222
                                         master_node))
235 223

  
236 224
  def _PrepareAuthorizedKeys(self):
237 225
    """Prepare the authorized_keys on every merging node.
......
319 307

  
320 308
    """
321 309
    for data in self.merger_data:
322
      master_ip_family = netutils.IPAddress.GetAddressFamily(data.master_ip)
323
      master_ip_len = netutils.IP4Address.iplen
324
      if master_ip_family == netutils.IP6Address.family:
325
        master_ip_len = netutils.IP6Address.iplen
326
      # Not using constants.IP_COMMAND_PATH because the command might run on a
327
      # machine in which the ip path is different, so it's better to rely on
328
      # $PATH.
329
      cmd = "ip address del %s/%s dev $(cat %s)" % (
330
             data.master_ip,
331
             master_ip_len,
332
             utils.PathJoin(constants.DATA_DIR, "ssconf_%s" %
333
                            constants.SS_MASTER_NETDEV))
334
      result = self._RunCmd(data.master_node, cmd, max_attempts=3)
310
      result = self._RunCmd(data.master_node,
311
                            "gnt-cluster deactivate-master-ip")
312

  
335 313
      if result.failed:
336 314
        raise errors.RemoteError("Unable to remove master IP on %s."
337 315
                                 " Fail reason: %s; output: %s" %
......
739 717
                                  " mergees")
740 718
      logging.info("Disable watcher")
741 719
      self._DisableWatcher()
742
      logging.info("Stop daemons on merging nodes")
743
      self._StopDaemons()
744 720
      logging.info("Merging config")
745 721
      self._FetchRemoteConfig()
746 722
      logging.info("Removing master IPs on mergee master nodes")
747 723
      self._RemoveMasterIps()
724
      logging.info("Stop daemons on merging nodes")
725
      self._StopDaemons()
748 726

  
749 727
      logging.info("Stopping master daemon")
750 728
      self._KillMasterDaemon()

Also available in: Unified diff