diff --git a/compute/src/main/clojure/org/jclouds/compute.clj b/compute/src/main/clojure/org/jclouds/compute.clj index b5fabed98f..5540b13c33 100644 --- a/compute/src/main/clojure/org/jclouds/compute.clj +++ b/compute/src/main/clojure/org/jclouds/compute.clj @@ -20,7 +20,7 @@ "A clojure binding to the jclouds ComputeService. Current supported services are: - [ec2, rimuhosting, terremark, vcloud, bluelock, ibmdev, hostingdotcom] + [ec2, rimuhosting, cloudservers, terremark, vcloud, bluelock, ibmdev, hostingdotcom] Here's an example of getting some compute configuration from rackspace: diff --git a/ibmdev/src/main/java/org/jclouds/ibmdev/options/CreateInstanceOptions.java b/ibmdev/src/main/java/org/jclouds/ibmdev/options/CreateInstanceOptions.java index 5ba7a3a3e2..630ef95f4b 100644 --- a/ibmdev/src/main/java/org/jclouds/ibmdev/options/CreateInstanceOptions.java +++ b/ibmdev/src/main/java/org/jclouds/ibmdev/options/CreateInstanceOptions.java @@ -20,6 +20,9 @@ package org.jclouds.ibmdev.options; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Map; +import java.util.Map.Entry; + import org.jclouds.http.options.BaseHttpRequestOptions; /** @@ -66,6 +69,20 @@ public class CreateInstanceOptions extends BaseHttpRequestOptions { return this; } + /** + * + * @param configurationData + * extra configuration to pass to the instance + */ + public CreateInstanceOptions configurationData(Map configurationData) { + checkNotNull(configurationData, "configurationData"); + for (Entry entry : configurationData.entrySet()) { + formParameters.removeAll(entry.getKey()); + formParameters.put(entry.getKey(), entry.getValue()); + } + return this; + } + /** * * @param id @@ -80,6 +97,14 @@ public class CreateInstanceOptions extends BaseHttpRequestOptions { public static class Builder { + /** + * @see CreateInstanceOptions#configurationData(Map ) + */ + public static CreateInstanceOptions configurationData(Map configurationData) { + CreateInstanceOptions options = new CreateInstanceOptions(); + return options.configurationData(configurationData); + } + /** * @see CreateInstanceOptions#mountVolume(String, String ) */ diff --git a/ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudAsyncClientTest.java b/ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudAsyncClientTest.java index a6ee31dbf2..e340d6e406 100644 --- a/ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudAsyncClientTest.java +++ b/ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudAsyncClientTest.java @@ -57,6 +57,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.inject.Module; import com.google.inject.TypeLiteral; @@ -528,15 +529,18 @@ public class IBMDeveloperCloudAsyncClientTest extends RestClientTest httpRequest = processor.createRequest( method, "location", "name", "22", "instanceType", new CreateInstanceOptions() - .attachIp("1").authorizePublicKey("MOO").mountVolume("2", "/mnt")); + .attachIp("1").authorizePublicKey("MOO").mountVolume("2", "/mnt").configurationData( + ImmutableMap.of("insight_admin_password", "myPassword1", + "db2_admin_password", "myPassword2", "report_user_password", + "myPassword3"))); assertRequestLineEquals(httpRequest, "POST https://www-180.ibm.com/cloud/enterprise/beta/api/rest/20090403/instances HTTP/1.1"); assertHeadersEqual(httpRequest, - "Accept: application/json\nContent-Length: 122\nContent-Type: application/x-www-form-urlencoded\n"); + "Accept: application/json\nContent-Length: 221\nContent-Type: application/x-www-form-urlencoded\n"); assertPayloadEquals( httpRequest, - "location=location&imageID=22&name=name&instanceType=instanceType&ip=1&publicKey=MOO&volumeID=2&oss.storage.id.2.mnt=%2Fmnt"); + "location=location&imageID=22&name=name&instanceType=instanceType&ip=1&publicKey=MOO&volumeID=2&oss.storage.id.2.mnt=%2Fmnt&insight_admin_password=myPassword1&db2_admin_password=myPassword2&report_user_password=myPassword3"); assertResponseParserClassEquals(method, httpRequest, ParseInstanceFromJson.class); assertSaxResponseParserClassEquals(method, null); diff --git a/ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudClientLiveTest.java b/ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudClientLiveTest.java index c19b08e3ff..5b4b4d6147 100644 --- a/ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudClientLiveTest.java +++ b/ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudClientLiveTest.java @@ -110,7 +110,7 @@ public class IBMDeveloperCloudClientLiveTest { @Test public void testListInstancesFromRequestReturnsNull() throws Exception { - Set response = connection.listInstancesFromRequest(Long.MAX_VALUE+""); + Set response = connection.listInstancesFromRequest(Long.MAX_VALUE + ""); assertNull(response); } @@ -275,7 +275,7 @@ public class IBMDeveloperCloudClientLiveTest { assert (allVolumes.contains(volume)) : String.format("volume %s not in %s", volume, volume); } - private static final String IMAGE_ID = "3";// RHEL + private static final String IMAGE_ID = "11";// Rational Insight /** * cannot run an instance due to 500 errors: @@ -286,9 +286,12 @@ public class IBMDeveloperCloudClientLiveTest { @Test(expectedExceptions = HttpResponseException.class, dependsOnMethods = { "testAddPublicKey", "testAllocateIpAddress", "testCreateVolume" }) public void testCreateInstanceWithOptions() throws Exception { - instance = connection.createInstanceInLocation(location.getId(), TAG, IMAGE_ID, "SMALL", + instance = connection.createInstanceInLocation(location.getId(), TAG, IMAGE_ID, "LARGE", attachIp(ip.getId()).authorizePublicKey(key.getName()).mountVolume(volume.getId(), - "/mnt")); + "/mnt").configurationData( + ImmutableMap.of("insight_admin_password", "myPassword1", + "db2_admin_password", "myPassword2", "report_user_password", + "myPassword3"))); assertEquals(instance.getLocation(), location.getId()); assertNotNull(instance.getHostname()); assertEquals(instance.getIp(), ip.getIp());