Deltacloud CIMI API - CIMI Volumes, Machines and the MachineVolume collection

In case you didnt know, Deltacloud implements the DMTF Cloud Infrastructure Management Interface API (CIMI). This means that you can ‘talk’ CIMI to any of the cloud providers supported by Deltacloud, including Amazon EC2, Openstack, RHEV-M and vSphere. The documentation on the Deltacloud website is in dire need of update to include CIMI-specific information; this should be addressed soon but until then here are some notes showing how to work with CIMI Volumes and Machines in Deltacloud.


Starting Deltacloud with the CIMI frontend enabled

The ‘-f’ flag is used to tell deltacloud which ‘frontend’ to enable. By default, only the ‘classic’ Deltacloud API is exposed. Right now you can enable ‘cimi’, ‘ec2’ or ‘deltacloud’; in fact you can expose all three with a single instance of the Deltacloud server:

deltacloudd -i mock -f cimi,ec2,deltacloud

The deltacloud API is exposed at /api, the CIMI API is exposed at /cimi and the EC2 API is exposed at /ec2. You can get the these locations by requesting the deltacloud URI in a web browser (by default the server is started at localhost:3001).

So we can request the CIMI CloudEntryPoint:

[marios@name server]$ curl -H "Accept: application/xml"
            http://localhost:3001/cimi/cloudEntryPoint

<CloudEntryPoint xmlns="http://schemas.dmtf.org/cimi/1">
  <id>http://localhost:3001/cimi/cloudEntryPoint</id>
  <name>mock</name>
  <description>Cloud Entry Point for the Deltacloud mock driver</description>
  <created>2012-11-28 12:48:40 +0200</created>
  <baseURI>http://localhost:3001/cimi</baseURI>
  <resourceMetadata href="http://localhost:3001/cimi/resource_metadata" />
  <machines href="http://localhost:3001/cimi/machines" />
  <machineConfigs href="http://localhost:3001/cimi/machine_configurations" />
  <machineImages href="http://localhost:3001/cimi/machine_images" />
  <credentials href="http://localhost:3001/cimi/credentials" />
  <volumes href="http://localhost:3001/cimi/volumes" />
  <volumeConfigs href="http://localhost:3001/cimi/volume_configurations" />
  <volumeImages href="http://localhost:3001/cimi/volume_images" />
  <networks href="http://localhost:3001/cimi/networks" />
  <networkTemplates href="http://localhost:3001/cimi/network_templates" />
  <networkConfigs href="http://localhost:3001/cimi/network_configurations" />
  <networkPorts href="http://localhost:3001/cimi/network_ports" />
  <networkPortTemplates href="http://localhost:3001/cimi/network_port_templates" />
  <networkPortConfigs href="http://localhost:3001/cimi/network_port_configurations" />
  <addresses href="http://localhost:3001/cimi/addresses" />
  <addressTemplates href="http://localhost:3001/cimi/address_templates" />
  <forwardingGroups href="http://localhost:3001/cimi/forwarding_groups" />
  <forwardingGroupTemplates href="http://localhost:3001/cimi/forwarding_group_templates" />
</CloudEntryPoint>



Listing Machines

Following the link obtained from the cloudEntryPoint:

[marios@name server]$ curl --user "mockuser:mockpassword"
    -H "Accept: application/xml"
    http://localhost:3001/cimi/machines

<Collection xmlns="http://schemas.dmtf.org/cimi/1">
  <id>http://localhost:3001/cimi/machines</id>
  <name>default</name>
  <description>Machine Collection for the Mock driver</description>
  <count>2</count>
  <Machine>
    <id>http://localhost:3001/cimi/machines/inst0</id>
    <name>inst0</name>
    <description>Mock Instance With Profile Change</description>
    <property name="machine_image">http://localhost:3001/cimi/machine_images/img1</property>
    <property name="credential">http://localhost:3001/cimi/credentials</property>
    <state>STARTED</state>
    <cpu>1</cpu>
    <memory>12582912</memory>
    <disks href="http://localhost:3001/cimi/machines/inst0/disks">
      <id>http://localhost:3001/cimi/machines/inst0/disks</id>
      <count>1</count>
      <Disk>
        <id>http://localhost:3001/cimi/machines/inst0/disks/inst0_disk_891289600</id>
        <name>inst0_disk_891289600</name>
        <description>DiskCollection for Machine inst0</description>
        <capacity>891289600</capacity>
      </Disk>
    </disks>
    <volumes href="http://localhost:3001/cimi/machines/inst0/volumes" />
    <operation rel="http://schemas.dmtf.org/cimi/1/action/restart"
          href="http://localhost:3001/cimi/machines/inst0/restart" />
    <operation rel="http://schemas.dmtf.org/cimi/1/action/stop"
          href="http://localhost:3001/cimi/machines/inst0/stop" />
  </Machine>

  (...)
</Collection>

Again, following the URI we can obtain the MachineVolume collection for a specific Machine:

[marios@name server]$ curl --user "mockuser:mockpassword"
        -H "Accept: application/xml"
         http://localhost:3001/cimi/machines/inst1/volumes

