RSS

jclouds and OpenStack

04 Sep

OpenStack

Update: This post is out of date. Use the Apache jclouds OpenStack Quick Start Guide instead.

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.

 
19 Comments

Posted by on September 4, 2012 in jclouds, openstack

 

19 responses to “jclouds and OpenStack

  1. 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 :)

     
  2. 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 …

     
  3. 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.

       
  4. 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.

     
  5. 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?

     
  6. Ferenc Cserepkei

    August 26, 2013 at 1:25 pm

    Everett Im using ununtu 12-04/devstack/oraclejdk7.25 Your example is the first one looks like working, i have tried JCloudsNova.java JCloudsSwift.java from http://jclouds.incubator.apache.org/documentation/quickstart/openstack none of them worked. Unfortunatel y cannot get rid of slf4j debug output, bit annoying… How can i? I have put a logback.xml on the classpath, buths no effect…
    any help are welcome

     
    • Everett Toews

      August 26, 2013 at 2:25 pm

      Comment out the modules variable and the .modules(modules) when creating the context.

       
      • Ferenc Cserepkei

        August 26, 2013 at 3:30 pm

        Great!!
        Thank You so much!

        java -classpath “.:lib/*” JCloudsOpenStack
        Calling listImages for RegionOne:
        Image{id=5e989034-5faf-4be6-a79b-5096147f81f2, name=cirros-0.3.1-x86_64-uec, links=[Link{relation=SELF, href=http://192.168.1.39:8774/v2/414fec1808dd4519ab5bd9e3a7342cf8/images/5e989034-5faf-4be6-a79b-5096147f81f2}, Link{relation=BOOKMARK, href=http://192.168.1.39:8774/414fec1808dd4519ab5bd9e3a7342cf8/images/5e989034-5faf-4be6-a79b-5096147f81f2}, Link{relation=ALTERNATE, type=application/vnd.openstack.image, href=http://192.168.1.39:9292/414fec1808dd4519ab5bd9e3a7342cf8/images/5e989034-5faf-4be6-a79b-5096147f81f2}], updated=Mon Aug 26 19:19:14 CEST 2013, created=Mon Aug 26 19:19:13 CEST 2013, tenantId=null, userId=null, status=ACTIVE, progress=100, minDisk=0, minRam=0, server=null, metadata={kernel_id=8ed6e444-e52c-4732-80a1-f38e1b535174, ramdisk_id=033f08e8-44f1-485c-8f8e-d45b4374e50a}}
        Image{id=033f08e8-44f1-485c-8f8e-d45b4374e50a, name=cirros-0.3.1-x86_64-uec-ramdisk, links=[Link{relation=SELF, href=http://192.168.1.39:8774/v2/414fec1808dd4519ab5bd9e3a7342cf8/images/033f08e8-44f1-485c-8f8e-d45b4374e50a}, Link{relation=BOOKMARK, href=http://192.168.1.39:8774/414fec1808dd4519ab5bd9e3a7342cf8/images/033f08e8-44f1-485c-8f8e-d45b4374e50a}, Link{relation=ALTERNATE, type=application/vnd.openstack.image, href=http://192.168.1.39:9292/414fec1808dd4519ab5bd9e3a7342cf8/images/033f08e8-44f1-485c-8f8e-d45b4374e50a}], updated=Mon Aug 26 19:19:13 CEST 2013, created=Mon Aug 26 19:19:13 CEST 2013, tenantId=null, userId=null, status=ACTIVE, progress=100, minDisk=0, minRam=0, server=null, metadata={}}
        Image{id=8ed6e444-e52c-4732-80a1-f38e1b535174, name=cirros-0.3.1-x86_64-uec-kernel, links=[Link{relation=SELF, href=http://192.168.1.39:8774/v2/414fec1808dd4519ab5bd9e3a7342cf8/images/8ed6e444-e52c-4732-80a1-f38e1b535174}, Link{relation=BOOKMARK, href=http://192.168.1.39:8774/414fec1808dd4519ab5bd9e3a7342cf8/images/8ed6e444-e52c-4732-80a1-f38e1b535174}, Link{relation=ALTERNATE, type=application/vnd.openstack.image, href=http://192.168.1.39:9292/414fec1808dd4519ab5bd9e3a7342cf8/images/8ed6e444-e52c-4732-80a1-f38e1b535174}], updated=Mon Aug 26 19:19:12 CEST 2013, created=Mon Aug 26 19:19:12 CEST 2013, tenantId=null, userId=null, status=ACTIVE, progress=100, minDisk=0, minRam=0, server=null, metadata={}}

         

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: