Example code that uses jclouds to perform common tasks on the Rackspace open cloud. The class names are self explanatory and the code is well commented for you to follow along.
To setup an environment to compile and run the examples use these commands:
git clone https://github.com/jclouds/jclouds-examples.git cd jcloud-examples/rackspace/
Now follow the instructions for Getting the binaries using Apache Ant. When you are done you should have a directory with the following files and sub-directories.
$ pwd /Users/username/jclouds-examples/rackspace $ ls build.xml maven-ant-tasks.jar README.md images/ lib/ src/
If you chose an installation method other than Ant and you want to run the Logging example (which is strongly encouraged!) then you'll need to manually download the Logback JAR files. Download the zip or tar.gz file, extract, and drop the JARs into the lib directory.
If you don‘t, you’ll see this error when you try to run the Logging example but the example will still work.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Start with the rackspace package. There you will find general purpose examples of things that are useful across all services.
The cloudfiles package demonstrates how to accomplish common tasks for putting files in and getting files from the cloud.
The cloudservers package demonstrates how to accomplish common tasks for working with servers in the cloud.
The cloudblockstorage package demonstrates how to accomplish common tasks for working with block storage (aka volumes) in the cloud.
To run these examples from the command line use these commands:
cd src/main/java/ javac -classpath ".:../../../lib/*:../resources/" org/jclouds/examples/rackspace/*.java
Every example class has a main method that takes your username as the first argument and your API key as the second argument. The one exception to this is the Authentication example that can take an optional third argument if you want to use your password for authentication.
Try out an example.
java -classpath ".:../../../lib/*:../resources/" org.jclouds.examples.rackspace.cloudservers.CreateServer myUsername myApiKey
Watch the terminal for output!
To run these examples from Eclipse follow these instructions.
Create a new Java Project and choose jcloud-examples/rackspace/ as the Location.
This should create a project with the following Java Settings. Eclipse will have detected the lib directory and filled in all of the Libraries for you.
Try out an example.
Click Run and watch the Console for the output!
Some suggestions.
Welcome to the jclouds community!
Your feedback is appreciated! If you have specific issues with Rackspace support in jclouds, we'd prefer that you file an issue via Github.
For general feedback and support requests, send an email to: