Example code that uses jclouds to perform common tasks on the Rackspace 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 jclouds-examples/rackspace/ $ pwd /Users/username/jclouds-examples/rackspace $ ls pom.xml README.md images/ src/
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.
The cloudloadbalancers package demonstrates how to accomplish common tasks for working with load balancers in the cloud.
The clouddns package demonstrates how to accomplish common tasks for working with DNS in the cloud.
The clouddatabases package demonstrates how to accomplish common tasks for working with databases in the cloud.
The cloudqueues package demonstrates how to accomplish common tasks for working with queues in the cloud.
To download all dependencies, run:
$ mvn dependency:copy-dependencies "-DoutputDirectory=./lib"
If you also want to download the source jars, run:
$ mvn dependency:copy-dependencies "-DoutputDirectory=./lib" "-Dclassifier=sources"
To run individual examples from the command line use these commands:
Note: If you're on Windows, the only change you need to make is to use a ‘;’ instead of a ‘:’ in the paths.
$ javac -classpath "lib/*:src/main/java/:src/main/resources/" src/main/java/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/*:src/main/java/:src/main/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 jclouds-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 JIRA.
For general feedback and support requests, send an email to: