1 """
2 Created on Jun 15, 2013
3
4 @author: Rafael Timmerberg
5 """
6
7
9 """
10 Base class for all built-in Tasks.
11 """
12
14 """
15 sets the type of this task.
16
17 Be aware! this method can only get called once!
18
19 params:
20 taskType: the type of this task
21 """
22 if hasattr(self, "_taskType"):
23 raise Exception("taskType is only allowed to set once!")
24 self.taskType = taskType
25
27 """
28 returns the type set by set_type_task
29 """
30 return self._taskType
31
33 """
34 this is the method tasks usually override.
35 It gets called anytime the task should get executed
36
37 default does nothing
38
39 params:
40 msg: the msg for this task
41 """
42 pass
43
45 """
46 internal method which gets called for any member in a hostgroup.
47 It determines if it has an appropriate type by comparing taskType with get_task_type().
48 Calls execute_task() if the type matches
49
50 params:
51 taskType: the type of the fail which is compared with get_task_type()
52 msg: the error message
53
54 return:
55 True if execute_task() is called succesfully, else False
56 """
57 if self.get_task_type() == taskType:
58 self.execute_task(msg)
59 return True
60 return False
61