Interdiff:

diff --git a/lib/backend.py b/lib/backend.py
index 56e1f6e..5547a39 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -283,11 +283,8 @@ def JobQueuePurge():
   _CleanDirectory(pathutils.JOB_QUEUE_ARCHIVE_DIR)
 
 
-def GetMasterInfo():
-  """Returns information about master node.
-
-  This is an utility function to compute master information, either
-  for consumption here or from the node daemon.
+def GetMasterNodeName():
+  """Returns the master node name.
 
   @rtype: string
   @return: name of the master node
diff --git a/lib/bootstrap.py b/lib/bootstrap.py
index 6029059..772134e 100644
--- a/lib/bootstrap.py
+++ b/lib/bootstrap.py
@@ -1111,7 +1111,7 @@ def GatherMasterVotes(node_names):
   if not node_names:
     # no nodes left (eventually after removing myself)
     return []
-  results = rpc.BootstrapRunner().call_master_info(node_names)
+  results = rpc.BootstrapRunner().call_master_node_name(node_names)
   if not isinstance(results, dict):
     # this should not happen (unless internal error in rpc)
     logging.critical("Can't complete rpc call, aborting master startup")
diff --git a/lib/rpc_defs.py b/lib/rpc_defs.py
index 73edeb4..6650c43 100644
--- a/lib/rpc_defs.py
+++ b/lib/rpc_defs.py
@@ -609,8 +609,8 @@ CALLS = {
       ("modify_ssh_setup", None, None),
       ], None, None,
      "Requests a node to clean the cluster information it has"),
