One 'too many branches' error.
Signed-off-by: Helga Velroyen <[email protected]>
---
tools/confd-client | 50 ++++++++++++++++++++++++++++++--------------------
1 file changed, 30 insertions(+), 20 deletions(-)
diff --git a/tools/confd-client b/tools/confd-client
index a070088..f2e6ae6 100755
--- a/tools/confd-client
+++ b/tools/confd-client
@@ -133,21 +133,40 @@ class TestClient(object):
self.opts = options
+ def _ProcessNotOk(self, reply, reqtype):
+ Log("Query %s gave non-ok status %s: %s" % (reply.orig_request,
+ reply.server_reply.status,
+ reply.server_reply))
+ if self.is_timing:
+ Err("Aborting timing tests")
+ if reqtype == constants.CONFD_REQ_CLUSTER_MASTER:
+ Err("Cannot continue after master query failure")
+ if reqtype == constants.CONFD_REQ_INSTANCES_IPS_LIST:
+ Err("Cannot continue after instance IP list query failure")
+
+ def _ProcessIpList(self, answer):
+ Log("Instance primary IP query: OK")
+ if not answer:
+ Log("no IPs received", indent=1)
+ else:
+ LogAtMost(answer, 5, indent=1)
+ self.instance_ips = answer
+
+ @staticmethod
+ def _ProcessMapping(answer):
+ Log("Instance IP to node IP query: OK")
+ if not answer:
+ Log("no mapping received", indent=1)
+ else:
+ LogAtMost(answer, 5, indent=1)
+
def ConfdCallback(self, reply):
"""Callback for confd queries"""
if reply.type == confd_client.UPCALL_REPLY:
answer = reply.server_reply.answer
reqtype = reply.orig_request.type
if reply.server_reply.status != constants.CONFD_REPL_STATUS_OK:
- Log("Query %s gave non-ok status %s: %s" % (reply.orig_request,
- reply.server_reply.status,
- reply.server_reply))
- if self.is_timing:
- Err("Aborting timing tests")
- if reqtype == constants.CONFD_REQ_CLUSTER_MASTER:
- Err("Cannot continue after master query failure")
- if reqtype == constants.CONFD_REQ_INSTANCES_IPS_LIST:
- Err("Cannot continue after instance IP list query failure")
+ self._ProcessNotOk(reply, reqtype)
return
if self.is_timing:
return
@@ -170,18 +189,9 @@ class TestClient(object):
Log("Master candidates primary IP query: OK")
LogAtMost(answer, 5, indent=1)
elif reqtype == constants.CONFD_REQ_INSTANCES_IPS_LIST:
- Log("Instance primary IP query: OK")
- if not answer:
- Log("no IPs received", indent=1)
- else:
- LogAtMost(answer, 5, indent=1)
- self.instance_ips = answer
+ self._ProcessIpList(answer)
elif reqtype == constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP:
- Log("Instance IP to node IP query: OK")
- if not answer:
- Log("no mapping received", indent=1)
- else:
- LogAtMost(answer, 5, indent=1)
+ self._ProcessMapping(answer)
else:
Log("Unhandled reply %s, please fix the client", reqtype)
print answer
--
1.9.1.423.g4596e3a