Revision 9a6800e1
b/lib/cmdlib.py | ||
---|---|---|
339 | 339 |
HTYPE = None |
340 | 340 |
|
341 | 341 |
|
342 |
class Tasklet: |
|
343 |
"""Tasklet base class. |
|
344 |
|
|
345 |
Tasklets are subcomponents for LUs. LUs can consist entirely of tasklets or |
|
346 |
they can mix legacy code with tasklets. Locking needs to be done in the LU, |
|
347 |
tasklets know nothing about locks. |
|
348 |
|
|
349 |
Subclasses must follow these rules: |
|
350 |
- Implement CheckPrereq |
|
351 |
- Implement Exec |
|
352 |
|
|
353 |
""" |
|
354 |
def CheckPrereq(self): |
|
355 |
"""Check prerequisites for this tasklets. |
|
356 |
|
|
357 |
This method should check whether the prerequisites for the execution of |
|
358 |
this tasklet are fulfilled. It can do internode communication, but it |
|
359 |
should be idempotent - no cluster or system changes are allowed. |
|
360 |
|
|
361 |
The method should raise errors.OpPrereqError in case something is not |
|
362 |
fulfilled. Its return value is ignored. |
|
363 |
|
|
364 |
This method should also update all parameters to their canonical form if it |
|
365 |
hasn't been done before. |
|
366 |
|
|
367 |
""" |
|
368 |
raise NotImplementedError |
|
369 |
|
|
370 |
def Exec(self, feedback_fn): |
|
371 |
"""Execute the tasklet. |
|
372 |
|
|
373 |
This method should implement the actual work. It should raise |
|
374 |
errors.OpExecError for failures that are somewhat dealt with in code, or |
|
375 |
expected. |
|
376 |
|
|
377 |
""" |
|
378 |
raise NotImplementedError |
|
379 |
|
|
380 |
|
|
342 | 381 |
def _GetWantedNodes(lu, nodes): |
343 | 382 |
"""Returns list of checked and expanded node names. |
344 | 383 |
|
Also available in: Unified diff