-    ("master_info", MULTI, None, constants.RPC_TMO_URGENT, [], None, None,
-     "Query master info"),
+    ("master_node_name", MULTI, None, constants.RPC_TMO_URGENT, [], None, None,
+     "Returns the master node name"),
     ]),
   "RpcClientDnsOnly": _Prepare([
     ("version", MULTI, ACCEPT_OFFLINE_NODE, constants.RPC_TMO_URGENT, [], None,
diff --git a/lib/server/noded.py b/lib/server/noded.py
index 682b231..9731925 100644
--- a/lib/server/noded.py
+++ b/lib/server/noded.py
@@ -892,11 +892,11 @@ class NodeRequestHandler(http.server.HttpServerHandler):
     return backend.UploadFile(*(params[0]))
 
   @staticmethod
-  def perspective_master_info(params):
-    """Query master information.
+  def perspective_master_node_name(params):
+    """Returns the master node name.
 
     """
-    return backend.GetMasterInfo()
+    return backend.GetMasterNodeName()
 
   @staticmethod
   def perspective_run_oob(params):


On Wed, Jan 15, 2014 at 02:35:13PM +0100, Guido Trotter wrote:
> On Wed, Jan 15, 2014 at 10:50 AM, Jose A. Lopes <[email protected]> wrote:
> > * RPC 'GetMasterInfo' returns several fields, namely, 'master_netdev',
> >   'master_ip', 'master_netmask', 'master_node', and
> >   'primary_ip_family', of which only the 'master_node' is actually
> >   used.  This patch, removes all the other fields and keeps only the
> >   'master_node' field.
> >
> > * Simplify the the voting algorithm code.
> >
> > Signed-off-by: Jose A. Lopes <[email protected]>
> > ---
> >  lib/backend.py   | 16 ++++------------
> >  lib/bootstrap.py | 27 +++++++++------------------
> >  2 files changed, 13 insertions(+), 30 deletions(-)
> >
> > diff --git a/lib/backend.py b/lib/backend.py
> > index c37e01d..56e1f6e 100644
> > --- a/lib/backend.py
> > +++ b/lib/backend.py
> > @@ -284,28 +284,20 @@ def JobQueuePurge():
> >
> >
> >  def GetMasterInfo():
> > -  """Returns master information.
> > +  """Returns information about master node.
> >
> 
> Please replace this with:
> 
> "Returns the master node name."
> It might even make sense to just change the rpc call name altogether.
> 
> >    This is an utility function to compute master information, either
> >    for consumption here or from the node daemon.
> >
> > -  @rtype: tuple
> > -  @return: master_netdev, master_ip, master_name, primary_ip_family,
> > -    master_netmask
> > +  @rtype: string
> > +  @return: name of the master node
> >    @raise RPCFail: in case of errors
> >
> >    """
> >    try:
> > -    cfg = _GetConfig()
> > -    master_netdev = cfg.GetMasterNetdev()
> > -    master_ip = cfg.GetMasterIP()
> > -    master_netmask = cfg.GetMasterNetmask()
> > -    master_node = cfg.GetMasterNode()
> > -    primary_ip_family = cfg.GetPrimaryIPFamily()
> > +    return _GetConfig().GetMasterNode()
> >    except errors.ConfigurationError, err:
> >      _Fail("Cluster configuration incomplete: %s", err, exc=True)
> > -  return (master_netdev, master_ip, master_node, primary_ip_family,
> > -          master_netmask)
> >
> >
> >  def RunLocalHooks(hook_opcode, hooks_path, env_builder_fn):
> > diff --git a/lib/bootstrap.py b/lib/bootstrap.py
> > index e468283..6029059 100644
> > --- a/lib/bootstrap.py
> > +++ b/lib/bootstrap.py
> > @@ -1119,27 +1119,18 @@ def GatherMasterVotes(node_names):
> >    votes = {}
> >    for node_name in results:
> >      nres = results[node_name]
> > -    data = nres.payload
> >      msg = nres.fail_msg
> > -    fail = False
> > +
> >      if msg:
> >        logging.warning("Error contacting node %s: %s", node_name, msg)
> > -      fail = True
> > -    # for now we accept both length 3, 4 and 5 (data[3] is primary ip 
> > version
> > -    # and data[4] is the master netmask)
> > -    elif not isinstance(data, (tuple, list)) or len(data) < 3:
> > -      logging.warning("Invalid data received from node %s: %s",
> > -                      node_name, data)
> > -      fail = True
> > -    if fail:
> > -      if None not in votes:
> > -        votes[None] = 0
> > -      votes[None] += 1
> > -      continue
> > -    master_node = data[2]
> > -    if master_node not in votes:
> > -      votes[master_node] = 0
> > -    votes[master_node] += 1
> > +      node = None
> > +    else:
> > +      node = nres.payload
> > +
> > +    if node not in votes:
> > +      votes[node] = 1
> > +    else:
> > +      votes[node] += 1
> >
> >    vote_list = [v for v in votes.items()]
> >    # sort first on number of votes then on name, since we want None
> > --
> > 1.8.5.2
> >
> 
> rest LGTM
> 
> Thanks,
> 
> Guido
> 
> 
> 
> 
> --
> Guido Trotter
> Ganeti Engineering
> Google Germany GmbH
> Dienerstr. 12, 80331, München
> 
> Registergericht und -nummer: Hamburg, HRB 86891
> Sitz der Gesellschaft: Hamburg
> Geschäftsführer: Graham Law, Christine Elizabeth Flores
> Steuernummer: 48/725/00206
> Umsatzsteueridentifikationsnummer: DE813741370
> 
> 
> -- 
> Guido Trotter
> Ganeti Engineering
> Google Germany GmbH
> Dienerstr. 12, 80331, München
> 
> Registergericht und -nummer: Hamburg, HRB 86891
> Sitz der Gesellschaft: Hamburg
> Geschäftsführer: Graham Law, Christine Elizabeth Flores
> Steuernummer: 48/725/00206
> Umsatzsteueridentifikationsnummer: DE813741370

-- 
Jose Antonio Lopes
Ganeti Engineering
Google Germany GmbH
Dienerstr. 12, 80331, München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores
Steuernummer: 48/725/00206
Umsatzsteueridentifikationsnummer: DE813741370

Reply via email to