Revision cb8028f3

b/lib/backend.py
283 283
  _CleanDirectory(pathutils.JOB_QUEUE_ARCHIVE_DIR)
284 284

  
285 285

  
286
def GetMasterInfo():
287
  """Returns master information.
286
def GetMasterNodeName():
287
  """Returns the master node name.
288 288

  
289
  This is an utility function to compute master information, either
290
  for consumption here or from the node daemon.
291

  
292
  @rtype: tuple
293
  @return: master_netdev, master_ip, master_name, primary_ip_family,
294
    master_netmask
289
  @rtype: string
290
  @return: name of the master node
295 291
  @raise RPCFail: in case of errors
296 292

  
297 293
  """
298 294
  try:
299
    cfg = _GetConfig()
300
    master_netdev = cfg.GetMasterNetdev()
301
    master_ip = cfg.GetMasterIP()
302
    master_netmask = cfg.GetMasterNetmask()
303
    master_node = cfg.GetMasterNode()
304
    primary_ip_family = cfg.GetPrimaryIPFamily()
295
    return _GetConfig().GetMasterNode()
305 296
  except errors.ConfigurationError, err:
306 297
    _Fail("Cluster configuration incomplete: %s", err, exc=True)
307
  return (master_netdev, master_ip, master_node, primary_ip_family,
308
          master_netmask)
309 298

  
310 299

  
311 300
def RunLocalHooks(hook_opcode, hooks_path, env_builder_fn):
b/lib/bootstrap.py
1111 1111
  if not node_names:
1112 1112
    # no nodes left (eventually after removing myself)
1113 1113
    return []
1114
  results = rpc.BootstrapRunner().call_master_info(node_names)
1114
  results = rpc.BootstrapRunner().call_master_node_name(node_names)
1115 1115
  if not isinstance(results, dict):
1116 1116
    # this should not happen (unless internal error in rpc)
1117 1117
    logging.critical("Can't complete rpc call, aborting master startup")
......
1119 1119
  votes = {}
1120 1120
  for node_name in results:
1121 1121
    nres = results[node_name]
1122
    data = nres.payload
1123 1122
    msg = nres.fail_msg
1124
    fail = False
1123

  
1125 1124
    if msg:
1126 1125
      logging.warning("Error contacting node %s: %s", node_name, msg)
1127
      fail = True
1128
    # for now we accept both length 3, 4 and 5 (data[3] is primary ip version
1129
    # and data[4] is the master netmask)
1130
    elif not isinstance(data, (tuple, list)) or len(data) < 3:
1131
      logging.warning("Invalid data received from node %s: %s",
1132
                      node_name, data)
1133
      fail = True
1134
    if fail:
1135
      if None not in votes:
1136
        votes[None] = 0
1137
      votes[None] += 1
1138
      continue
1139
    master_node = data[2]
1140
    if master_node not in votes:
1141
      votes[master_node] = 0
1142
    votes[master_node] += 1
1126
      node = None
1127
    else:
1128
      node = nres.payload
1129

  
1130
    if node not in votes:
1131
      votes[node] = 1
1132
    else:
1133
      votes[node] += 1
1143 1134

  
1144 1135
  vote_list = [v for v in votes.items()]
1145 1136
  # sort first on number of votes then on name, since we want None
b/lib/rpc_defs.py
609 609
      ("modify_ssh_setup", None, None),
610 610
      ], None, None,
611 611
     "Requests a node to clean the cluster information it has"),
612
    ("master_info", MULTI, None, constants.RPC_TMO_URGENT, [], None, None,
613
     "Query master info"),
612
    ("master_node_name", MULTI, None, constants.RPC_TMO_URGENT, [], None, None,
613
     "Returns the master node name"),
614 614
    ]),
615 615
  "RpcClientDnsOnly": _Prepare([
616 616
    ("version", MULTI, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_URGENT, [], None,
b/lib/server/noded.py
892 892
    return backend.UploadFile(*(params[0]))
893 893

  
894 894
  @staticmethod
895
  def perspective_master_info(params):
896
    """Query master information.
895
  def perspective_master_node_name(params):
896
    """Returns the master node name.
897 897

  
898 898
    """
899
    return backend.GetMasterInfo()
899
    return backend.GetMasterNodeName()
900 900

  
901 901
  @staticmethod
902 902
  def perspective_run_oob(params):

Also available in: Unified diff