projects
/
ganeti-local
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
http.client: Remove HTTP client pool code
[ganeti-local]
/
lib
/
confd
/
querylib.py
diff --git
a/lib/confd/querylib.py
b/lib/confd/querylib.py
index
f757760
..
e231a14
100644
(file)
--- a/
lib/confd/querylib.py
+++ b/
lib/confd/querylib.py
@@
-1,7
+1,7
@@
#
#
#
#
-# Copyright (C) 2009, Google Inc.
+# Copyright (C) 2009 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@
-50,7
+50,7
@@
class ConfdQuery(object):
"""
self.reader = reader
"""
self.reader = reader
- def Exec(self, query):
+ def Exec(self, query): # pylint: disable=R0201,W0613
"""Process a single UDP request from a client.
Different queries should override this function, which by defaults returns
"""Process a single UDP request from a client.
Different queries should override this function, which by defaults returns
@@
-94,6
+94,9
@@
class ClusterMasterQuery(ConfdQuery):
It accepts no arguments, and returns the current cluster master.
"""
It accepts no arguments, and returns the current cluster master.
"""
+ def _GetMasterNode(self):
+ return self.reader.GetMasterNode()
+
def Exec(self, query):
"""ClusterMasterQuery main execution
def Exec(self, query):
"""ClusterMasterQuery main execution
@@
-109,9
+112,11
@@
class ClusterMasterQuery(ConfdQuery):
answer = []
for field in req_fields:
if field == constants.CONFD_REQFIELD_NAME:
answer = []
for field in req_fields:
if field == constants.CONFD_REQFIELD_NAME:
- answer.append(self.reader.GetMasterNode())
+ answer.append(self._GetMasterNode())
elif field == constants.CONFD_REQFIELD_IP:
answer.append(self.reader.GetMasterIP())
elif field == constants.CONFD_REQFIELD_IP:
answer.append(self.reader.GetMasterIP())
+ elif field == constants.CONFD_REQFIELD_MNODE_PIP:
+ answer.append(self.reader.GetNodePrimaryIp(self._GetMasterNode()))
else:
logging.debug("missing FIELDS in query dict")
return QUERY_ARGUMENT_ERROR
else:
logging.debug("missing FIELDS in query dict")
return QUERY_ARGUMENT_ERROR
@@
-182,7
+187,6
@@
class InstanceIpToNodePrimaryIpQuery(ConfdQuery):
instances_list = query[constants.CONFD_REQQ_IPLIST]
mode = constants.CONFD_REQQ_IPLIST
else:
instances_list = query[constants.CONFD_REQQ_IPLIST]
mode = constants.CONFD_REQQ_IPLIST
else:
- status = constants.CONFD_REPL_STATUS_ERROR
logging.debug("missing IP or IPLIST in query dict")
return QUERY_ARGUMENT_ERROR
logging.debug("missing IP or IPLIST in query dict")
return QUERY_ARGUMENT_ERROR
@@
-190,46
+194,42
@@
class InstanceIpToNodePrimaryIpQuery(ConfdQuery):
network_link = query[constants.CONFD_REQQ_LINK]
else:
network_link = None # default will be used
network_link = query[constants.CONFD_REQQ_LINK]
else:
network_link = None # default will be used
- elif isinstance(query, basestring):
- # 2.1 beta1 and beta2 mode, to be deprecated for 2.2
- instances_list = [query]
- network_link = None
- mode = constants.CONFD_REQQ_IP
else:
else:
- logging.debug("Invalid query argument type for: %s" % query)
+ logging.debug("Invalid query argument type for: %s", query)
return QUERY_ARGUMENT_ERROR
pnodes_list = []
for instance_ip in instances_list:
if not isinstance(instance_ip, basestring):
return QUERY_ARGUMENT_ERROR
pnodes_list = []
for instance_ip in instances_list:
if not isinstance(instance_ip, basestring):
- logging.debug("Invalid IP type for: %s" % instance_ip)
+ logging.debug("Invalid IP type for: %s", instance_ip)
return QUERY_ARGUMENT_ERROR
instance = self.reader.GetInstanceByLinkIp(instance_ip, network_link)
if not instance:
return QUERY_ARGUMENT_ERROR
instance = self.reader.GetInstanceByLinkIp(instance_ip, network_link)
if not instance:
- logging.debug("Unknown instance IP: %s" % instance_ip)
+ logging.debug("Unknown instance IP: %s", instance_ip)
pnodes_list.append(QUERY_UNKNOWN_ENTRY_ERROR)
continue
pnode = self.reader.GetInstancePrimaryNode(instance)
if not pnode:
logging.error("Instance '%s' doesn't have an associated primary"
pnodes_list.append(QUERY_UNKNOWN_ENTRY_ERROR)
continue
pnode = self.reader.GetInstancePrimaryNode(instance)
if not pnode:
logging.error("Instance '%s' doesn't have an associated primary"
- " node" % instance)
+ " node", instance)
pnodes_list.append(QUERY_INTERNAL_ERROR)
continue
pnode_primary_ip = self.reader.GetNodePrimaryIp(pnode)
if not pnode_primary_ip:
logging.error("Primary node '%s' doesn't have an associated"
pnodes_list.append(QUERY_INTERNAL_ERROR)
continue
pnode_primary_ip = self.reader.GetNodePrimaryIp(pnode)
if not pnode_primary_ip:
logging.error("Primary node '%s' doesn't have an associated"
- " primary IP" % pnode)
+ " primary IP", pnode)
pnodes_list.append(QUERY_INTERNAL_ERROR)
continue
pnodes_list.append((constants.CONFD_REPL_STATUS_OK, pnode_primary_ip))
pnodes_list.append(QUERY_INTERNAL_ERROR)
continue
pnodes_list.append((constants.CONFD_REPL_STATUS_OK, pnode_primary_ip))
- # If a single ip was requested, return a single answer, otherwise the whole
- # list, with a success status (since each entry has its own success/failure)
+ # If a single ip was requested, return a single answer, otherwise
+ # the whole list, with a success status (since each entry has its
+ # own success/failure)
if mode == constants.CONFD_REQQ_IP:
return pnodes_list[0]
if mode == constants.CONFD_REQQ_IP:
return pnodes_list[0]