Commit 8646adce authored by Guido Trotter's avatar Guido Trotter
Browse files

Parallelize Tag operations

For now we lock the instance/node for adding/deleting tags from it, but
we could probably in the future do without, with more support from the
config for atomic operations.

Reviewed-by: iustinp
parent c53279cf
......@@ -4845,26 +4845,34 @@ class TagsLU(NoHooksLU):
This is an abstract class which is the parent of all the other tags LUs.
"""
def CheckPrereq(self):
"""Check prerequisites.
"""
if self.op.kind == constants.TAG_CLUSTER:
self.target = self.cfg.GetClusterInfo()
elif self.op.kind == constants.TAG_NODE:
def ExpandNames(self):
self.needed_locks = {}
if self.op.kind == constants.TAG_NODE:
name = self.cfg.ExpandNodeName(self.op.name)
if name is None:
raise errors.OpPrereqError("Invalid node name (%s)" %
(self.op.name,))
self.op.name = name
self.target = self.cfg.GetNodeInfo(name)
self.needed_locks[locking.LEVEL_NODE] = name
elif self.op.kind == constants.TAG_INSTANCE:
name = self.cfg.ExpandInstanceName(self.op.name)
if name is None:
raise errors.OpPrereqError("Invalid instance name (%s)" %
(self.op.name,))
self.op.name = name
self.target = self.cfg.GetInstanceInfo(name)
self.needed_locks[locking.LEVEL_INSTANCE] = name
def CheckPrereq(self):
"""Check prerequisites.
"""
if self.op.kind == constants.TAG_CLUSTER:
self.target = self.cfg.GetClusterInfo()
elif self.op.kind == constants.TAG_NODE:
self.target = self.cfg.GetNodeInfo(self.op.name)
elif self.op.kind == constants.TAG_INSTANCE:
self.target = self.cfg.GetInstanceInfo(self.op.name)
else:
raise errors.OpPrereqError("Wrong tag type requested (%s)" %
str(self.op.kind))
......@@ -4875,6 +4883,7 @@ class LUGetTags(TagsLU):
"""
_OP_REQP = ["kind", "name"]
REQ_BGL = False
def Exec(self, feedback_fn):
"""Returns the tag list.
......@@ -4888,6 +4897,10 @@ class LUSearchTags(NoHooksLU):
"""
_OP_REQP = ["pattern"]
REQ_BGL = False
def ExpandNames(self):
self.needed_locks = {}
def CheckPrereq(self):
"""Check prerequisites.
......@@ -4907,9 +4920,9 @@ class LUSearchTags(NoHooksLU):
"""
cfg = self.cfg
tgts = [("/cluster", cfg.GetClusterInfo())]
ilist = [cfg.GetInstanceInfo(name) for name in cfg.GetInstanceList()]
ilist = cfg.GetAllInstancesInfo().values()
tgts.extend([("/instances/%s" % i.name, i) for i in ilist])
nlist = [cfg.GetNodeInfo(name) for name in cfg.GetNodeList()]
nlist = cfg.GetAllNodesInfo().values()
tgts.extend([("/nodes/%s" % n.name, n) for n in nlist])
results = []
for path, target in tgts:
......@@ -4924,6 +4937,7 @@ class LUAddTags(TagsLU):
"""
_OP_REQP = ["kind", "name", "tags"]
REQ_BGL = False
def CheckPrereq(self):
"""Check prerequisites.
......@@ -4957,6 +4971,7 @@ class LUDelTags(TagsLU):
"""
_OP_REQP = ["kind", "name", "tags"]
REQ_BGL = False
def CheckPrereq(self):
"""Check prerequisites.
......
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