-#!/usr/bin/python
+#
#
-# 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
"""
DISPATCH_TABLE = {
- constants.CONFD_REQ_PING: querylib.PingQuery,
- constants.CONFD_REQ_NODE_ROLE_BYNAME: querylib.NodeRoleQuery,
- constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP:
- querylib.InstanceIpToNodePrimaryIpQuery,
- constants.CONFD_REQ_CLUSTER_MASTER: querylib.ClusterMasterQuery,
- }
+ constants.CONFD_REQ_PING: querylib.PingQuery,
+ constants.CONFD_REQ_NODE_ROLE_BYNAME: querylib.NodeRoleQuery,
+ constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP:
+ querylib.InstanceIpToNodePrimaryIpQuery,
+ constants.CONFD_REQ_CLUSTER_MASTER: querylib.ClusterMasterQuery,
+ constants.CONFD_REQ_NODE_PIP_LIST: querylib.NodesPipsQuery,
+ constants.CONFD_REQ_MC_PIP_LIST: querylib.MasterCandidatesPipsQuery,
+ constants.CONFD_REQ_INSTANCES_IPS_LIST: querylib.InstancesIpsQuery,
+ }
def __init__(self):
"""Constructor for ConfdProcessor
"""
self.disabled = True
- self.hmac_key = utils.ReadFile(constants.HMAC_CLUSTER_KEY)
+ self.hmac_key = utils.ReadFile(constants.CONFD_HMAC_KEY)
self.reader = None
assert \
not constants.CONFD_REQS.symmetric_difference(self.DISPATCH_TABLE), \
payload_out = self.PackReply(reply, rsalt)
return payload_out
except errors.ConfdRequestError, err:
- logging.info('Ignoring broken query from %s:%d: %s' % (ip, port, err))
+ logging.info('Ignoring broken query from %s:%d: %s', ip, port, err)
return None
def ExtractRequest(self, payload):
"""
current_time = time.time()
- logging.debug("Extracting request with size: %d" % (len(payload)))
+ logging.debug("Extracting request with size: %d", len(payload))
try:
(message, salt) = serializer.LoadSigned(payload, self.hmac_key)
except errors.SignatureError, err:
@return: tuple of reply and salt to add to the signature
"""
- logging.debug("Processing request: %s" % request)
+ logging.debug("Processing request: %s", request)
if request.protocol != constants.CONFD_PROTOCOL_VERSION:
msg = "wrong protocol version %d" % request.protocol
raise errors.ConfdRequestError(msg)
serial=self.reader.GetConfigSerialNo(),
)
- logging.debug("Sending reply: %s" % reply)
+ logging.debug("Sending reply: %s", reply)
return (reply, rsalt)
"""
return serializer.DumpSigned(reply.ToDict(), self.hmac_key, rsalt)
-