OCCI Service Usage Guide 1.4
The OpenNebula OCCI API is a RESTful service to create, control and monitor cloud resources based on the latest draft of the OGF OCCI API specification. Interactions with the resources are done through HTTP verbs (GET, POST, PUT and DELETE).
There are three kind of resources, listed below with their implemented methods:
Collections of resources have the following implemented methods for all Pool Resources are:
An account is needed in order to use the OpenNebula OCCI cloud. The cloud administrator will be responsible for assigning these accounts, which have a one to one correspondence with OpenNebula accounts, so all the cloud administrator has to do is check the configuration guide to setup accounts, and automatically the OpenNebula OCCI cloud account will be created.
In order to use such an account, the end user can make use of clients programmed to access the services described in the previous section. For this, she has to set up her environment, particularly the following aspects:
Lets take a walk through a typical usage scenario. In this brief scenario it will be shown how to upload an image to the OCCI OpenNebula Storage repository, how to create a Network in the OpenNebula OCCI cloud and how to create Compute resource using the image and the network previously created.
Assuming we have a working Gentoo installation residing in an .img file, we can upload it into the OpenNebula OCCI cloud using the following OCCI representation of the image:
<DISK> <NAME>GentooImage</NAME> <URL>file:////images/gentoo.img</URL> </DISK>
Next, using the occi-storage command we will create the Storage resource:
<xterm> $ ./occi-storage --url http://localhost:4567 --username oneadmin --password opennebula create imagexml <DISK><ID>ab5c9770-7ade-012c-f1d5-00254bd6f386</ID><NAME>GentooImage</NAME><SIZE>1000</SIZE><URL>file://images/gentoo.img<URL></DISK> </xterm>
The user should take note of this ID, as it will be needed to add it to the Compute resource.
The next step would be to create a Network resource
<NETWORK> <NAME>MyServiceNetwork</NAME> <ADDRESS>192.168.1.1</ADDRESS> <SIZE>200</SIZE> </NETWORK>
Next, using the occi-network command we will create the Network resource:
<xterm> $ ./occi-network --url http://localhost:4567 --username oneadmin --password opennebula create vnxml <NIC><ID>23</ID><NAME>MyServiceNetwork</NAME><ADDRESS>192.168.1.1</ADDRESS><SIZE>200</SIZE></NIC> </xterm>
The last step would be to create a Compute resource referencing the Storage and Networks resource previously created by means of their ID, using a representation like the following:
<COMPUTE> <NAME>MyCompute</NAME> <STORAGE> <SWAP size="1024" dev="sda2"/> <DISK image="ab5c9770-7ade-012c-f1d5-00254bd6f386" dev="sda1"/> <FS size="512" format="ext3" dev="sda3"/> </STORAGE> <NETWORK> <NIC network="23" ip="192.168.0.9"/> </NETWORK> <INSTANCE_TYPE>small</INSTANCE_TYPE> </COMPUTE>
Next, using the occi-compute command we will create the Compute resource:
<xterm> $ ./occi-compute --url http://localhost:4567 --username tinova --password opennebula create ~/vmxml <COMPUTE><ID>17</ID><NAME>MyCompute</NAME><STATE>PENDING</STATE><STORAGE><DISK image="ab5c9770-7ade-012c-f1d5-00254bd6f386" dev="sda1"/><FS size="512" format="ext3" dev="sda3"/><SWAP size="1024" dev="sda2"/></STORAGE><NETWORK><NIC network="23" ip="192.168.0.9"/><NIC network="23" ip="192.168.1.1"/></NETWORK></COMPUTE> </xterm>