Issue 230: added configurationData entry to ibmdev support

This commit is contained in:
Adrian Cole 2010-06-08 01:15:27 -07:00
parent 8b9d1682a7
commit f283b072e9
4 changed files with 40 additions and 8 deletions

View File

@ -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:

View File

@ -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<String, String> configurationData) {
checkNotNull(configurationData, "configurationData");
for (Entry<String, String> 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<String, String> )
*/
public static CreateInstanceOptions configurationData(Map<String, String> configurationData) {
CreateInstanceOptions options = new CreateInstanceOptions();
return options.configurationData(configurationData);
}
/**
* @see CreateInstanceOptions#mountVolume(String, String )
*/

View File

@ -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<IBMDevelope
CreateInstanceOptions[].class);
GeneratedHttpRequest<IBMDeveloperCloudAsyncClient> 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);

View File

@ -110,7 +110,7 @@ public class IBMDeveloperCloudClientLiveTest {
@Test
public void testListInstancesFromRequestReturnsNull() throws Exception {
Set<? extends Instance> response = connection.listInstancesFromRequest(Long.MAX_VALUE+"");
Set<? extends Instance> 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());