Skip to content
n1zyy edited this page May 17, 2012 · 12 revisions

IMPORTANT NOTE: This is a local fork of the project and may not last forever, and this is not official project documentation. Don't count on this documentation kicking around forever. (And if you happen across this from Google, it's probably not what you want.)

The Conductor API currently has an immature API. There are plans to extend it into a robust API, but there is a need to (ab)use the capabilities of an API in the meantime. Here are some example of performing some basic operations over the quasi-API that works today.

Of course, much of what is here is an ugly hack.

In these examples, I used a base URL of http://localhost:3000/ and a username/password of admin/password. Obviously, you should customize to suit. You will probably want the /conductor prefix. You should not use "/api" in the URL except where mentioned; most these tools do not live there.

What does NOT work at all right now

  • Listing Catalogs (you'll need to get IDs through the web UI)
  • Listing Hardware Profiles (same)
  • Probably lots more not mentioned here

You could probably get some of this data from the Postgres database if you wanted, using the credentials in /etc/aeolus-conductor/database.yml.

Listing Images

Most of the examples here return JSON and do not live in /api. Images are the exception to both of these rules.

You can obtain a list of the images stored in iwhd like so:

$ curl --user admin:password http://localhost:3000/api/images
<images>
  <image href='http://localhost:3000/api/images/12dab92d-f1e9-494c-a722-491994487401' id='12dab92d-f1e9-494c-a722-491994487401'>
    <name>img1</name>
    <environment>default</environment>
    <description></description>
    <os></os>
    <os_version></os_version>
    <arch></arch>
    <builds type='xs:list'>
      <build href='http://localhost:3000/api/builds/62dd8550-76af-4ae1-a296-1966dc6ccc03' id='62dd8550-76af-4ae1-a296-1966dc6ccc03'></build>
    </builds>
  </image>
  <image href='http://localhost:3000/api/images/1473cdcc-9e93-11e1-8c56-70f395039857' id='1473cdcc-9e93-11e1-8c56-70f395039857'>
    <name>f15jeos</name>
    <environment>default</environment>
    <description>Fedora 15</description>
    <os>Fedora</os>
    <os_version>15</os_version>
    <arch>x86_64</arch>
    <builds type='xs:list'>
      <build href='http://localhost:3000/api/builds/a51d4984-e22c-4f03-b71f-7a9f27a0c351' id='a51d4984-e22c-4f03-b71f-7a9f27a0c351'></build>
    </builds>
  </image>
</images>

Of course, the aeolus-image CLI tools are useful here too.

Create a new deployable (Application Blueprint)

This does not have JSON support, so this is kind of inelegant.

Path

POST to /deployables

Required fields:

  • catalog_id[] -- An ID of a Catalog object in Conductor. Sadly, these cannot be listed over the API, so this example assumes the Default catalog with ID 1.
  • create_from_image -- The UUID of the Image you wish to include in the deployable
  • deployable[name] -- A name for the Deployable you are creating. (I gave mine the meaningless name "soma". Maybe I'm tired.)
  • hardware_profile -- an ID of a front-end HardwareProfile. I again used 1, for the default HWP.

Example

$ curl --user admin:password -F "catalog_id[]=1" -F "create_from_image=1473cdcc-9e93-11e1-8c56-70f395039857" -F "deployable[name]=soma" -F "hardware_profile=1" http://localhost:3000/deployables
<html><body>You are being <a href="http://localhost:3000/deployables/19">redirected</a>.</body></html>

The response is an HTML redirect, which curl does not follow. But, this is okay -- we just want the "/deployables/19" from the URL it tries to redirect to -- telling us that the new deployable has an ID of 19.

Listing Pools (Cloud Resource Zones)

This one's easy: a GET to /pools.json will return a JSON document outlining all Pools.

$ curl --user admin:password http://localhost:3000/pools.json
[{"id":3,"failed_instances_present":false,"filter_view_path":"/pools/3?view=filter","pool_family":{"name":"Empty","path":"/pool_families/3"},"deployments_count":0,"name":"Alternative","user_can_access_pool_family":true,"statistics":{"instances_failed_count":0,"total_instances":0,"instances_pending":0,"quota_percent":"0%"}},{"id":1,"failed_instances_present":true,"filter_view_path":"/pools/1?view=filter","pool_family":{"name":"default","path":"/pool_families/1"},"deployments_count":3,"name":"Default","user_can_access_pool_family":true,"statistics":{"instances_failed_count":2,"total_instances":3,"instances_pending":1,"quota_percent":"0%"}},{"id":7,"failed_instances_present":false,"filter_view_path":"/pools/7?view=filter","pool_family":{"name":"default","path":"/pool_families/1"},"deployments_count":0,"name":"Ivory Coast","user_can_access_pool_family":true,"statistics":{"instances_failed_count":0,"total_instances":0,"instances_pending":0,"quota_percent":"0%"}},{"id":6,"failed_instances_present":true,"filter_view_path":"/pools/6?view=filter","pool_family":{"name":"default","path":"/pool_families/1"},"deployments_count":9,"name":"Secondary","user_can_access_pool_family":true,"statistics":{"instances_failed_count":3,"total_instances":8,"instances_pending":0,"quota_percent":"0%"}},{"id":4,"failed_instances_present":true,"filter_view_path":"/pools/4?view=filter","pool_family":{"name":"Empty","path":"/pool_families/3"},"deployments_count":1,"name":"Wishbone","user_can_access_pool_family":true,"statistics":{"instances_failed_count":1,"total_instances":1,"instances_pending":0,"quota_percent":"0%"}}]

Launching a deployment (Application) from your deployable (Blueprint)

This one does respond with JSON. Creating a Deployment from a Deployable will launch it.

Path

POST to /deployments.json (or to plain /deployments with an Accept-Encoding header of application/json which should have the same effect)

Required Fields

  • deployable_id -- The ID of the Deployable you wish to launch. We got the ID 19 above when creating our Deployable, so that is what is used in the example below.
  • deployment[name] -- The name of the Deployment you wish to create. (I used "somethingnicer" because I had already created "somethingnice")
  • deployment[pool_id] -- The Pool you wish to launch into. I used ID 6 from the above list of pools.

Example

$ curl --user admin:password -F "deployable_id=19" -F "deployment[name]=somethingnicer" -F "deployment[pool_id]=6" http://localhost:3000/deployments.json
{"status":"pending","translated_state":"Pending","id":16,"uuid":"0c66cbb0-a05b-11e1-a073-70f395039857","deleted_at":null,
"owner_id":2,"instances_count_text":"Instance","provider":{"id":1,"name":"Mock"},"created_at":"2012-05-17 20:01:10 UTC","pool_family_id":1,"
created_at":"2012-05-17T20:01:10Z","deployable_xml":{"assemblies":[{"image_build":null,"image_id":"1473cdcc-9e93-11e1-8c56-70f395039857",
"hwp":"hwp1","services":[],"root":[["hwp","hwp1"],["name","f15jeos"]],"output_parameters":[],"image":[["id","1473cdcc-9e93-11e1-8c56-70f395039857"]],
"name":"f15jeos"}],"doc":[],"root":[["name","soma"],["version","1.0"]],"relax_file":"/home/mawagner/aeolus/conductor/src/app/util/deployable-rng.xml","
relax":{"errors":]}},"lock_version":1,"deployable_xml_name":"soma",
"state":"pending","owner":"Administrator ",
"status_description":"Deployment is starting up","name":"somethingnicer","pool_id":6,"realm_id":null,"uptime":"1 second","pool":{"id":6,"name":"Secondary"},
"frontend_realm_id":null,"instances_count":1,"failed_instances_count":0,"scheduled_for_deletion":false,"updated_at":"2012-05-17T20:01:11Z"}

The messy blob of JSON you get back should show state "pending" indicating that it's beginning to work. Also note that there are no errors.

Clone this wiki locally