Tasks¶
These handle all the remote operations that happen. Such as building a new cluster, or run a scheduled backup. We are using celery as our worker daemon, giving us a powerful system to schedule or chain tasks together.
Execution Tasks¶
We can use the perform task to run any command on the remote systems.
- dtrove.tasks.perform(instance_id, name, *cmds)¶
Execute a remote task
Parameters: - instance_id (int) – ID of the instance to connect to
- name (str) – Identifier of this task
- cmds (str) – The actual commands to run
For example (To ruin someones day):
perform.delay(1, 'destory', 'rm -rf /', 'echo everything gone') Will produce [root@10.0.0.1] run: rm -rf / out: [root@10.0.0.1] run: echo everything gone out: everything gone Disconnecting from 127.0.0.1... done.
Build Tasks¶
These tasks handle creating and managing the servers themselves.
- dtrove.tasks.create_server(instance_id, volume_id=None)¶
Create a nova server instance
Parameters: - instance_id (int) – ID of the instance to build
- volume_id (str) – Optional volume id to attach
- dtrove.tasks.create_volume(instance_id)¶
Create a volume for the instance
Parameters: instance_id (int) – ID of the instance
- dtrove.tasks.attach_volume(instance_id, volume_id)¶
Attach a volume to a nova server instance
Parameters: - instance_id (int) – ID of the instance to build
- volume_id (str) – Optional volume id to attach