Update: Using jclouds 1.5.1
Getting jclouds and your own OpenStack deployment working together can be just a bit tricky as there are a couple of special configurations you need to make.
I’ve described how to get started with jclouds before but the other piece of this puzzle is your own OpenStack deployment. For easy and reliable testing I just run my own devstack install of OpenStack. Setting up devstack has been written about many times elsewhere so the only thing that I’ll say about it here is that I use an Ubuntu 12.04 Server VM running in VirtualBox. The trickiest part of that setup is the networking so I posted my VirtualBox settings on this question on ServerFault. After that it’s just a matter of following the devstack instructions.
Here’s the code for connecting to OpenStack. It’s very similar to the getting started example with a few key differences. In the init() method notice that
String provider = "openstack-nova";- This ones pretty self explanatory, we’re using the OpenStack Nova provider in jclouds
String identity = "demo:demo"; // tenantName:userName- Here we use the tenant name and user name with a colon between them instead of just a user name
String password = "devstack";- Instead of using the API key I’m using the password I set when devstack did its installation
.endpoint("http://172.16.0.1:5000/v2.0/")- This is the Keystone endpoint that jclouds needs to connect with to get more info (services and endpoints) from OpenStack
- When the devstack installation completes successfully, one of the last few lines will read something like “
Keystone is serving at http://172.16.0.1:5000/v2.0/“ - Set the endpoint to this URL
To get everything compiling and running do the following.
This post was written on Mac OS X 10.7.4, Java 1.6.0, jclouds 1.5.1 1.5.0-beta.10, and OpenStack Essex. If you’re on a different OS and run into problems, please feel free to comment.

Reynaldi Prasetyo
September 27, 2012 at 5:49 am
Hi.. Everett ..
i’m trying your script in my eclipse, but it have error in listImages() :
java.lang.Error: Unresolved compilation problem:
The method listImages() is undefined for the type ImageApi
i’m newbie in jclouds, please help,..
thanks
Everett Toews
September 27, 2012 at 11:45 am
Hi Reynaldi,
Can you send me some more details?
If you modified the code at all, please put it in a gist ( https://gist.github.com/ ) and send me the link.
Did you follow the instructions in my Getting Started with jcloud post ( http://blog.phymata.com/2012/08/15/getting-started-with-jclouds/ )? What does your Java Build Path look like for your project?
It should have all of the libraries from the lib dir. Here’s mine http://phymata.files.wordpress.com/2012/09/java-build-path.png
Hope this helps
Reynaldi Prasetyo
September 27, 2012 at 9:08 pm
Hi Everett,
thanks for answer my question,,
i’m not change your script, but i’m change in value:
String provider = “openstack-nova”;
String identity = “admin:admin”; // tenantName:userName
String password = “admin”;
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.credentials(identity, password)
.endpoint(“http://192.168.2.20:5000/v2.0/”),
i’m using centOS 6.3 and jre_1.6.0_53, and i have been follow your instructions in Getting Started,
i’m also using all of libraries on jclouds and when i’m “run as” on eclipse, i got error this on console:
java.lang.Error: Unresolved compilation problem:
The method listImages() is undefined for the type ImageApi
at JCloudsTest.listImages(JCloudsTest.java:58)
at JCloudsTest.main(JCloudsTest.java:26)
Thanks,..
Everett Toews
September 28, 2012 at 6:19 am
I see what happened. These examples were written with jclouds-beta.10, which has the ImageApi
http://demobox.github.com/jclouds-maven-site-1.5.0-beta.10/1.5.0-beta.10/jclouds-multi/apidocs/org/jclouds/openstack/nova/v2_0/features/ImageApi.html
When you grabbed the JARs, I think you grabbed a jclouds-1.5.0, which has the ImageApi
http://demobox.github.com/jclouds-maven-site-1.5.0/1.5.0/jclouds-multi/apidocs/org/jclouds/openstack/nova/v2_0/features/ImageApi.html
From 1.5.0-beta.10 to 1.5.0 the API change and listImages() became just list() and the return type changed too. You’ll need to change your code to the version of jclouds that you’re working on.
I’ll update my examples shortly after jclouds 1.5 is officially announced.
Cheers
Reynaldi Prasetyo
September 30, 2012 at 9:23 pm
Thanks, Everett.
your amazing …
now, I can run it…
Can I ask something? How to connect Azure with jclouds, Is the same with your getting started tutorial ??
Thanks …
Everett Toews
September 30, 2012 at 9:41 pm
Sorry, I haven’t used Azure before and I don’t know anything about it. Looks jclouds has some support for Azure Storage, see http://www.jclouds.org/documentation/quickstart/azure-storage/
Reynaldi Prasetyo
September 30, 2012 at 9:42 pm
OK, thanks before ..
Werner Buck
April 19, 2013 at 9:47 am
Is it possible to launch instances on openstack in virtualbox?
Everett Toews
April 19, 2013 at 10:25 am
Yep. But you’ll want to keep the instance sizes small.
Shankar
June 14, 2013 at 3:45 pm
Is it possible to get the tenant ID via jclouds ? I’ve tried various options – none of them seem to give the tenant ID.
Everett Toews
June 17, 2013 at 12:41 pm
I wrote a post about how to do this at http://blog.phymata.com/2013/06/17/jclouds-manual-authentication-with-openstack/
Shankar
June 18, 2013 at 12:36 pm
Thanks Everett !
syed
June 18, 2013 at 12:34 am
is it possible to create image and do other CRUD operation on image using openstack jclouds api? Does jclouds provide support for glance?
Everett Toews
June 18, 2013 at 8:34 am
Sorry. jclouds doesn’t have support for Glance yet. If you’d like to request support for it (or maybe even try implementing it yourself), file an issue at https://issues.apache.org/jira/browse/JCLOUDS