Schedule management
With these methods, you can schedule periodic operations to run in your cluster. The types of operations are currently limited to backups and best practice rules.
Methods |
|
---|---|
List jobs scheduled to run in OpsCenter. |
|
Get the description of a scheduled job. |
|
Schedule a job. |
|
Modify a scheduled job. |
|
Delete a scheduled job. |
Managing Job Schedules
Job Schedule
A job schedule describes an action that OpsCenter runs periodically. There are two possible schedule types; backups and best practice rules.
A job schedule has the following form:
{
"first_run_date": FIRST_RUN_DATE,
"first_run_time": FIRST_RUN_TIME,
"timezone": TIMEZONE,
"interval": INTERVAL,
"interval_unit": INTERVAL_UNIT
"job_params": JOB_PARAMS,
"id": ID,
"next_run": NEXT_RUN,
"last_run": LAST_RUN
}
Data:
-
FIRST_RUN_DATE (string): A date in YYYY-MM-DD format the date for running the job.
-
FIRST_RUN_TIME (string) : A time in hh:mm:ss format specifying the time to begin running the job.
-
TIMEZONE (string): The time zone, listed in the OpsCenter /meta/timezones directory, for the job schedule. For example, GMT, US/Central, US/Pacific, and US/Eastern are valid timezones.
-
INTERVAL (integer): In conjunction with interval_unit, this controls how often the job is executed. For example, an interval of 2 and an interval_unit of weeks results in a job that runs every two weeks.
-
INTERVAL_UNIT (string): The unit of time for interval. Values are minutes, hours, days, or weeks.
-
JOB_PARAMS (dict): A dictionary that describes the job. Only the type field is required to be present in the dictionary, and its value is currently limited to backup and best-practice. Fields for this dictionary are specific to the type; for the backup type, see Backup-Job-Params. For the best-practice type see Best Practice Job Params.
-
ID (string): A unique ID that references a job schedule. Use only for retrieving a job schedule.
-
NEXT_RUN (string): The date and time of the next scheduled run.
-
LAST_RUN (string): The date and time of the last successful run.
Backup Job Params
A JSON dictionary that describes a backup type of job-schedule
.
This should be used as the job_params
field in the Job Schedule.
{
"type": "backup",
"keyspaces": KEYSPACES,
"cleanup_age": CLEANUP_AGE,
"cleanup_age_unit": CLEANUP_AGE_UNIT,
"pre_snapshot_script": PRE_SNAPSHOT_SCRIPT,
"post_snapshot_script": POST_SNAPSHOT_SCRIPT,
"datacenters": DATACENTERS,
"destinations": DESTINATIONS,
"alert_on_failure": ALERT_ON_FAILURE,
"cleanup_dests": CLEANUP_DESTS,
"retries": RETRIES
}
Data:
-
KEYSPACES (list): A JSON list of keyspace names that should be included in scheduled backups. An empty list or null results in all keyspaces being included in the backups.
-
CLEANUP_AGE (int): (Optional) In combination with CLEANUP_AGE_UNIT, this specifies the age at which old backups should be deleted. A value of 0 disables automatic backup cleanup. This option defaults to a value of 0, meaning automatic backup cleanups are disabled by default.
-
CLEANUP_AGE_UNIT (string): (Optional) The unit of time for CLEANUP_AGE. Valid values include "minutes", "hours", "days" (the default), and "weeks".
-
PRE_SNAPSHOT_SCRIPT (string): (Optional) The file name of a custom script to be automatically run prior to triggering each backup. This file must exist within the
bin/backup-scripts/
directory where the OpsCenter agent is installed. Only letters, numbers, underscores and hyphens are permitted in the name. -
POST_SNAPSHOT_SCRIPT (string): (Optional) The file name of a custom script to be automatically run after each backup is taken. The name of each file included in the backup is passed to the script through
stdin
. This file must exist within thebin/backup-scripts/
directory where the OpsCenter agent is installed. Only letters, numbers, underscores and hyphens are permitted in the name. -
DATACENTERS (list): (Optional) A JSON list of data center names where backup should be performed. An empty list or null leads to performing backup in all data centers.
-
DESTINATIONS (object): (Optional) A JSON object representing the destinations for backup. The key is the destination ID obtained by using
/{cluster_id}/backups/destinations
API, and value is the JSON object with additional parameters specific for given destination. For example, you can specify retention time (withcleanup_age
andcleanup_age_unit
parameters), and/or compression (with parametercompressed
(true
/false
)). -
ALERT_ON_FAILURE (boolean): (Optional, default is
false
) boolean flag that defines, if the alert should be triggered on backup failure. -
RETRIES (int): (Optional, default is 0) number of retries to perform backup before triggering failure.
Best Practice Job Params
A JSON dictionary that describes a best practice rule type of job-schedule
.
This should be used as the job_params
field in the Job Schedule.
{
"type": "best-practice",
"rules": RULE_LIST
}
Data:
-
RULE_LIST (list): A JSON list of rules to run on the given schedule. At least one rule must be specified.
GET /{cluster_id}/job-schedules
Retrieve a list of jobs scheduled to run in OpsCenter. Currently the only types of jobs are a scheduled backup or a best practice rule.
Path arguments: * cluster_id: The ID of a cluster returned from GET /cluster-configs.
Returns a list of job-schedule
objects.
Example:
curl http://127.0.0.1:8888/Test_Cluster/job-schedules
Output:
[
{
"first_run_date": "2012-04-19",
"first_run_time": "18:00:00",
"id": "19119720-115a-4f2c-862f-e10e1fb90eed",
"interval": 1,
"interval_unit": "days",
"job_params": {
"cleanup_age": 30,
"cleanup_age_unit": "days",
"keyspaces": [],
"type": "backup"
},
"last_run": "2012-04-20 18:00:00 GMT",
"next_run": "2012-04-21 18:00:00 GMT",
"timezone": "GMT"
},
...
]
GET /{cluster_id}/job-schedules/{schedule_id}
Get the description of a scheduled job.
Path arguments:
* cluster_id: The ID of a cluster returned from GET /cluster-configs.
* schedule_id: A unique ID of the scheduled job that matches the id of a job-schedule
object.
Returns a Job Schedule object.
POST /{cluster_id}/job-schedules
Create a new scheduled job. You can create a scheduled job to run one time in the future by specifying an interval of -1 and interval_unit of null.
Path arguments:
* cluster_id: The ID of a cluster returned from GET /cluster-configs.
Body: A dictionary in the format of a Job Schedule describing the scheduled job to create. The id
,last_run
, and next_run
fields should be omitted.
* Responses: 201: Job schedule created successfully.
Returns the ID of the newly created job.
Example:
curl -X POST
http://127.0.0.1:8888/Test_Cluster/job-schedules/
-d
'{
"first_run_date": "2012-05-03",
"first_run_time": "18:00:00",
"interval": 1,
"interval_unit": "days",
"job_params": {
"cleanup_age": 30,
"cleanup_age_unit": "days",
"keyspaces": [],
"type": "backup"
},
"timezone": "GMT"
}'
Output:
"905391b7-1920-486d-a633-282f22dce604"
PUT /{cluster_id}/job-schedules/{schedule_id}
Update a scheduled job.
Path arguments: * cluster_id: The ID of a cluster returned from GET /cluster-configs. * schedule_id: A unique ID identifying the schedule job to update. Body: A dictionary with fields from :http:response:`job-schedule` that you would like to update. * Responses: 200: Schedule updated successfully.
Returns null.
Example:
curl -X PUT
http://127.0.0.1:8888/Test_Cluster/job-schedules/905391b7-1920-486d-a633-282f22 dce604
-d
'{
"interval": "12",
"interval_unit": "hours"
}'
DELETE /{cluster_id}/job-schedules/{schedule_id}
Delete a scheduled job.
Path arguments: * cluster_id: The ID of a cluster returned from GET /cluster-configs. * schedule_id: A unique ID identifying the schedule job to delete. Body: A dictionary with fields from :http:response:`job-schedule` that you would like to update. * Responses: 200: Schedule deleted successfully.
Returns null.
Example:
curl -X DELETE
http://127.0.0.1:8888/Test_Cluster/job-schedules/905391b7-1920-486d-a633-282f22 dce604