Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
images
src
README.md
pom.xml

README.md

Rackspace Examples

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.

Requirements

  1. Username and API key for the Rackspace Cloud - See the Getting Started guide.
  2. Java Development Kit (JDK) version 6 or later - Download.
  3. Apache Maven - Maven in 5 Minutes.
  4. Git - Download.

Environment

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/

The Examples

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.

  • CloudFilesPublish.java - An end to end example of publishing a file on the internet with Cloud Files.
  • Other examples of creating, updating, listing, and deleting containers/objects.

The cloudservers package demonstrates how to accomplish common tasks for working with servers in the cloud.

  • CloudServersPublish.java - An end to end example of publishing a web page on the internet with Cloud Servers.
  • Other examples of creating, manipulating, listing, and deleting servers.

The cloudblockstorage package demonstrates how to accomplish common tasks for working with block storage (aka volumes) in the cloud.

  • CreateVolumeAndAttach.java - An end to end example of creating a volume, attaching it to a server, putting a filesystem on it, and mounting it for use to store persistent data.
  • Other examples of creating, manipulating, listing, and deleting volumes and snapshots.

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.

  • CreateDomains.java - An example of creating domains with subdomains and records.
  • CreateRecords.java - An example of creating records and adding them to a domain.
  • CRUDReverseDNSRecords.java - An example of creating a Cloud Server and a reverse DNS record (PTR) to go along with it.
  • Other examples of creating, manipulating, listing, and deleting domains and records.

The clouddatabases package demonstrates how to accomplish common tasks for working with databases in the cloud.

  • CreateInstance.java - An example of creating a database instance.
  • CreateDatabase.java - An example of creating a database on the database instance.
  • CreateUser.java - An example of creating a database user.
  • TestDatabase.java - An example of connecting to the database from the public Internet and making a simple request.
  • Other examples include deleting instances, databases, and users, and granting root access.

The cloudqueues package demonstrates how to accomplish common tasks for working with queues in the cloud.

Command Line

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!

Eclipse

To run these examples from Eclipse follow these instructions.

Create a new Java Project and choose jclouds-examples/rackspace/ as the Location.

Eclipse: Create Java Project

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.

Eclipse: Java Settings

Try out an example.

  1. Double click CreateContainer example file to open it.
  2. Choose the Run > Run Configurations... menu item.
  3. Press the plus icon to create a new launch configuration.
  4. This will automatically create a launch configuration for CreateContainer.
  5. Switch to the Arguments tab and enter your username and API key in the Program arguments field.

Eclipse: Launch Config

Click Run and watch the Console for the output!

Next Steps

Here are some suggestions on how to continue working with jclouds:

  1. Change the examples to do different things that you want to do.
  2. After running some examples, compare the output with what you see in the Cloud Control Panel.
  3. Browse the JavaDocs.
  4. Return to the Installation Guide and have a look at the different ways to integrate jclouds with your project.
  5. Join the user mailing list or developer mailing list.

Welcome to the jclouds community!

Support and Feedback

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:

sdk-support@rackspace.com