diff --git a/.gitignore b/.gitignore index ca35be0..d61eba9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ +.DS_Store _site +.project +.idea/ +*.iml +site-content/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..0379038 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# jclouds + +This repository supports the GitHub Pages site for jclouds. See and read more at [http://www.jclouds.org](http://www.jclouds.org). + +To deploy web site to ASF: +* have jekyll installed +* sh ./deploy-site.sh $uid $pwd (with $uid your ASF account $pwd your ASF password) + diff --git a/README.txt b/README.txt deleted file mode 100644 index 8c8617f..0000000 --- a/README.txt +++ /dev/null @@ -1 +0,0 @@ -GitHub Pages site for jclouds. See http://www.jclouds.org \ No newline at end of file diff --git a/_config.yml b/_config.yml index decb852..732a51d 100644 --- a/_config.yml +++ b/_config.yml @@ -1 +1,3 @@ markdown: rdiscount +pygments: true +permalink: pretty \ No newline at end of file diff --git a/_includes/footer.md b/_includes/footer.md new file mode 100644 index 0000000..eeeb7dc --- /dev/null +++ b/_includes/footer.md @@ -0,0 +1,5 @@ +Copyright © 2011 The Apache Software Foundation. All Rights Reserved. + +jclouds is licensed under [the Apache License, Version 2.0](https://github.com/jclouds/jclouds/blob/master/resources/LICENSE.txt). + +The jclouds logo is trademark of jclouds, Inc. diff --git a/_includes/menu.md b/_includes/menu.md new file mode 100644 index 0000000..8726624 --- /dev/null +++ b/_includes/menu.md @@ -0,0 +1,5 @@ +* [Getting Started](/documentation/gettingstarted/) +* [Documentation](/documentation/) +* [Community](/documentation/community/) +* [Development](/documentation/devguides/) +* [Contact](http://groups.google.com/group/jclouds) diff --git a/_includes/sidebar.html b/_includes/sidebar.html deleted file mode 100644 index e53e6a8..0000000 --- a/_includes/sidebar.html +++ /dev/null @@ -1,126 +0,0 @@ -
Name | -Description | -Default | -Example | -
---|---|---|---|
*providerName* | -The camel case name for the service. Will be used in class names, so should not contain spaces or other invalid characters. | -- | Tweeter | -
*artifactId* | -The name of the project. Will be prefixed with `jclouds-`, and will also be the name of the generated project directory, so should not contain invalid characters. | -- | tweeter | -
*providerEndpoint* | -The URL at which the service can be accessed. | -- | http://tweeter.com/api | -
*providerIdentity* | -What does this provider call an identity? | -- | user, account, apikey | -
*providerCredential* | -What does this provider call a credential, associated with above? | -- | password, secret, key | -
*providerApiVersion* | -What version of the rest api are you working on? | -- | 1.0, 2001-11-01 | -
*groupId* | -The Maven project groupId. | -org.jclouds | -- |
*author* | -The author of the project. | -Adrian Cole | -- |
*package* | -The Java base package of the project's classes. | -_same as_ `groupId`.`artifactId` | -- |
*version* | -The Maven project version. | -1.0-SNAPSHOT | -- |
file | -Reason | -
---|---|
src/test/resources/log4j.xml | -adding compute logger | -
src/main/java/org/jclouds/`artifactId`/`providerName`ContextBuilder | -converts to build a ComputeServiceContext instead of a RestContext | -
src/main/java/org/jclouds/`artifactId`/`providerName`ContextFactory | -converts to build a ComputeServiceContext instead of a RestContext | -
log | -path | -purpose | -
---|---|---|
test log | -target/surefire-reports/TestSuite.txt | -shows you the line in the test code that failed and specific reason | -
wire log | -target/test-data/jclouds-wire.log | -shows you all http packets sent to the service and their responses | -
jclouds log | -target/test-data/jclouds.log | -shows you which java methods created which packets and also other debug info | -
ssh log | -target/test-data/jclouds-ssh.log | -shows you connections to other machines | -
abstraction log | -target/test-data/jclouds-_compute or blobstore_.log | -shows you high-level commands, like what node is being deployed at what time | -
Name | +Description | +Default | +Example | +
---|---|---|---|
*providerName* | +The camel case name for the service. This will be used in class names, so it should not contain spaces or other invalid characters. | ++ | Tweeter | +
*artifactId* | +The name of the project. It will be prefixed with `jclouds-` and will also be the name of the generated project directory. It should not contain invalid characters. | ++ | tweeter | +
*providerEndpoint* | +The URL at which the service can be accessed. | ++ | http://tweeter.com/api | +
*providerIdentity* | +What does this provider call an identity? | ++ | user, account, apikey | +
*providerCredential* | +This is associated with the providerIdentity. What does this provider call a credential? | ++ | password, secret, key | +
*providerApiVersion* | +What version of the REST API are you working on? | ++ | 1.0, 2001-11-01 | +
*groupId* | +The Maven project groupId. | +org.jclouds | ++ |
*author* | +The author of the project. | +Adrian Cole | ++ |
*package* | +The Java base package of the project's classes. | +groupId.artifactId | ++ |
*version* | +The Maven project version. | +1.0-SNAPSHOT | ++ |
log | +path | +purpose | +
---|---|---|
test log | +target/surefire-reports/TestSuite.txt | +shows you the line in the test code that failed and specific reason | +
wire log | +target/test-data/jclouds-wire.log | +shows you all http packets sent to the service and their responses | +
jclouds log | +target/test-data/jclouds.log | +shows you which java methods created which packets and also other debug info | +
ssh log | +target/test-data/jclouds-ssh.log | +shows you connections to other machines | +
abstraction log | +target/test-data/jclouds-_compute or blobstore_.log | +shows you high-level commands, like what node is being deployed at what time | +
{% highlight java %} -import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; -import static org.jclouds.openstack.nova.options.ListOptions.Builder.*; -import org.jclouds.Constants; +import static com.google.common.io.Closeables.closeQuietly; + +import java.io.Closeable; +import java.util.Set; + +import org.jclouds.ContextBuilder; +import org.jclouds.compute.ComputeService; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; +import org.jclouds.openstack.nova.v2_0.NovaApi; +import org.jclouds.openstack.nova.v2_0.NovaAsyncApi; +import org.jclouds.openstack.nova.v2_0.domain.Server; +import org.jclouds.openstack.nova.v2_0.features.ServerApi; +import org.jclouds.rest.RestContext; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +public class JCloudsNova implements Closeable { + private ComputeService compute; + private RestContext+ +In the init() method note 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";` + * The demo account uses ADMIN_PASSWORD too +* `.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 depending on the method used to get OpenStack above. + +### Compile and Run + + javac -classpath ".:lib/*" JCloudsNova.java + + java -classpath ".:lib/*" JCloudsNova + + [logging output] + Servers in RegionOne + [logging output] + Server{uuid=...} + ... + +## List Containers +### Introduction + +[OpenStack Object Storage](http://www.openstack.org/software/openstack-storage/) (aka Swift) provides redundant, scalable object storage using clusters of standardized servers capable of storing petabytes of data. + +### The Source Code + +1. Create a Java source file called JCloudsSwift.java in the jclouds directory above. +1. You should now have a directory with the following structure: + * `jclouds/` + * `JCloudsSwift.java` + * `build.xml` + * `maven-ant-tasks.jar` + * `lib/` + * `*.jar` +1. Open JCloudsSwift.java for editing, read the code below, and copy it in. +nova; + private Set zones; + + public static void main(String[] args) { + JCloudsNova jCloudsNova = new JCloudsNova(); + + try { + jCloudsNova.init(); + jCloudsNova.listServers(); + jCloudsNova.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + jCloudsNova.close(); + } + } + + private void init() { + Iterable modules = ImmutableSet. of(new SLF4JLoggingModule()); + + String provider = "openstack-nova"; + String identity = "demo:demo"; // tenantName:userName + String password = "devstack"; // demo account uses ADMIN_PASSWORD too + + ComputeServiceContext context = ContextBuilder.newBuilder(provider) + .endpoint("http://172.16.0.1:5000/v2.0/") + .credentials(identity, password) + .modules(modules) + .buildView(ComputeServiceContext.class); + compute = context.getComputeService(); + nova = context.unwrap(); + zones = nova.getApi().getConfiguredZones(); + } + + private void listServers() { + for (String zone: zones) { + ServerApi serverApi = nova.getApi().getServerApiForZone(zone); + + System.out.println("Servers in " + zone); + + for (Server server: serverApi.listInDetail().concat()) { + System.out.println(" " + server); + } + } + } + + public void close() { + closeQuietly(compute.getContext()); + } +} {% endhighlight %} +
{% highlight java %} -Properties overrides = new Properties(); -//point the JClouds to the Openstack v 1.1 API endpoint URL -//for swift version 1.4.4 the URL is of the form: http(s)://ip:port/auth -overrides.setProperty(Constants.PROPERTY_ENDPOINT, "https://authurl"); +import static com.google.common.io.Closeables.closeQuietly; -/ get a context with nova that offers the portable ComputeService api -ComputeServiceContext context = new ComputeServiceContextFactory().createContext("nova", user, apiKey, - ImmutableSet.+ +### Compile and Run + + javac -classpath ".:lib/*" JCloudsSwift.java + + java -classpath ".:lib/*" JCloudsSwift + + [logging output] + List Containers + [logging output] + ContainerMetadata{name=...} + ... + +## Next Steps + +1. Try the example above with one of the public clouds. For the Rackspace Cloud init() becomes + +of(new JschSshClientModule()), - overrides); +import java.io.Closeable; +import java.util.Set; -// here's an example of the portable api +import org.jclouds.ContextBuilder; +import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; +import org.jclouds.openstack.swift.CommonSwiftAsyncClient; +import org.jclouds.openstack.swift.CommonSwiftClient; +import org.jclouds.openstack.swift.domain.ContainerMetadata; +import org.jclouds.rest.RestContext; -// run some nodes -nodes = context.getComputeService().client.runNodesInGroup("webserver", 2); +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; -// when you need access to nova-specific features, use the provider-specific context -NovaClient novaClient = NovaClient.class.cast(context.getProviderSpecificContext() - .getApi()); +public class JCloudsSwift implements Closeable { + private BlobStore storage; + private RestContext swift; + public static void main(String[] args) { + JCloudsSwift jCloudsSwift = new JCloudsSwift(); -// Test this code on recent build! -// create a server with a new file called /etc/jclouds.txt and some metadata -Map metadata = ImmutableMap.of("jclouds", "nova"); -int imageId = 2; -int flavorId = 1; -Server server = novaClient.createServer("myservername", imageId, flavorId, - withMetadata(metadata)); + try { + jCloudsSwift.init(); + jCloudsSwift.listContainers(); + jCloudsSwift.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + jCloudsSwift.close(); + } + } + + private void init() { + Iterable modules = ImmutableSet. of( + new SLF4JLoggingModule()); -// list all of my servers including details such as metadata -List servers = novaClient.listServers(withDetails()); + String provider = "swift-keystone"; + String identity = "demo:demo"; // tenantName:userName + String password = "devstack"; // demo account uses ADMIN_PASSWORD too -// list the id and name of my servers that were modified since yesterday -servers = novaClient.listServers(changesSince(yesterday)); + BlobStoreContext context = ContextBuilder.newBuilder(provider) + .endpoint("http://172.16.0.1:5000/v2.0/") + .credentials(identity, password) + .modules(modules) + .buildView(BlobStoreContext.class); + storage = context.getBlobStore(); + swift = context.unwrap(); + } -// list the id and name of images I have access to, starting at index 200 limited to 100 results. -List images = novaClient.listImages(startAt(200).maxResults(100)); + private void listContainers() { + System.out.println("List Containers"); + Set containers = swift.getApi().listContainers(); -context.close(); + for (ContainerMetadata container: containers) { + System.out.println(" " + container); + } + } + + public void close() { + closeQuietly(storage.getContext()); + } +} {% endhighlight %} +
+private void init() { + Iterable+ +1. Try using the `"openstack-cinder"` provider to list volumes (hint: see [VolumeAndSnapshotApiLiveTest.testListVolumes()](https://github.com/jclouds/jclouds/blob/master/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/features/VolumeAndSnapshotApiLiveTest.java)). +1. Have a look at how the optional extensions are handled (hint: see [FloatingIPApiLiveTest.testListFloatingIPs()](https://github.com/jclouds/jclouds/blob/master/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java)). +1. Change the example to do different things that you want to do. +1. Browse the [documentation](http://www.jclouds.org/documentation/) and have a look at the [Javadoc](http://demobox.github.com/jclouds-maven-site/latest/apidocs). +1. Return to the [Installation Guide](http://www.jclouds.org/documentation/userguide/installation-guide/) and have a look at the different ways to integrate jclouds with your project. +1. Join the [jclouds mailing list](https://groups.google.com/forum/?fromgroups#!forum/jclouds) or maybe even the [jclouds developer mailing list](https://groups.google.com/forum/?fromgroups#!forum/jclouds-dev). +## OpenStack Providers -## Known Issues - -This provider is a work in progress. Some issues remain open and are described here. If you are missing some features, - [let us know](http://groups.google.com/group/jclouds?pli=1) Or just [fork](https://github.com/jclouds/jclouds) the code -on github and scratch that itch yourself. - -* No public IP on current Cactus Release: The current version of Openstack API has a shortcoming. - Nova Compute system boots the nodes without a public IP if the vlan network topology is used. - This makes them unreachable from the outside world. And there is no way to assign the public IP to a node using - the Openstack API. There is a patch which adds the additional `auto_assign_floating_ip` parameter to the Nova config. - When this parameter is set to true Nova automatically assigns theIP from the pool of floating IPs to a node after its startup. - This patch has already been submitted to OpenStack. Just take the nighty builds of the Openstack Compute or - use Openstack Cactus packages for RHEL from [here](http://yum.griddynamics.net/)which is also include this patch. - -* Some features are currently not working if KVM hypervisor is used but may work on other hypervisors supported by OpenStack. - It looks that Openstack does not support that features on KVM. - * root password returned in create server call is not the right password. - * image customization by uploading additional files before the instance creation is not working - * injection of an SSH key from the JClouds is not working (but working for the registered user's default key) - -* Request to create image from a running instance returns incorrect JSON output. Possibly a bug in OpenStack. - -* If the node in running status does not have the public IP addresses yet and have only - private address (the public addresses can be assigned a bit later after the node status is changed to running) - then some features of the JClouds are not working, namely: - -* A script can't be executed as a part of node creation process (`TemplateOptions.runScript` attribute). - The node is pinged using the private address and then the node creation process exits on timeout. - * Node creation process can't wait until the ports on node are opened (`TemplateOptions.blockOnPort` attribute). - The reason is the same - private IP address is used. - * Flavor reference is not returned in servers/details/list output by Openstack - (but is returned if the instance details are requested directly in servers/id/details call) and - therefore sometimes node metadata does not have the correct hardware info. - -* The format of the endpoint URL has changed since version 1.4.4 of swift. - It is now of the form: http(s)://ip:port/auth - In previous versions 'auth' was not required. +This is a list of providers that work with OpenStack that you can use to build your Context. +* `"openstack-nova"` +* `"openstack-keystone"` +* `"openstack-cinder"` +* `"swift-keystone"` diff --git a/documentation/quickstart/rackspace.markdown b/documentation/quickstart/rackspace.markdown index d9e4c07..36e31a7 100644 --- a/documentation/quickstart/rackspace.markdown +++ b/documentation/quickstart/rackspace.markdown @@ -1,75 +1,297 @@ --- -layout: docs -title: Quick Start - Rackspace Cloud +layout: jclouds +title: Getting Started - The Rackspace Cloud --- -# Quick Start: Rackspace Cloud +# Getting Started: The Rackspace Cloud -1. Sign up for Rackspace Cloud by going to this [page](https://www.rackspacecloud.com/signup) -2. Login to the portal and get your username and key from [the management portal](https://manage.rackspacecloud.com/Login.do) -3. Ensure you are using a recent JDK 6 -4. Setup your project to include cloudfiles-us,-uk or cloudservers-us,-uk - get the dependency `org.jclouds.provider/cloudfiles-us`, `org.jclouds.provider/cloudfiles-uk`, - `org.jclouds.provider/cloudservers-us`, or `org.jclouds.provider/cloudservers-uk` - using jclouds [Installation](/documentation/userguide/installation-guide). -5. Start coding +1. [Introduction](#intro) +1. [Get a Username and API Key](#account) +1. [Get jclouds](#install) +1. [Terminology](#terminology) +1. [Your First Cloud Files App](#files) +1. [Your First Cloud Servers App](#servers) +1. [Working with Cloud Block Storage](#volumes) +1. [Working with Cloud Load Balancers](#loadbalancers) +1. [Next Steps](#next) +1. [Rackspace Cloud Providers](#providers) +1. [Support and Feedback](#support) -## Cloud Files +## Introduction +The [Rackspace Cloud](http://www.rackspace.com/cloud/public/) platform includes everything you need to build websites and applications that scale servers, storage, networking, APIs, and more. The Rackspace Cloud is based on OpenStack, which is a global collaboration of developers and cloud computing technologists producing the ubiquitous open source cloud computing platform for public and private clouds. -{% highlight java %} -// get a context with rackspace that offers the portable BlobStore api -BlobStoreContext context = new BlobStoreContextFactory().createContext("cloudfiles-us", user, password); +This guide assumes you're familiar with Java and its technologies. To get started you'll need access to the Rackspace cloud and jclouds. -// create a container in the default location -context.getBlobStore().createContainerInLocation(null, container); +## Get a Username and API Key +1. Sign up for free for the [Rackspace Cloud (US)](https://cart.rackspace.com/cloud/). +1. Login to the [Cloud Control Panel (US)](https://mycloud.rackspace.com/). +1. In the top right corner click on your username and then API Keys. -// use the map interface for easy access to put/get things, keySet, etc. -context.createInputStreamMap(container).put("blob.txt", inputStream); +Likewise you can go to the [Rackspace Cloud (UK)](https://buyonline.rackspace.co.uk/cloud/userinfo?type=normal) and login to the [Cloud Control Panel (UK)](https://mycloud.rackspace.co.uk/). -// when you need access to rackspace-specific features, use the provider-specific context -CloudFilesClient rackspaceClient = CloudFilesClient.class.cast(context.getProviderSpecificContext() - .getApi()); +## Get jclouds -// get a cdn uri for the container -URI cdnURI = rackspaceClient.enableCDN(container); +1. Ensure you are using the [Java Development Kit (JDK) version 6 or later](http://www.oracle.com/technetwork/java/javase/downloads/index.html). + * `javac -version` +1. Ensure you are using [Maven version 3 or later](http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html). + * `mvn -version` +1. Create a directory to try out jclouds. + * `mkdir jclouds` + * `cd jclouds` +1. Make a local copy of this [pom.xml](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/pom.xml) file in the jclouds directory. + * mvn dependency:copy-dependencies "-DoutputDirectory=./lib" +1. You should now have a directory with the following structure: + * `jclouds/` + * `pom.xml` + * `lib/` + * `*.jar` -context.close(); -{% endhighlight %} +## Terminology +There are some differences in terminology between jclouds and Rackspace/OpenStack that should be made clear. + +| jclouds | Rackspace/OpenStack | +|---------|---------------------| +| Compute | Cloud Servers (Nova) +| Node | Server +| Location/Zone | Region +| Hardware | Flavor +| NodeMetadata | Server details +| UserMetadata | Metadata +| BlobStore | Cloud Files (Swift) +| Blob | File (Object) + +## Your First Cloud Files App +### Introduction + +[Cloud Files](http://www.rackspace.com/cloud/public/files/) is an easy to use online storage for files and media which can be delivered globally over Akamai's content delivery network (CDN). + +### APIs + +Cloud Files works with a portable layer in jclouds that is used to access features common to all cloud object storage systems. Cloud Files also works with the OpenStack layer in jclouds that is used to access features common to all OpenStack Swift object storage systems. Finally, Cloud Files works with the Rackspace layer in jclouds that is used to access features specific to the Rackspace object storage system. + +1. The portable API for Cloud Files is org.jclouds.blobstore.BlobStore. +1. The OpenStack API for Cloud Files is org.jclouds.openstack.swift.CommonSwiftClient. +1. The Rackspace API for Cloud Files is org.jclouds.cloudfiles.CloudFilesClient. +1. You can find these APIs in the latest [Javadoc](http://demobox.github.com/jclouds-maven-site/latest/apidocs). + +### The Source Code + +1. Create the directory hierarchy org/jclouds/examples/rackspace/cloudfiles/ in your jclouds directory. +1. Create Java source files called CreateContainer.java and Constants.java in the directory above. +1. You should now have a directory with the following structure: + * `jclouds/` + * `pom.xml` + * `lib/` + * `*.jar` + * `org/jclouds/examples/rackspace/cloudfiles/` + * `CreateContainer.java` + * `Constants.java` +1. Open CreateContainer.java for editing. +1. Go to the example code [CreateContainer.java](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudfiles/CreateContainer.java), read it over, and copy the code into your file. +1. Open Constants.java for editing. +1. Go to the example code [Constants.java](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudfiles/Constants.java), read it over, and copy the code into your file. + +### Compile and Run + + javac -classpath ".:lib/*" org/jclouds/examples/rackspace/cloudfiles/CreateContainer.java + + java -classpath ".:lib/*" org.jclouds.examples.rackspace.cloudfiles.CreateContainer myUsername myApiKey + + Create Container + jclouds-example + +## Your First Cloud Servers App +### Introduction + +[Cloud Servers](http://www.rackspace.com/cloud/public/servers/) is an easy to use service that provides on-demand servers that you can use to to build dynamic websites, deliver mobile apps, or crunch big data. + +### APIs + +Cloud Servers works with a portable layer in jclouds that is used to access features common to all cloud compute systems. Cloud Servers also works with the OpenStack layer in jclouds that is used to access features common to all OpenStack Nova compute systems. + +1. The portable API for Cloud Servers is org.jclouds.compute.ComputeService. +1. The OpenStack API for Cloud Servers is the org.jclouds.openstack.nova.v2_0.features.ServerApi. It's accessible via the org.jclouds.openstack.nova.v2_0.NovaApi. +1. You can find these APIs in the latest [Javadoc](http://demobox.github.com/jclouds-maven-site/latest/apidocs). + +### The Source Code + +1. Create the directory hierarchy org/jclouds/examples/rackspace/cloudservers/ in your jclouds directory. +1. Create Java source files called CreateServer.java and Constants.java in the directory above. +1. You should now have a directory with the following structure: + * `jclouds/` + * `pom.xml` + * `lib/` + * `*.jar` + * `org/jclouds/examples/rackspace/cloudservers/` + * `CreateServer.java` + * `Constants.java` +1. Open CreateServer.java for editing. +1. Go to the example code [CreateServer.java](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CreateServer.java), read it over, and copy the code into your file. +1. Open Constants.java for editing. +1. Go to the example code [Constants.java](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/Constants.java), read it over, and copy the code into your file. + +### Compile and Run + + javac -classpath ".:lib/*" org/jclouds/examples/rackspace/cloudservers/CreateServer.java + + java -classpath ".:lib/*" org.jclouds.examples.rackspace.cloudservers.CreateServer myUsername myApiKey + + Images + Image{id=9eb71a23-2c7e-...} + ... + Flavors + Flavor{id=2,...} + ... + Create Server + ..................................................... + ServerCreated{id=b037b1a1-...} + Login IP: 123.123.123.123 Username: root Password: a1b2c3d4 + +## Working with Cloud Block Storage +### Introduction + +[Cloud Block Storage](http://www.rackspace.com/cloud/public/blockstorage/) allows you to create volumes on which to persistently store your data from your servers, even when those servers have been deleted. It delivers consistent performance for your I/O-intensive applications. + +### APIs + +Cloud Block Storage works with the OpenStack layer in jclouds that is used to access features common to all OpenStack Cinder block storage systems. + +1. The OpenStack API for Cloud Block Storage is the org.jclouds.openstack.cinder.v1.CinderApi. All other APIs for working with block storage are accessible via the CinderApi. +1. You can find these APIs in the latest [Javadoc](http://demobox.github.com/jclouds-maven-site/latest/apidocs). + +### The Source Code + +1. Create the directory hierarchy org/jclouds/examples/rackspace/cloudblockstorage/ in your jclouds directory. +1. Create Java source files called CreateVolumeAndAttach.java and Constants.java in the directory above. +1. You should now have a directory with the following structure: + * `jclouds/` + * `pom.xml` + * `lib/` + * `*.jar` + * `org/jclouds/examples/rackspace/cloudblockstorage/` + * `CreateVolumeAndAttach.java` + * `Constants.java` +1. Open CreateVolumeAndAttach.java for editing. +1. Go to the example code [CreateVolumeAndAttach.java](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudblockstorage/CreateVolumeAndAttach.java), read it over, and copy the code into your file. +1. Open Constants.java for editing. +1. Go to the example code [Constants.java](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudblockstorage/Constants.java), read it over, and copy the code into your file. + +### Compile and Run + + javac -classpath ".:lib/*" org/jclouds/examples/rackspace/cloudblockstorage/CreateVolumeAndAttach.java + + java -classpath ".:lib/*" org.jclouds.examples.rackspace.cloudblockstorage.CreateVolumeAndAttach myUsername myApiKey + + Create Server + {id=DFW/8814...} + Login: ssh root@123.123.123.123 + Password: a1b2c3d4 + Create Volume + Volume{id=53d9...} + Create Volume Attachment + VolumeAttachment{id=53d9...} + Mount Volume and Create Filesystem + Exit Status: 0 + List Volumes + ... + +## Working with Cloud Load Balancers +### Introduction + +[Cloud Load Balancers](http://www.rackspace.com/cloud/public/loadbalancers/) distributes workloads across two or more servers, network links, and other resources to maximize throughput, minimize response time, and avoid overload. Rackspace Cloud Load Balancers allow you to quickly load balance multiple Cloud Servers for optimal resource utilization. + +### APIs + +Cloud Load Balancers works with the Rackspace layer in jclouds that is used to access features specific to the Rackspace load balancer system. + +1. The Rackspace API for Cloud Load Balancers is org.jclouds.rackspace.cloudloadbalancers.CloudLoadBalancersApi. All other APIs for working with load balancers are accessible via the CloudLoadBalancersApi. +1. You can find these APIs in the latest [Javadoc](http://demobox.github.com/jclouds-maven-site/latest/apidocs). + +### The Source Code + +1. Create the directory hierarchy org/jclouds/examples/rackspace/cloudloadbalancers/ in your jclouds directory. +1. Create Java source files called CreateLoadBalancerWithExistingServers.java and Constants.java in the directory above. +1. You should now have a directory with the following structure: + * `jclouds/` + * `pom.xml` + * `lib/` + * `*.jar` + * `org/jclouds/examples/rackspace/cloudloadbalancers/` + * `CreateLoadBalancerWithExistingServers.java` + * `Constants.java` +1. Open CreateLoadBalancerWithExistingServers.java for editing. +1. Go to the example code [CreateLoadBalancerWithExistingServers.java](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudloadbalancers/CreateLoadBalancerWithExistingServers.java), read it over, and copy the code into your file. +1. Open Constants.java for editing. +1. Go to the example code [Constants.java](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudloadbalancers/Constants.java), read it over, and copy the code into your file. + +### Compile and Run + + javac -classpath ".:lib/*" org/jclouds/examples/rackspace/cloudloadbalancers/CreateLoadBalancerWithExistingServers.java + + java -classpath ".:lib/*" org.jclouds.examples.rackspace.cloudloadbalancers.CreateLoadBalancerWithExistingServers myUsername myApiKey + + Create Cloud Load Balancer + LoadBalancer{id=85901...} + Go to http://166.78.34.87 + +## jclouds in a Managed Container + +Setting up jclouds to work in a managed container is easy. You simply need to ensure that jclouds won't spawn any of its own threads. You can do this by using the ExecutorServiceModule when building your Context. + +An example code snippet. -## Cloud Servers {% highlight java %} -import static org.jclouds.rackspace.cloudservers-us.options.CreateServerOptions.Builder.withFile; -import static org.jclouds.rackspace.cloudservers-us.options.ListOptions.Builder.*; - -// get a context with rackspace that offers the portable ComputeService api - ComputeServiceContext context = new ComputeServiceContextFactory().createContext("cloudservers-us", accesskeyid, secretkey, - ImmutableSet.modules = ImmutableSet. of(new SLF4JLoggingModule()); + Properties overrides = new Properties(); + overrides.setProperty(KeystoneProperties.CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); + overrides.setProperty(Constants.PROPERTY_API_VERSION, "2"); + + String provider = "openstack-nova"; + String identity = "myUsername"; // userName + String password = "myPassword"; + + ComputeServiceContext context = ContextBuilder.newBuilder(provider) + .endpoint("https://identity.api.rackspacecloud.com/v2.0/") + .credentials(identity, password) + .modules(modules) + .overrides(overrides) + .buildView(ComputeServiceContext.class); + compute = context.getComputeService(); + nova = context.unwrap(); + zones = nova.getApi().getConfiguredZones(); +} +
Provider | +Maven Artifact ID | +ISO 3166 Codes | +
---|---|---|
AWS | +aws-ec2 | +US-VA,US-CA,IE,SG | +
Bluelock | +bluelock-vcloud-zone01 | +US-IN | +
CloudSigma US | +cloudsigma-lvs | +US-NV | +
CloudSigma CH | +cloudsigma-zrh | +CH-ZH | +
ElasticHosts GB | +elastichosts-lon-b | +GB-LND | +
ElasticHosts GB | +elastichosts-lon-p | +GB-LND | +
ElasticHosts US | +elastichosts-sat-p | +US-TX | +
Go2Cloud | +go2cloud-jhb1 | +ZA-GP | +
GoGrid | +gogrid | +US-CA,US-VA | +
Green House Data | +greenhousedata-element-vcloud | +US-WY | +
HP | +hpcloud-compute | +US-NV | +
Ninefold | +ninefold-compute | +AU-NSW | +
OpenHosting | +openhosting-east1 | +US-VA | +
Rackspace UK (First Gen) | +cloudservers-uk | +GB-SLG | +
Rackspace US (First Gen) | +cloudservers-us | +US-IL,US-TX | +
Rackspace UK (Next Gen) | +rackspace-cloudservers-uk | +GB-SLG | +
Rackspace US (Next Gen) | +rackspace-cloudservers-us | +US-IL,US-TX | +
SeverLove | +serverlove-z1-man | +GB-MAN | +
SkaliCloud | +skalicloud-sdg-my | +MY-10 | +
SoftLayer | +softlayer | ++ |
Stratogen | +stratogen-vcloud-mycloud | +GB | +
TRMK | +trmk-ecloud | +US-FL,NL-NH | +
TRMK | +trmk-vcloudexpress | +US-FL | +
TryStack | +trystack-nova | +US-CA | +
Provider | +Maven Artifact ID | +
---|---|
Abiquo | +abiquo | +
AWS | +ec2 | +
Bring Your Own Node | +byon | +
CloudSigma | +cloudsigma | +
CloudStack | +cloudstack | +
ElasticStack | +elasticstack | +
OpenStack | +openstack-nova | +
vCloud | +vcloud | +
Provider | +Maven Artifact ID | +
---|---|
AWS | +aws-s3 | +
CloudOne | +cloudonestorage | +
HP | +hpcloud-objectstorage | +
Microsoft | +azureblob | +
Ninefold | +ninefold-storage | +
Rackspace US | +cloudfiles-us | +
Rackspace UK | +cloudfiles-uk | +
Synaptic | +synaptic-storage | +
Provider | +Maven Artifact ID | +
---|---|
Atmos | +atmos | +
AWS | +s3 | +
Filesystem | +filesystem | +
OpenStack | +swift | +
Rackspace | +cloudfiles | +