Commit 6fd35c4d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cmdlib: Add tasklet support to logical unit base class

Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarGuido Trotter <>
parent 9a6800e1
......@@ -47,8 +47,8 @@ class LogicalUnit(object):
Subclasses must follow these rules:
- implement ExpandNames
- implement CheckPrereq
- implement Exec
- implement CheckPrereq (except when tasklets are used)
- implement Exec (except when tasklets are used)
- implement BuildHooksEnv
- redefine HPATH and HTYPE
- optionally redefine their run requirements:
......@@ -93,11 +93,15 @@ class LogicalUnit(object):
# support for dry-run
self.dry_run_result = None
# Tasklets
self.tasklets = []
for attr_name in self._OP_REQP:
attr_val = getattr(op, attr_name, None)
if attr_val is None:
raise errors.OpPrereqError("Required parameter '%s' missing" %
def __GetSSH(self):
......@@ -149,6 +153,10 @@ class LogicalUnit(object):
level you can modify self.share_locks, setting a true value (usually 1) for
that level. By default locks are not shared.
This function can also define a list of tasklets, which then will be
executed in order instead of the usual LU-level CheckPrereq and Exec
functions, if those are not defined by the LU.
# Acquire all nodes and one instance
......@@ -205,6 +213,10 @@ class LogicalUnit(object):
their canonical form if it hasn't been done by ExpandNames before.
if self.tasklets:
for tl in self.tasklets:
raise NotImplementedError
def Exec(self, feedback_fn):
......@@ -215,6 +227,10 @@ class LogicalUnit(object):
code, or expected.
if self.tasklets:
for tl in self.tasklets:
raise NotImplementedError
def BuildHooksEnv(self):
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