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