<Collection xmlns="http://schemas.dmtf.org/cimi/1"
      resourceURI="http://schemas.dmtf.org/cimi/1/MachineVolumeCollection">
  <id>http://localhost:3001/cimi/machines/inst1/volumes</id>
  <count>1</count>
  <MachineVolume>
    <id>http://localhost:3001/cimi/machines/inst1/volumes/vol3</id>
    <name>vol3</name>
    <description>MachineVolume vol3 for Machine inst1</description>
    <created>2009-07-30T14:35:11Z</created>
    <initialLocation>/dev/sda1</initialLocation>
    <volume href="http://localhost:3001/cimi/volumes/vol3" />
    <operation rel="delete"
      href="http://localhost:3001/cimi/machines/inst1/volumes/vol3" />
  </MachineVolume>
  <operation rel="add"
      href="http://localhost:3001/cimi/machines/inst1/volume_attach" />
</Collection>

Notice the ‘addURI’ of the MachineVolume collection (/inst1/volume_attach) which we will use later to attach a new Volume to this instance. Also, notice the ‘deleteURI’ of the MachineVolume, which is used to detach the particular Volume from this Machine.



Listing Volumes

You can retrieve the Volume collection in order to select the volume you would like to attach to a Machine:

curl --user "mockuser:mockpassword" -H "Accept: application/xml"
    http://localhost:3001/cimi/volumes

<Collection xmlns="http://schemas.dmtf.org/cimi/1"
     resourceURI="http://schemas.dmtf.org/cimi/1/VolumeCollection">
  <id>http://localhost:3001/cimi/volumes</id>
  <count>3</count>
  <Volume>
    <id>http://localhost:3001/cimi/volumes/vol2</id>
    <name>vol2</name>
    <description>vol2</description>
    <created>2009-07-30T14:35:11Z</created>
    <state>AVAILABLE</state>
    <type>http://schemas.dmtf.org/cimi/1/mapped</type>
    <capacity>1048576</capacity>
    <bootable>false</bootable>
  </Volume>
(...)
</Collection>



Working with the MachineVolume collection

Once you’ve selected a Volume, you can attach it to a Machine with:

curl -v --user "mockuser:mockpassword" -H "Content-Type: application/xml"
    -H "Accept: application/xml" -X PUT -d
    '<MachineVolume xmlns="http://schemas.dmtf.org/cimi/1/MachineVolume">
      <initialLocation> /dev/sdf </initialLocation>
      <volume href="http://localhost:3001/cimi/volumes/vol2"/>
    </MachineVolume>'  http://localhost:3001/cimi/machines/inst1/volume_attach

The URI for the attach operation is obtained from the MachineVolume collection - the “addURI”. In JSON format the same request looks like:

curl -v --user "mockuser:mockpassword" -H "Content-Type: application/json"
    -H "Accept: application/xml" -X PUT -d
    '{"resourceURI":"http://schemas.dmtf.org/cimi/1/MachineVolume",
    "initialLocation": "/dev/sdf",
    "volume": {"href":"http://localhost:3001/cimi/volumes/vol2"}}'
    http://localhost:3001/cimi/machines/inst1/volume_attach

The response in the newly created MachineVolume entity:

< HTTP/1.1 201 Created
< Content-Type: application/xml
< CIMI-Specification-Version: 1.0.1
< Content-Length: 522
< ETag: 8379f00a2f8d73091758a62591874082
< Cache-Control: max-age=0, private, must-revalidate
< Date: Wed, 28 Nov 2012 11:12:49 GMT
< Connection: keep-alive
<
<MachineVolume xmlns="http://schemas.dmtf.org/cimi/1"
    resourceURI="http://schemas.dmtf.org/cimi/1/MachineVolume">
  <id>http://localhost:3001/cimi/machines/inst1/volumes/vol2</id>
  <name>vol2</name>
  <description>MachineVolume vol2 for Machine inst1</description>
  <created>2009-07-30T14:35:11Z</created>
  <initialLocation>/dev/sdf</initialLocation>
  <volume href="http://localhost:3001/cimi/volumes/vol2" />
  <operation rel="delete"
    href="http://localhost:3001/cimi/machines/inst1/volumes/vol2" />
</MachineVolume>

To detach a Volume from a Machine we use the ‘delete’ URI given in the serialization of the MachineVolume:

curl -v --user "mockuser:mockpassword" -H "Accept: application/xml"
    -X DELETE http://localhost:3001/cimi/machines/inst1/volumes/vol2

< HTTP/1.1 200 OK
< Content-Type: application/xml
< CIMI-Specification-Version: 1.0.1
< Content-Length: 747
< ETag: 8e2d333a3747634c04942b7d219a8d59
< Cache-Control: max-age=0, private, must-revalidate
< Date: Wed, 28 Nov 2012 11:15:53 GMT
< Connection: keep-alive
<
<Collection xmlns="http://schemas.dmtf.org/cimi/1"
    resourceURI="http://schemas.dmtf.org/cimi/1/MachineVolumeCollection">
  <id>http://localhost:3001/cimi/machines/inst1/volumes</id>
  <count>1</count>
  <MachineVolume>
    <id>http://localhost:3001/cimi/machines/inst1/volumes/vol3</id>
    <name>vol3</name>
    <description>MachineVolume vol3 for Machine inst1</description>
    <created>2009-07-30T14:35:11Z</created>
    <initialLocation>/dev/sda1</initialLocation>
    <volume href="http://localhost:3001/cimi/volumes/vol3" />
    <operation rel="delete" href="http://localhost:3001/cimi/machines/inst1/volumes/vol3" />
  </MachineVolume>
  <operation rel="add" href="http://localhost:3001/cimi/machines/inst1/volume_attach" />
</Collection>

The response shows the updated MachineVolume collection, which in this case still contains one MachineVolume.



blog comments powered by Disqus
RSS Feed Icon site.xml
RSS Feed Icon tripleo.xml