Skip to content
Permalink
Browse files
Consolidate zone to make it easier to change the zone when running th…
…e examples.
  • Loading branch information
Everett Toews committed Nov 14, 2013
1 parent 0d99205 commit 17817b5892afb1fbcd3af7a192f0b6cf491ec0f6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 24 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.cbs", "DFW");
public static final String ZONE = System.getProperty("zone", "DFW");

public static final String NAME = "jclouds-example";
public static final String POLL_PERIOD_TWENTY_SECONDS = String.valueOf(SECONDS.toMillis(20));
@@ -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.cdb", "DFW");
public static final String ZONE = System.getProperty("zone", "DFW");

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.cf", "DFW");
public static final String ZONE = System.getProperty("zone", "DFW");

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.clb", "DFW");
public static final String ZONE = System.getProperty("zone", "DFW");

public static final String NAME = "jclouds-example";
}
@@ -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.cs", "DFW");
public static final String ZONE = System.getProperty("zone", "DFW");

public static final String NAME = "jclouds-example";
public static final String POLL_PERIOD_TWENTY_SECONDS = String.valueOf(SECONDS.toMillis(20));
@@ -27,7 +27,6 @@
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Template;
import org.jclouds.domain.Location;

import java.io.Closeable;
import java.io.IOException;
@@ -96,7 +95,7 @@ private void createServer() throws RunNodesException, TimeoutException {
System.out.format("Create Server%n");

Template template = computeService.templateBuilder()
.locationId(getLocationId())
.locationId(ZONE)
.fromHardware(getHardware())
.fromImage(getImage())
.build();
@@ -114,23 +113,6 @@ private void createServer() throws RunNodesException, TimeoutException {
System.out.format(" Password: %s%n", nodeMetadata.getCredentials().getPassword());
}

/**
* This method uses the generic ComputeService.listAssignableLocations() to find the location.
*
* @return The first available Location
*/
private String getLocationId() {
System.out.format(" Locations%n");

Set<? extends Location> locations = computeService.listAssignableLocations();

for (Location location: locations) {
System.out.format(" %s%n", location);
}

return locations.iterator().next().getId();
}

/**
* This method uses the generic ComputeService.listHardwareProfiles() to find the hardware profile.
*

0 comments on commit 17817b5

Please sign in to comment.