Scheduling vCO workflows with curl and the REST API

There is an issue with vCenter Orchestrator 5.1.0 not running scheduled workflows (http://kb.vmware.com/kb/2041733). The KB says it’s resolved n 5.1.0 but it appears that it’s not. Until the issue is resolved, this post will show you how to schedule vCO workflow runs.

Say you have a workflow named BackupProviderVMs that you want to run every Sunday. First you need to find the workflow’s itemHref value. You can get this by running the following and replacing the vCO URL, credentials and your workflow name:

curl -i -k -H “accept:application/xml” -H “content-type:application/xml;charset=UTF-8” -u vcoadmin:password -X GET https://vco.example.com:8281/api/workflows?conditions=name=BackupProviderVMs

In my example the value of itemHref was https://vco.example.com:8281/api/workflows/A780808080808080808080808080808064B6808001326285598060aebf2a6a5a5/

itemHref will be used in the remaining command as such:

curl -i -k -H “accept:application/xml” -H “content-type:application/xml;charset=UTF-8” -u vcoadmin:password -X GET itemHref/…

You can view existing runs for the workflow by running:

curl -i -k -H “accept:application/xml” -H “content-type:application/xml;charset=UTF-8” -u vcoadmin:password -X GET https://vco.example.com:8281/api/workflows/A780808080808080808080808080808064B6808001326285598060aebf2a6a5a5/executions

The workflow can be ran with:

curl -i -k -H “accept:application/xml” -H “content-type:application/xml;charset=UTF-8” -u vcoadmin:password -X POST https://vco.example.com:8281/api/workflows/A780808080808080808080808080808064B6808001326285598060aebf2a6a5a5/executions -d @relocate-response

Where relocate-response is a file with the contents of:

<execution-context xmlns=”http://www.vmware.com/vco”&gt;
<parameters>
</parameters>
</execution-context>

The workflow can be scheduled to run by creating a crontab entry on the vCO server as such:

05 02 * * 0 /usr/bin/curl -i -k -H “accept:application/xml” -H “content-type:application/xml;charset=UTF-8” -u vcoadmin:password -X POST https://vco.example.com:8281/api/workflows/A780808080808080808080808080808064B6808001326285598060aebf2a6a5a5/executions -d @/usr/local/src/relocate-response

Advertisements

2 Comments on “Scheduling vCO workflows with curl and the REST API”

  1. […] The workflow id is e2e9b56a-7867-44a6-9b9f-3b3e69fe1175.   You can get the workflow id by pressing ctrl-c while the workflow is highlighted in the vCO client or using the method in https://kickingwaterbottles.wordpress.com/2013/06/05/scheduling-vco-workflows-with-curl-and-the-rest-&#8230; […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s