OpenNebula EC2 User Guide 2.2
The EC2 Query API offers the functionality exposed by Amazon EC2: upload images, register them, run, monitor and terminate instances, etc. In short, Query requests are HTTP or HTTPS requests that use the HTTP verb GET or POST and a Query parameter.
OpenNebula implements a subset of the EC2 Query interface, enabling the creation of public clouds managed by OpenNebula. In this first release of the API implementation, the methods implemented are:
An account is needed in order to use the OpenNebula 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 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 his environment, particularly the following aspects:
EC2_URL
has to use the FQDN of the EC2-Query Server
Lets take a walk through a typical usage scenario. In this brief scenario it will be shown how to upload an image to the OpenNebula image repository, how to register it in the OpenNebula cloud and perform operations upon it.
Assuming we have a working Gentoo installation residing in an .img file, we can upload it into the OpenNebula cloud using the econe-upload command:
<xterm> $ ./econe-upload /images/gentoo.img Success: ImageId ami-00000001 </xterm>
The user should take note of this ImageId, as it will be needed to register the image.
The next step should be registering the image to enable its instantiation. We can do this with the econe-register command:
<xterm> $ ./econe-register ami-00000001 Success: ImageId ami-00000001 </xterm>
We will need the ImageId to launch the image, so in case we forgotten we can list registered images using the econe-describe-images command:
<xterm> $ ./econe-describe-images -H Owner ImageId Location
helen ami-00000001 /tmp/images/1 </xterm>
Once we recall the ImageId, we will need to use the econe-run-instances command to launch an Virtual Machine instance of our image:
<xterm> $ ./econe-run-instances -H ami-00000001 Owner ImageId InstanceId InstanceType
helen ami-00000001 i-15 m1.small </xterm>
We will need the InstanceId to monitor and shutdown our instance, so we better write down that 15.
If we have too many instances launched and we don't remember everyone of them, we can ask econe-describe-instances to show us which instances we have submitted.
<xterm> $ ./econe-describe-instances -H Owner Id ImageId State IP Type
helen i-15 ami-00000001 pending 147.96.80.33 m1.small </xterm>
We can see that the instances with Id 15 has been launched, but it is still pending, i.e., it still needs to be deployed into a physical host. If we try the same command again after a short while, we should be seeing it running as in the following excerpt:
<xterm> $ ./econe-describe-instances -H Owner Id ImageId State IP Type
helen i-15 ami-00000001 running 147.96.80.33 m1.small </xterm>
After we put the Virtual Machine to a good use, it is time to shut it down to make space for other Virtual Machines (and, presumably, to stop being billed for it). For that we can use the econe-terminate-instances passing to it as an argument the InstanceId that identifies our Virtual Machine:
<xterm> $ ./econe-terminate-instances 15 Success: Terminating i-15 in running state </xterm>