Skip to content
Permalink
Browse files
Setup examples to use Rackspace performance flavors.
  • Loading branch information
Everett Toews committed Nov 14, 2013
1 parent 17817b5 commit f5f038cc4c92c85fb8bc61c7ca8a591b7b2dacad
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
@@ -29,7 +29,7 @@ public interface Constants {
// The provider configures jclouds To use the Rackspace Cloud (US)
// To use the Rackspace Cloud (UK) set the system property or default value to "rackspace-cloudblockstorage-uk"
public static final String PROVIDER = System.getProperty("provider.cbs", "rackspace-cloudblockstorage-us");
public static final String ZONE = System.getProperty("zone", "DFW");
public static final String ZONE = System.getProperty("zone", "IAD");

public static final String NAME = "jclouds-example";
public static final String POLL_PERIOD_TWENTY_SECONDS = String.valueOf(SECONDS.toMillis(20));
@@ -38,6 +38,7 @@
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentApi;
import org.jclouds.rest.RestContext;
import org.jclouds.scriptbuilder.ScriptBuilder;
@@ -121,10 +122,12 @@ public CreateVolumeAndAttach(String username, String apiKey) {
private NodeMetadata createServer() throws RunNodesException, TimeoutException {
System.out.format("Create Server%n");

ZoneAndId zoneAndId = ZoneAndId.fromZoneAndId(ZONE, "performance1-1");
Template template = computeService.templateBuilder()
.locationId(ZONE)
.osDescriptionMatches(".*CentOS 6.4.*")
.minRam(512).build();
.hardwareId(zoneAndId.slashEncode())
.build();

Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup(NAME, 1, template);
NodeMetadata nodeMetadata = nodes.iterator().next();
@@ -27,7 +27,7 @@ public interface Constants {
// The provider configures jclouds To use the Rackspace Cloud (US)
// To use the Rackspace Cloud (UK) set the system property or default value to "rackspace-clouddatabases-uk"
public static final String PROVIDER = System.getProperty("provider.cdb", "rackspace-clouddatabases-us");
public static final String ZONE = System.getProperty("zone", "DFW");
public static final String ZONE = System.getProperty("zone", "IAD");

public static final String NAME = "jclouds-example";
public static final String PASSWORD = "0192j41dm311iaadjaoqpvplw";
@@ -27,7 +27,7 @@ public interface Constants {
// The provider configures jclouds To use the Rackspace Cloud (US)
// To use the Rackspace Cloud (UK) set the system property or default value to "cloudfiles-uk"
public static final String PROVIDER = System.getProperty("provider.cf", "cloudfiles-us");
public static final String ZONE = System.getProperty("zone", "DFW");
public static final String ZONE = System.getProperty("zone", "IAD");

public static final String CONTAINER_PUBLISH = "jclouds-example-publish";
public static final String CONTAINER = "jclouds-example";
@@ -28,7 +28,7 @@ public interface Constants {
// The provider configures jclouds To use the Rackspace Cloud (US)
// To use the Rackspace Cloud (UK) set the system property or default value to "rackspace-cloudloadbalancers-uk"
public static final String PROVIDER = System.getProperty("provider.clb", "rackspace-cloudloadbalancers-us");
public static final String ZONE = System.getProperty("zone", "DFW");
public static final String ZONE = System.getProperty("zone", "IAD");

public static final String NAME = "jclouds-example";
}
@@ -30,6 +30,7 @@
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.scriptbuilder.ScriptBuilder;
import org.jclouds.scriptbuilder.domain.OsFamily;
@@ -112,10 +113,11 @@ public CloudServersPublish(List<String> args) {
private Set<? extends NodeMetadata> createServer() throws RunNodesException, TimeoutException {
System.out.format("Create Server%n");

ZoneAndId zoneAndId = ZoneAndId.fromZoneAndId(ZONE, "performance1-1");
Template template = computeService.templateBuilder()
.locationId(ZONE)
.osDescriptionMatches(".*CentOS 6.4.*")
.minRam(512)
.hardwareId(zoneAndId.slashEncode())
.build();

// This method will continue to poll for the server status and won't return until this server is ACTIVE
@@ -29,7 +29,7 @@ public interface Constants {
// The provider configures jclouds To use the Rackspace Cloud (US)
// To use the Rackspace Cloud (UK) set the system property or default value to "rackspace-cloudservers-uk"
public static final String PROVIDER = System.getProperty("provider.cs", "rackspace-cloudservers-us");
public static final String ZONE = System.getProperty("zone", "DFW");
public static final String ZONE = System.getProperty("zone", "IAD");

public static final String NAME = "jclouds-example";
public static final String POLL_PERIOD_TWENTY_SECONDS = String.valueOf(SECONDS.toMillis(20));
@@ -39,7 +39,7 @@
import static org.jclouds.examples.rackspace.cloudservers.Constants.*;

/**
* This example creates an Ubuntu 12.04 server with 512 MB of RAM on the Rackspace Cloud.
* This example creates an Ubuntu 12.04 server with 1024 MB of RAM on the Rackspace Cloud.
*
* @author Everett Toews
*/
@@ -88,7 +88,7 @@ public CreateServer(String username, String apiKey) {
* .locationId(getLocationId())
* .osFamily(OsFamily.UBUNTU)
* .osVersionMatches("12.04")
* .minRam(512)
* .minRam(1024)
* .build();
*/
private void createServer() throws RunNodesException, TimeoutException {
@@ -116,7 +116,7 @@ private void createServer() throws RunNodesException, TimeoutException {
/**
* This method uses the generic ComputeService.listHardwareProfiles() to find the hardware profile.
*
* @return The Hardware with 512 MB of RAM
* @return The Hardware with 1024 MB of RAM
*/
private Hardware getHardware() {
System.out.format(" Hardware Profiles (Flavors)%n");
@@ -126,13 +126,13 @@ private Hardware getHardware() {

for (Hardware profile: profiles) {
System.out.format(" %s%n", profile);
if (profile.getRam() == 512) {
if (profile.getProviderId().equals("performance1-1")) {
result = profile;
}
}

if (result == null) {
System.err.println("Flavor with 512 MB of RAM not found. Using first flavor found.%n");
System.err.println("Performance 1-1 flavor not found. Using first flavor found.%n");
result = profiles.iterator().next();
}

0 comments on commit f5f038c

Please sign in to comment.