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

Allow locking to be used via OpQuery

The original design for query2 specifically excluded locking, but now
it's turned out that it would be a good thing to have in watcher. This
patch adds a new parameter to OpQuery and enables its use in LUQuery. A
missing function is added to LUGroupQuery, a comment clarified in
_NodeQuery and all locks declared as shared acquires in the same LU.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarRené Nussbaumer <>
parent 7859261b
......@@ -4338,7 +4338,7 @@ class _NodeQuery(_QueryBase):
def ExpandNames(self, lu):
lu.needed_locks = {}
lu.share_locks[locking.LEVEL_NODE] = 1
lu.share_locks = _ShareAll()
if self.names:
self.wanted = _GetWantedNodes(lu, self.names)
......@@ -4349,7 +4349,7 @@ class _NodeQuery(_QueryBase):
query.NQ_LIVE in self.requested_data)
if self.do_locking:
# if we don't request only static fields, we need to lock the nodes
# If any non-static field is requested we need to lock the nodes
lu.needed_locks[locking.LEVEL_NODE] = self.wanted
def DeclareLocks(self, lu, level):
......@@ -4721,7 +4721,7 @@ class LUQuery(NoHooksLU):
def CheckArguments(self):
qcls = _GetQueryImplementation(self.op.what)
self.impl = qcls(self.op.filter, self.op.fields, False)
self.impl = qcls(self.op.filter, self.op.fields, self.op.use_locking)
def ExpandNames(self):
......@@ -12057,6 +12057,9 @@ class LUGroupQuery(NoHooksLU):
def ExpandNames(self):
def DeclareLocks(self, level):, level)
def Exec(self, feedback_fn):
......@@ -795,6 +795,7 @@ class OpQuery(OpCode):
OP_DSC_FIELD = "what"
("fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
"Requested fields"),
("filter", None, ht.TOr(ht.TNone, ht.TListOf),
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