From 8f44674f5d624ff3844eeb611ea5cf89723b0e2d Mon Sep 17 00:00:00 2001
From: Stephen Shirley <diamond@google.com>
Date: Tue, 1 Feb 2011 13:07:31 +0100
Subject: [PATCH] Merge node groups from other cluster
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stephen Shirley <diamond@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 tools/cluster-merge | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tools/cluster-merge b/tools/cluster-merge
index 5b6d0b650..412280bc2 100755
--- a/tools/cluster-merge
+++ b/tools/cluster-merge
@@ -47,6 +47,7 @@ PAUSE_PERIOD_OPT = cli.cli_option("-p", "--watcher-pause-period", default=1800,
                                   dest="pause_period",
                                   help=("Amount of time in seconds watcher"
                                         " should be suspended from running"))
+_CLUSTERMERGE_ECID = "clustermerge-ecid"
 
 
 def Flatten(unflattened_list):
@@ -268,6 +269,7 @@ class Merger(object):
 
     for data in self.merger_data:
       other_config = config.ConfigWriter(data.config_path, accept_foreign=True)
+      self._MergeNodeGroups(my_config, other_config)
 
       for node in other_config.GetNodeList():
         node_info = other_config.GetNodeInfo(node)
@@ -295,6 +297,17 @@ class Merger(object):
         my_config.AddInstance(instance_info, str(fake_ec_id))
         fake_ec_id += 1
 
+  # R0201: Method could be a function
+  def _MergeNodeGroups(self, my_config, other_config):
+    """Adds foreign node groups
+
+    ConfigWriter.AddNodeGroup takes care of making sure there are no conflicts.
+    """
+    # pylint: disable-msg=R0201
+    for (_, grp) in other_config.GetAllNodeGroupsInfo():
+      #TODO: handle node group conflicts
+      my_config.AddNodeGroup(grp, _CLUSTERMERGE_ECID)
+
   # R0201: Method could be a function
   def _StartMasterDaemon(self, no_vote=False): # pylint: disable-msg=R0201
     """Starts the local master daemon.
-- 
GitLab