Revision 620a9c62

b/tools/cluster-merge
45 45
_GROUPS_MERGE = "merge"
46 46
_GROUPS_RENAME = "rename"
47 47
_CLUSTERMERGE_ECID = "clustermerge-ecid"
48
_RESTART_ALL = "all"
49
_RESTART_UP = "up"
50
_RESTART_NONE = "none"
51
_RESTART_CHOICES = (_RESTART_ALL, _RESTART_UP, _RESTART_NONE)
52

  
48 53

  
49 54
PAUSE_PERIOD_OPT = cli.cli_option("-p", "--watcher-pause-period", default=1800,
50 55
                                  action="store", type="int",
......
57 62
                            help=("How to handle groups that have the"
58 63
                                  " same name (One of: %s/%s)" %
59 64
                                  (_GROUPS_MERGE, _GROUPS_RENAME)))
65
RESTART_OPT = cli.cli_option("--restart", default=_RESTART_ALL,
66
                             metavar="STRATEGY",
67
                             choices=_RESTART_CHOICES,
68
                             dest="restart",
69
                             help=("How to handle restarting instances"
70
                                   " same name (One of: %s/%s/%s)" %
71
                                   _RESTART_CHOICES))
60 72

  
61 73

  
62 74
def Flatten(unflattened_list):
......
101 113
  """Handling the merge.
102 114

  
103 115
  """
104
  def __init__(self, clusters, pause_period, groups):
116
  def __init__(self, clusters, pause_period, groups, restart):
105 117
    """Initialize object with sane defaults and infos required.
106 118

  
107 119
    @param clusters: The list of clusters to merge in
108 120
    @param pause_period: The time watcher shall be disabled for
109 121
    @param groups: How to handle group conflicts
122
    @param restart: How to handle instance restart
110 123

  
111 124
    """
112 125
    self.merger_data = []
......
116 129
    (self.cluster_name, ) = cli.GetClient().QueryConfigValues(["cluster_name"])
117 130
    self.ssh_runner = ssh.SshRunner(self.cluster_name)
118 131
    self.groups = groups
132
    self.restart = restart
133
    if self.restart == _RESTART_UP:
134
      raise NotImplementedError
135

  
119 136

  
120 137
  def Setup(self):
121 138
    """Sets up our end so we can do the merger.
......
630 647
      self._KillMasterDaemon()
631 648
      self._StartMasterDaemon()
632 649

  
633
      logging.info("Starting instances again")
634
      self._StartupAllInstances()
650
      if self.restart == _RESTART_ALL:
651
        logging.info("Starting instances again")
652
        self._StartupAllInstances()
653
      else:
654
        logging.info("Not starting instances again")
635 655
      logging.info("Post cluster verification")
636 656
      self._VerifyCluster()
637 657
    except errors.GenericError, e:
......
692 712
  parser = optparse.OptionParser(usage=("%%prog [--debug|--verbose]"
693 713
                                        " [--watcher-pause-period SECONDS]"
694 714
                                        " [--groups [%s|%s]]"
715
                                        " [--restart [%s|%s|%s]]"
695 716
                                        " <cluster> [<cluster...>]" %
696
                                        (_GROUPS_MERGE, _GROUPS_RENAME)),
717
                                        (_GROUPS_MERGE, _GROUPS_RENAME,
718
                                         _RESTART_ALL, _RESTART_UP,
719
                                         _RESTART_NONE)),
697 720
                                        prog=program)
698 721
  parser.add_option(cli.DEBUG_OPT)
699 722
  parser.add_option(cli.VERBOSE_OPT)
700 723
  parser.add_option(PAUSE_PERIOD_OPT)
701 724
  parser.add_option(GROUPS_OPT)
725
  parser.add_option(RESTART_OPT)
702 726

  
703 727
  (options, args) = parser.parse_args()
704 728

  
......
708 732
    parser.error("No clusters specified")
709 733

  
710 734
  cluster_merger = Merger(utils.UniqueSequence(args), options.pause_period,
711
                          options.groups)
735
                          options.groups, options.restart)
712 736
  try:
713 737
    try:
714 738
      cluster_merger.Setup()

Also available in: Unified diff