ClearGLASS allows you to store and run scheduled tasks (cronjobs) that can run your scripts and schedule actions on your servers.
There are three types of tasks: interval (running periodically), crontab (with a format that resembles the unix crontab file) and one_off (runs only once).
A scheduled task can also have an activation time, an expiration time and can be disabled and kept for future use. ClearGLASS provides a REST API for task management. All scheduled task results can be accessed through the ClearGLASS logs.
Adding a task requires a POST call to /api/v1/schedules. For example, the following task will try to start the machine every 2 minutes:
user@user:/tmp$ curl -H "Authorization: 51fb1fc5554d0861d80843dd2612234365feb8211e9d191a70fde56a340bf742" -X POST -d '{'name':'test','action':'start', 'machines_per_cloud':[["b48a696e84554275a52fbe6278f6df56","i-781daaf3"]],'enabled':true,'expires':'2016-11-10 20:20:00','cronjob_type':'interval','cronjob_entry':JSON.stringify({"every" : 2,"period" : "minutes"})}' https://ClearGLASS/api/v1/schedules
while this example, will run a script every 2 hours:
user@user:/tmp$ curl -H "Authorization: 51fb1fc5554d0861d80843dd2612234365feb8211e9d191a70fde56a340bf742" -X POST -d '{'name':'test','script_id':'875cabc81fa1438b98ef25f099bbdf09', 'machines_per_cloud':[["b48a696e84554275a52fbe6278f6df56","i-781daaf3"]],'enabled':true,'expires':'2016-11-10 20:20:00','cronjob_type':'interval','cronjob_entry':JSON.stringify({"every" : 2,"period" : "hours"})}' https://ClearGLASS/api/v1/schedules
Things you can/should provide while creating a new task:
Available periods: days, hours, minutes, seconds, microseconds
example of crontabs
{"minute" : "30", "hour" : "2", "day_of_week" : "*", "day_of_month" : "*", "month_of_year" : "*"} other crontab examples: http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#crontab-schedules * one_off: (ex. 'cronjob_entry':'2016-2-28 16:20:00' )
To get a list of all your tasks, you need to send a GET call to / api /v1/schedules. E.g.:
user@user:/tmp$ curl -X GET -H "Authorization: 51fb1fc5554d0861d80843dd2612234365feb8211e9d191a70fde56a340bf742" https://ClearGLASS/api/v1/schedules
To get a specific task, you need to send a GET call to / api /v1/schedules/taskId. E.g.:
user@user:/tmp$ curl -X GET -H "Authorization: 51fb1fc5554d0861d80843dd2612234365feb8211e9d191a70fde56a340bf742" https://ClearGLASS/api/v1/schedules/3bb46efc882c4b44b21826e5e98f7c28
To edit the configuration of a task, you need to send a PUT call to / api /v1/schedules/taskId. E.g.:
user@user:/tmp$ curl -H "Authorization: 51fb1fc5554d0861d80843dd2612234365feb8211e9d191a70fde56a340bf742" -X POST -d '{'name':'test','script_id':'875cabc81fa1438b98ef25f099bbdf09', 'machines_per_cloud':[["b48a696e84554275a52fbe6278f6df56","i-781daaf3"]],'enabled':true,'expires':'2016-11-10 20:20:00','cronjob_type':'interval','cronjob_entry':JSON.stringify({"every" : 5,"period" : "hours"})}' https://clear.glass/api/v1/schedules/3bb46efc882c4b44b21826e5e98f7c28
To delete one of your tasks, you need to send a DELETE call to / api /v1/schedules/taskId. E.g.:
user@user:/tmp$ curl -X DELETE -H "Authorization: 51fb1fc5554d0861d80843dd2612234365feb8211e9d191a70fde56a340bf742" https://clear.glass/api/v1/schedules/3bb46efc882c4b44b21826e5e98f7c28