netunicorn.base.task.TaskDispatcher¶
- class TaskDispatcher(name=None)[source]¶
Bases:
ABC
This class is a wrapper for several tasks that are designed to implement the same functionality but depend on node attributes. Most often you either want to use a specific implementation for a specific architecture (e.g., different Tasks for Windows and Linux), or instantiate a task with some specific parameters for a specific node (e.g., node-specific IP address).You should implement your own TaskDispatcher class and override the dispatch method.You also should provide and use any variables (state) that run method would use in the constructor of this class and pass them to the constructor of the task implementation.Dispatching is done by calling the dispatch method that you should implement.- Parameters:
name (
Optional
[str
], default:None
) – Name of the task. If not provided, a random UUID will be used.
Attributes
Name of the task.
Methods
- abstract dispatch(node)[source]¶
- This method takes a node and should return and instance of the task that is designed to be executed on this node.The instance could depend on the node information (such as architecture, platform, properties, etc).Do not forget to pass all arguments and variables to the constructor of the task implementation.