Commit b02c6bdf authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

opcodes: Remove dependency on query module



There's no need to verify the field definitions on every query. They are
static for all intents and purposes anyway and verified at module load
time.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent d859a2cf
......@@ -40,7 +40,6 @@ from ganeti import constants
from ganeti import errors
from ganeti import ht
from ganeti import objects
from ganeti import query
# Common opcode attributes
......@@ -255,13 +254,13 @@ def _GenerateObjectTypeCheck(obj, fields_types):
return ht.TStrictDict(True, True, fields_types)
_TObjFdefs = \
_GenerateObjectTypeCheck(objects.QueryFieldDefinition, {
"name": ht.TRegex(query.FIELD_NAME_RE),
"title": ht.TRegex(query.TITLE_RE),
"kind": ht.TElemOf(constants.QFT_ALL),
"doc": ht.TRegex(query.DOC_RE),
})
_TQueryFieldDef = \
_GenerateObjectTypeCheck(objects.QueryFieldDefinition, {
"name": ht.TNonEmptyString,
"title": ht.TNonEmptyString,
"kind": ht.TElemOf(constants.QFT_ALL),
"doc": ht.TNonEmptyString,
})
def RequireFileStorage():
......@@ -920,10 +919,10 @@ class OpQuery(OpCode):
"Query filter"),
]
OP_RESULT = \
_GenerateObjectTypeCheck(objects.QueryResponse, {
"fields": ht.TListOf(_TObjFdefs),
"data": _TQueryResult,
})
_GenerateObjectTypeCheck(objects.QueryResponse, {
"fields": ht.TListOf(_TQueryFieldDef),
"data": _TQueryResult,
})
class OpQueryFields(OpCode):
......@@ -940,9 +939,9 @@ class OpQueryFields(OpCode):
"Requested fields; if not given, all are returned"),
]
OP_RESULT = \
_GenerateObjectTypeCheck(objects.QueryFieldsResponse, {
"fields": ht.TListOf(_TObjFdefs),
})
_GenerateObjectTypeCheck(objects.QueryFieldsResponse, {
"fields": ht.TListOf(_TQueryFieldDef),
})
class OpOobCommand(OpCode):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment