Commit 3a969900 authored by Stephen Shirley's avatar Stephen Shirley
Browse files

Add support for merging node groups


Signed-off-by: default avatarStephen Shirley <diamond@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 1a615be0
...@@ -339,13 +339,27 @@ class Merger(object): ...@@ -339,13 +339,27 @@ class Merger(object):
conflict_names) conflict_names)
# User wants to rename conflicts # User wants to rename conflicts
if self.groups == _GROUPS_RENAME: elif self.groups == _GROUPS_RENAME:
for grp in conflicts: for grp in conflicts:
new_name = "%s-%s" % (grp.name, other_config.GetClusterName()) new_name = "%s-%s" % (grp.name, other_config.GetClusterName())
logging.info("Renaming remote node group from %s to %s" logging.info("Renaming remote node group from %s to %s"
" to resolve conflict" % (grp.name, new_name)) " to resolve conflict" % (grp.name, new_name))
grp.name = new_name grp.name = new_name
# User wants to merge conflicting groups
elif self.groups == 'merge':
for other_grp in conflicts:
logging.info("Merging local and remote '%s' groups" % other_grp.name)
for node_name in other_grp.members[:]:
node = other_config.GetNodeInfo(node_name)
other_config._UnlockedRemoveNodeFromGroup(node)
my_grp_uuid = my_config._UnlockedLookupNodeGroup(other_grp.name)
my_config._UnlockedAddNodeToGroup(node, my_grp_uuid)
node.group = my_grp_uuid
# Remove from list of groups to add
other_grps.remove(other_grp)
for grp in other_grps: for grp in other_grps:
#TODO: handle node group conflicts #TODO: handle node group conflicts
my_config.AddNodeGroup(grp, _CLUSTERMERGE_ECID) my_config.AddNodeGroup(grp, _CLUSTERMERGE_ECID)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment