Scheduling changes provides flexibility to execute API actions at any given time. For instance, scheduling to automatically upgrade VMware Tools, or to Shutdown VM and then increase memory or CPU can be accomplished by just adding the schedule attribute to any PUT request in any virutal machine resource /vm/<resource>. This guide, will exemplify how to schedule the following actions:
- Power Off VM
- Add CPU
- Add Memory
- Power On VM
Prerequisites
- Valid access token.
- Access to Virtual Machine.
Step-by-step guide
Get virtual machine UUID using the search feature in the /vm resource:
Requesthttp -a $TK GET "https://vss-api.eis.utoronto.ca:8001/v2/vm?name=coreos0&summary"
This would be a simple VM State change via a PUT request to /vm/<uuid>/state with the attribute value set to poweredOff but, by adding the schedule attribute will be added as a scheduled change. The following example will schedule its execution at 4:00am on 2016-07-13:
http -a $TK PUT "https://vss-api.eis.utoronto.ca:8001/v2/vm/5012abcb-a9f3-e112-c1ea-de2fa9dab90a/state" value=poweredOff schedule='2016-07-13 04:00'
The schedule attribute is expected to be in the following format: yyyy-mm-dd HH:MM
Response from the API will provide feedback upon request. Please, make sure it state is Scheduled:
Then, memory and CPU updates could be executed five and seven minutes later:
http -a $TK PUT "https://vss-api.eis.utoronto.ca:8001/v2/vm/5012abcb-a9f3-e112-c1ea-de2fa9dab90a/memory" value=3 schedule='2016-07-13 04:05' http -a $TK PUT "https://vss-api.eis.utoronto.ca:8001/v2/vm/5012abcb-a9f3-e112-c1ea-de2fa9dab90a/cpu" value=2 schedule='2016-07-13 04:07'
Verifying your request has been successfully scheduled is also possible using the /request/change/<id> resource, for instance:
- At this point just wait for the email confirmation or check periodically the status of the request.
Related articles