Skip to content
Snippets Groups Projects
Commit d21eda27 authored by Guido Trotter's avatar Guido Trotter
Browse files

ConfdProcessor: move verification to __init__


During a query execution we currently verify whether we have that query
supported in our dispatch table. Since it's an error not to have it
anyway, we move this verification to the class creation, erroring out
early if such a problem exists.

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent e16e4824
No related branches found
No related tags found
No related merge requests found
...@@ -57,6 +57,9 @@ class ConfdProcessor(object): ...@@ -57,6 +57,9 @@ class ConfdProcessor(object):
""" """
self.reader = reader self.reader = reader
self.hmac_key = utils.ReadFile(constants.HMAC_CLUSTER_KEY) self.hmac_key = utils.ReadFile(constants.HMAC_CLUSTER_KEY)
assert \
not constants.CONFD_REQS.symmetric_difference(self.DISPATCH_TABLE), \
"DISPATCH_TABLE is unaligned with CONFD_REQS"
def ExecQuery(self, payload_in, ip, port): def ExecQuery(self, payload_in, ip, port):
"""Process a single UDP request from a client. """Process a single UDP request from a client.
...@@ -131,10 +134,6 @@ class ConfdProcessor(object): ...@@ -131,10 +134,6 @@ class ConfdProcessor(object):
msg = "missing requested salt" msg = "missing requested salt"
raise errors.ConfdRequestError(msg) raise errors.ConfdRequestError(msg)
if request.type not in self.DISPATCH_TABLE:
msg = "Valid request %d not in DISPATCH_TABLE" % request.type
raise errors.ProgrammerError(msg)
query_object = self.DISPATCH_TABLE[request.type](self.reader) query_object = self.DISPATCH_TABLE[request.type](self.reader)
status, answer = query_object.Exec(request.query) status, answer = query_object.Exec(request.query)
reply = objects.ConfdReply( reply = objects.ConfdReply(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment