Revision 6d7e1f20

b/lib/cmdlib.py
686 686
               (mc_now, mc_max))
687 687

  
688 688

  
689
def _DecideSelfPromotion(lu, exceptions=None):
690
  """Decide whether I should promote myself as a master candidate.
691

  
692
  """
693
  cp_size = lu.cfg.GetClusterInfo().candidate_pool_size
694
  mc_now, mc_should, _ = lu.cfg.GetMasterCandidateStats(exceptions)
695
  # the new node will increase mc_max with one, so:
696
  mc_should = min(mc_should + 1, cp_size)
697
  return mc_now < mc_should
698

  
699

  
689 700
def _CheckNicsBridgesExist(lu, target_nics, target_node,
690 701
                               profile=constants.PP_DEFAULT):
691 702
  """Check that the brigdes needed by a list of nics exist.
......
2793 2804
        raise errors.OpPrereqError("Node secondary ip not reachable by TCP"
2794 2805
                                   " based ping to noded port")
2795 2806

  
2796
    cp_size = self.cfg.GetClusterInfo().candidate_pool_size
2797 2807
    if self.op.readd:
2798 2808
      exceptions = [node]
2799 2809
    else:
2800 2810
      exceptions = []
2801
    mc_now, mc_max, _ = self.cfg.GetMasterCandidateStats(exceptions)
2802
    # the new node will increase mc_max with one, so:
2803
    mc_max = min(mc_max + 1, cp_size)
2804
    self.master_candidate = mc_now < mc_max
2811

  
2812
    self.master_candidate = _DecideSelfPromotion(self, exceptions=exceptions)
2805 2813

  
2806 2814
    if self.op.readd:
2807 2815
      self.new_node = self.cfg.GetNodeInfo(node)

Also available in: Unified diff