Commit 9a6800e1 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cmdlib: Add tasklet base class

Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent c0446a46
......@@ -339,6 +339,45 @@ class NoHooksLU(LogicalUnit):
HTYPE = None
class Tasklet:
"""Tasklet base class.
Tasklets are subcomponents for LUs. LUs can consist entirely of tasklets or
they can mix legacy code with tasklets. Locking needs to be done in the LU,
tasklets know nothing about locks.
Subclasses must follow these rules:
- Implement CheckPrereq
- Implement Exec
def CheckPrereq(self):
"""Check prerequisites for this tasklets.
This method should check whether the prerequisites for the execution of
this tasklet are fulfilled. It can do internode communication, but it
should be idempotent - no cluster or system changes are allowed.
The method should raise errors.OpPrereqError in case something is not
fulfilled. Its return value is ignored.
This method should also update all parameters to their canonical form if it
hasn't been done before.
raise NotImplementedError
def Exec(self, feedback_fn):
"""Execute the tasklet.
This method should implement the actual work. It should raise
errors.OpExecError for failures that are somewhat dealt with in code, or
raise NotImplementedError
def _GetWantedNodes(lu, nodes):
"""Returns list of checked and expanded node names.
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