Merge remote branch 'origin'

Conflicts:
	tools/antcontrib/samples/compute/build.xml
This commit is contained in:
Andrew Phillips 2010-10-06 11:48:12 +02:00
commit 7a459aaf77
10 changed files with 215 additions and 107 deletions

View File

@ -23,7 +23,7 @@ jclouds is an open source framework that helps you get started in the cloud
and reuse your java and clojure development skills. Our api allows you to and reuse your java and clojure development skills. Our api allows you to
freedom to use portable abstractions or cloud-specific features. freedom to use portable abstractions or cloud-specific features.
our current version is 1.0-beta-6 our current version is 1.0-beta-7
our dev version is 1.0-SNAPSHOT our dev version is 1.0-SNAPSHOT
our compute api supports: ec2, gogrid, rackspace, rimuhosting, vcloud, trmk-ecloud, our compute api supports: ec2, gogrid, rackspace, rimuhosting, vcloud, trmk-ecloud,
@ -98,13 +98,13 @@ Compute Example (Clojure):
(run-nodes "mycluster" 2)) (run-nodes "mycluster" 2))
Downloads: Downloads:
* distribution zip: http://jclouds.googlecode.com/files/jclouds-1.0-beta-6.zip * distribution zip: http://jclouds.googlecode.com/files/jclouds-1.0-beta-7.zip
* maven repo: http://jclouds.googlecode.com/svn/repo * maven repo: http://jclouds.googlecode.com/svn/repo
* snapshot repo: http://jclouds.rimuhosting.com/maven2/snapshots * snapshot repo: http://jclouds.rimuhosting.com/maven2/snapshots
Links: Links:
* project page: http://code.google.com/p/jclouds/ * project page: http://code.google.com/p/jclouds/
* javadocs (1.0-beta-6): http://jclouds.rimuhosting.com/apidocs/ * javadocs (1.0-beta-7): http://jclouds.rimuhosting.com/apidocs/
* javadocs (1.0-SNAPSHOT): http://jclouds.rimuhosting.com/apidocs-SNAPSHOT/ * javadocs (1.0-SNAPSHOT): http://jclouds.rimuhosting.com/apidocs-SNAPSHOT/
* community: http://code.google.com/p/jclouds/wiki/AppsThatUseJClouds * community: http://code.google.com/p/jclouds/wiki/AppsThatUseJClouds
* user group: http://groups.google.com/group/jclouds * user group: http://groups.google.com/group/jclouds

View File

@ -75,6 +75,8 @@ public class EC2TemplateBuilderImpl extends TemplateBuilderImpl {
eTo.subnetId(eFrom.getSubnetId()); eTo.subnetId(eFrom.getSubnetId());
if (eFrom.isMonitoringEnabled()) if (eFrom.isMonitoringEnabled())
eTo.enableMonitoring(); eTo.enableMonitoring();
if (eFrom.getUserData() != null)
eTo.userData(eFrom.getUserData());
} }
} }

View File

@ -62,6 +62,7 @@ public class EC2TemplateOptions extends TemplateOptions {
private String placementGroup = null; private String placementGroup = null;
private boolean noPlacementGroup; private boolean noPlacementGroup;
private String subnetId; private String subnetId;
private byte[] userData;
public static final EC2TemplateOptions NONE = new EC2TemplateOptions(); public static final EC2TemplateOptions NONE = new EC2TemplateOptions();
@ -94,6 +95,17 @@ public class EC2TemplateOptions extends TemplateOptions {
return this; return this;
} }
/**
* Unencoded data
*/
public EC2TemplateOptions userData(byte[] unencodedData) {
checkArgument(checkNotNull(unencodedData, "unencodedData").length <= 16 * 1024,
"userData cannot be larger than 16kb");
this.userData = unencodedData;
return this;
}
/** /**
* Specifies the keypair used to run instances with * Specifies the keypair used to run instances with
*/ */
@ -170,6 +182,14 @@ public class EC2TemplateOptions extends TemplateOptions {
return EC2TemplateOptions.class.cast(options.keyPair(keyPair)); return EC2TemplateOptions.class.cast(options.keyPair(keyPair));
} }
/**
* @see EC2TemplateOptions#userData
*/
public static EC2TemplateOptions userData(byte[] unencodedData) {
EC2TemplateOptions options = new EC2TemplateOptions();
return EC2TemplateOptions.class.cast(options.userData(unencodedData));
}
/** /**
* @see EC2TemplateOptions#noKeyPair * @see EC2TemplateOptions#noKeyPair
*/ */
@ -436,6 +456,13 @@ public class EC2TemplateOptions extends TemplateOptions {
return subnetId; return subnetId;
} }
/**
* @return unencoded user data.
*/
public byte[] getUserData() {
return userData;
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
@ -447,6 +474,7 @@ public class EC2TemplateOptions extends TemplateOptions {
result = prime * result + (monitoringEnabled ? 1231 : 1237); result = prime * result + (monitoringEnabled ? 1231 : 1237);
result = prime * result + ((placementGroup == null) ? 0 : placementGroup.hashCode()); result = prime * result + ((placementGroup == null) ? 0 : placementGroup.hashCode());
result = prime * result + ((subnetId == null) ? 0 : subnetId.hashCode()); result = prime * result + ((subnetId == null) ? 0 : subnetId.hashCode());
result = prime * result + ((userData == null) ? 0 : userData.hashCode());
return result; return result;
} }
@ -485,6 +513,11 @@ public class EC2TemplateOptions extends TemplateOptions {
return false; return false;
} else if (!subnetId.equals(other.subnetId)) } else if (!subnetId.equals(other.subnetId))
return false; return false;
if (userData == null) {
if (other.userData != null)
return false;
} else if (!userData.equals(other.userData))
return false;
return true; return true;
} }

View File

@ -106,6 +106,11 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions
if (placementGroupName != null) if (placementGroupName != null)
instanceOptions.inPlacementGroup(placementGroupName); instanceOptions.inPlacementGroup(placementGroupName);
byte[] userData = EC2TemplateOptions.class.cast(template.getOptions()).getUserData();
if (userData != null)
instanceOptions.withUserData(userData);
return instanceOptions; return instanceOptions;
} }

View File

@ -43,6 +43,7 @@ import org.jclouds.aws.ec2.domain.PlacementGroup;
import org.jclouds.aws.ec2.options.RunInstancesOptions; import org.jclouds.aws.ec2.options.RunInstancesOptions;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.encryption.internal.Base64;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
@ -65,16 +66,16 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// create mocks // create mocks
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock( CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class, new Method[] { CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod( new Method[] {
"createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class), "createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod( TemplateOptions.class),
"createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class), "createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class TemplateOptions.class),
.getDeclaredMethod("getSecurityGroupsForTagAndOptions", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class) }); "getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
EC2TemplateOptions options = createMock(EC2TemplateOptions.class); EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
Template template = createMock(Template.class); Template template = createMock(Template.class);
@ -83,9 +84,10 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
expect(template.getHardware()).andReturn(size).atLeastOnce(); expect(template.getHardware()).andReturn(size).atLeastOnce();
expect(template.getOptions()).andReturn(options).atLeastOnce(); expect(template.getOptions()).andReturn(options).atLeastOnce();
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn( expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
systemGeneratedKeyPairName); systemGeneratedKeyPairName);
expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups); expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups);
expect(options.getSubnetId()).andReturn(null); expect(options.getSubnetId()).andReturn(null);
expect(options.getUserData()).andReturn(null);
// replay mocks // replay mocks
replay(options); replay(options);
@ -95,9 +97,10 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// run // run
RunInstancesOptions runOptions = strategy.execute(region, tag, template); RunInstancesOptions runOptions = strategy.execute(region, tag, template);
assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildFormParameters().entries(), ImmutableMultimap.<String, String> of("InstanceType", assertEquals(
size.getProviderId(), "AdditionalInfo", tag, "SecurityGroup.1", generatedGroup, "KeyName", runOptions.buildFormParameters().entries(),
systemGeneratedKeyPairName).entries()); ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
"SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName).entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildStringPayload(), null); assertEquals(runOptions.buildStringPayload(), null);
@ -119,16 +122,16 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// create mocks // create mocks
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock( CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class, new Method[] { CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod( new Method[] {
"createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class), "createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod( TemplateOptions.class),
"createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class), "createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class TemplateOptions.class),
.getDeclaredMethod("getSecurityGroupsForTagAndOptions", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class) }); "getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
EC2TemplateOptions options = createMock(EC2TemplateOptions.class); EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
Template template = createMock(Template.class); Template template = createMock(Template.class);
@ -137,11 +140,12 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
expect(template.getHardware()).andReturn(size).atLeastOnce(); expect(template.getHardware()).andReturn(size).atLeastOnce();
expect(template.getOptions()).andReturn(options).atLeastOnce(); expect(template.getOptions()).andReturn(options).atLeastOnce();
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn( expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
systemGeneratedKeyPairName); systemGeneratedKeyPairName);
expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn( expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
generatedGroup); generatedGroup);
expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups); expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups);
expect(options.getSubnetId()).andReturn(null); expect(options.getSubnetId()).andReturn(null);
expect(options.getUserData()).andReturn(null);
// replay mocks // replay mocks
replay(options); replay(options);
@ -151,9 +155,11 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// run // run
RunInstancesOptions runOptions = strategy.execute(region, tag, template); RunInstancesOptions runOptions = strategy.execute(region, tag, template);
assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildFormParameters().entries(), ImmutableMultimap.<String, String> of("InstanceType", assertEquals(
size.getProviderId(), "AdditionalInfo", tag, "SecurityGroup.1", generatedGroup, "KeyName", runOptions.buildFormParameters().entries(),
systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup).entries()); ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
"SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName",
generatedGroup).entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildStringPayload(), null); assertEquals(runOptions.buildStringPayload(), null);
@ -175,16 +181,16 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// create mocks // create mocks
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock( CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class, new Method[] { CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod( new Method[] {
"createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class), "createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod( TemplateOptions.class),
"createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class), "createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class TemplateOptions.class),
.getDeclaredMethod("getSecurityGroupsForTagAndOptions", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class) }); "getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
EC2TemplateOptions options = createMock(EC2TemplateOptions.class); EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
Template template = createMock(Template.class); Template template = createMock(Template.class);
@ -193,11 +199,12 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
expect(template.getHardware()).andReturn(size).atLeastOnce(); expect(template.getHardware()).andReturn(size).atLeastOnce();
expect(template.getOptions()).andReturn(options).atLeastOnce(); expect(template.getOptions()).andReturn(options).atLeastOnce();
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn( expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
systemGeneratedKeyPairName); systemGeneratedKeyPairName);
expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn( expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
generatedGroup); generatedGroup);
expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups); expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups);
expect(options.getSubnetId()).andReturn(null); expect(options.getSubnetId()).andReturn(null);
expect(options.getUserData()).andReturn(null);
// replay mocks // replay mocks
replay(options); replay(options);
@ -207,9 +214,11 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// run // run
RunInstancesOptions runOptions = strategy.execute(region, tag, template); RunInstancesOptions runOptions = strategy.execute(region, tag, template);
assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildFormParameters().entries(), ImmutableMultimap.<String, String> of("InstanceType", assertEquals(
size.getProviderId(), "AdditionalInfo", tag, "SecurityGroup.1", generatedGroup, "KeyName", runOptions.buildFormParameters().entries(),
systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup).entries()); ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
"SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName",
generatedGroup).entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildStringPayload(), null); assertEquals(runOptions.buildStringPayload(), null);
@ -229,16 +238,16 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// create mocks // create mocks
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock( CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class, new Method[] { CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod( new Method[] {
"createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class), "createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod( TemplateOptions.class),
"createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class), "createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class TemplateOptions.class),
.getDeclaredMethod("getSecurityGroupsForTagAndOptions", String.class, String.class, CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
TemplateOptions.class) }); "getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
EC2TemplateOptions options = createMock(EC2TemplateOptions.class); EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
Template template = createMock(Template.class); Template template = createMock(Template.class);
@ -247,8 +256,9 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
expect(template.getHardware()).andReturn(size).atLeastOnce(); expect(template.getHardware()).andReturn(size).atLeastOnce();
expect(template.getOptions()).andReturn(options).atLeastOnce(); expect(template.getOptions()).andReturn(options).atLeastOnce();
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn( expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
systemGeneratedKeyPairName); systemGeneratedKeyPairName);
expect(options.getSubnetId()).andReturn("1"); expect(options.getSubnetId()).andReturn("1");
expect(options.getUserData()).andReturn(null);
// replay mocks // replay mocks
replay(options); replay(options);
@ -258,9 +268,66 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// run // run
RunInstancesOptions runOptions = strategy.execute(region, tag, template); RunInstancesOptions runOptions = strategy.execute(region, tag, template);
assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildFormParameters().entries(), ImmutableMultimap.<String, String> of("InstanceType", assertEquals(
size.getProviderId(), "AdditionalInfo", tag, "SubnetId", "1", "KeyName", systemGeneratedKeyPairName) runOptions.buildFormParameters().entries(),
.entries()); ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
"SubnetId", "1", "KeyName", systemGeneratedKeyPairName).entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildStringPayload(), null);
// verify mocks
verify(options);
verify(template);
verify(strategy);
}
public void testExecuteWithUserData() throws SecurityException, NoSuchMethodException {
// setup constants
String region = Region.AP_SOUTHEAST_1;
String tag = "tag";
EC2Hardware size = EC2Hardware.M1_SMALL;
String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
String generatedGroup = "group";
Set<String> generatedGroups = ImmutableSet.of(generatedGroup);
// create mocks
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
new Method[] {
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
"createNewKeyPairUnlessUserSpecifiedOtherwise", String.class, String.class,
TemplateOptions.class),
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
"createNewPlacementGroupUnlessUserSpecifiedOtherwise", String.class, String.class,
TemplateOptions.class),
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class.getDeclaredMethod(
"getSecurityGroupsForTagAndOptions", String.class, String.class, TemplateOptions.class) });
EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
Template template = createMock(Template.class);
// setup expectations
expect(template.getHardware()).andReturn(size).atLeastOnce();
expect(template.getOptions()).andReturn(options).atLeastOnce();
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
systemGeneratedKeyPairName);
expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups);
expect(options.getSubnetId()).andReturn(null);
expect(options.getUserData()).andReturn("hello".getBytes());
// replay mocks
replay(options);
replay(template);
replay(strategy);
// run
RunInstancesOptions runOptions = strategy.execute(region, tag, template);
assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap.<String, String> of());
assertEquals(
runOptions.buildFormParameters().entries(),
ImmutableMultimap.<String, String> of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
"SecurityGroup.1", "group", "KeyName", systemGeneratedKeyPairName, "UserData", Base64.encodeBytes("hello".getBytes())).entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap.<String, String> of()); assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
assertEquals(runOptions.buildStringPayload(), null); assertEquals(runOptions.buildStringPayload(), null);
@ -318,7 +385,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
expect(strategy.createUniqueKeyPair.apply(new RegionAndName(region, tag))).andReturn(keyPair); expect(strategy.createUniqueKeyPair.apply(new RegionAndName(region, tag))).andReturn(keyPair);
expect(keyPair.getKeyName()).andReturn(systemGeneratedKeyPairName).atLeastOnce(); expect(keyPair.getKeyName()).andReturn(systemGeneratedKeyPairName).atLeastOnce();
expect(strategy.credentialsMap.put(new RegionAndName(region, systemGeneratedKeyPairName), keyPair)).andReturn( expect(strategy.credentialsMap.put(new RegionAndName(region, systemGeneratedKeyPairName), keyPair)).andReturn(
null); null);
// replay mocks // replay mocks
replay(options); replay(options);
@ -327,7 +394,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// run // run
assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options), assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options),
systemGeneratedKeyPairName); systemGeneratedKeyPairName);
// verify mocks // verify mocks
verify(options); verify(options);
@ -385,7 +452,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce(); expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce(); expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup, RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
ports, shouldAuthorizeSelf); ports, shouldAuthorizeSelf);
expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted); expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted);
expect(strategy.createSecurityGroupIfNeeded.apply(regionNameAndIngressRules)).andReturn(generatedMarkerGroup); expect(strategy.createSecurityGroupIfNeeded.apply(regionNameAndIngressRules)).andReturn(generatedMarkerGroup);
expect(strategy.securityGroupMap.put(regionNameAndIngressRules, generatedMarkerGroup)).andReturn(null); expect(strategy.securityGroupMap.put(regionNameAndIngressRules, generatedMarkerGroup)).andReturn(null);
@ -421,7 +488,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce(); expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce(); expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup, RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
ports, shouldAuthorizeSelf); ports, shouldAuthorizeSelf);
expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted); expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted);
expect(strategy.createSecurityGroupIfNeeded.apply(regionNameAndIngressRules)).andReturn(generatedMarkerGroup); expect(strategy.createSecurityGroupIfNeeded.apply(regionNameAndIngressRules)).andReturn(generatedMarkerGroup);
expect(strategy.securityGroupMap.put(regionNameAndIngressRules, generatedMarkerGroup)).andReturn(null); expect(strategy.securityGroupMap.put(regionNameAndIngressRules, generatedMarkerGroup)).andReturn(null);
@ -457,7 +524,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce(); expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce(); expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup, RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
ports, shouldAuthorizeSelf); ports, shouldAuthorizeSelf);
expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted); expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted);
// replay mocks // replay mocks
@ -490,7 +557,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// setup expectations // setup expectations
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce(); expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup, RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
ports, shouldAuthorizeSelf); // note ports, shouldAuthorizeSelf); // note
// this // this
// works // works
// since // since
@ -531,7 +598,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// run // run
assertEquals(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options), assertEquals(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options),
userSuppliedPlacementGroup); userSuppliedPlacementGroup);
// verify mocks // verify mocks
verify(options); verify(options);
@ -556,9 +623,9 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
expect(options.shouldAutomaticallyCreatePlacementGroup()).andReturn(shouldAutomaticallyCreatePlacementGroup); expect(options.shouldAutomaticallyCreatePlacementGroup()).andReturn(shouldAutomaticallyCreatePlacementGroup);
expect(strategy.placementGroupMap.containsKey(new RegionAndName(region, generatedMarkerGroup))).andReturn(false); expect(strategy.placementGroupMap.containsKey(new RegionAndName(region, generatedMarkerGroup))).andReturn(false);
expect(strategy.createPlacementGroupIfNeeded.apply(new RegionAndName(region, generatedMarkerGroup))).andReturn( expect(strategy.createPlacementGroupIfNeeded.apply(new RegionAndName(region, generatedMarkerGroup))).andReturn(
generatedMarkerGroup); generatedMarkerGroup);
expect(strategy.placementGroupMap.put(new RegionAndName(region, generatedMarkerGroup), generatedMarkerGroup)) expect(strategy.placementGroupMap.put(new RegionAndName(region, generatedMarkerGroup), generatedMarkerGroup))
.andReturn(null); .andReturn(null);
// replay mocks // replay mocks
replay(options); replay(options);
@ -566,7 +633,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
// run // run
assertEquals(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options), assertEquals(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options),
generatedMarkerGroup); generatedMarkerGroup);
// verify mocks // verify mocks
verify(options); verify(options);
@ -623,7 +690,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded = createMock(CreatePlacementGroupIfNeeded.class); CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded = createMock(CreatePlacementGroupIfNeeded.class);
return new CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(credentialsMap, securityGroupMap, return new CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(credentialsMap, securityGroupMap,
placementGroupMap, createUniqueKeyPair, createSecurityGroupIfNeeded, createPlacementGroupIfNeeded); placementGroupMap, createUniqueKeyPair, createSecurityGroupIfNeeded, createPlacementGroupIfNeeded);
} }
private void replayStrategy(CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy) { private void replayStrategy(CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy) {

View File

@ -238,44 +238,44 @@
<configuration> <configuration>
<systemProperties> <systemProperties>
<property> <property>
<name>twitter.identity</name> <name>test.twitter.identity</name>
<value>${jclouds.twitter.user}</value> <value>${test.twitter.identity}</value>
</property> </property>
<property> <property>
<name>twitter.credential</name> <name>test.twitter.credential</name>
<value>${jclouds.twitter.password}</value> <value>${test.twitter.credential}</value>
</property> </property>
<property> <property>
<name>azureblob.identity</name> <name>test.azureblob.identity</name>
<value>${jclouds.azure.storage.account}</value> <value>${test.azureblob.identity}</value>
</property> </property>
<property> <property>
<name>azureblob.credential</name> <name>test.azureblob.credential</name>
<value>${jclouds.azure.storage.key}</value> <value>${test.azureblob.credential}</value>
</property> </property>
<property> <property>
<name>cloudfiles.identity</name> <name>test.cloudfiles.identity</name>
<value>${jclouds.rackspace.user}</value> <value>${test.cloudfiles.identity}</value>
</property> </property>
<property> <property>
<name>cloudfiles.credential</name> <name>test.cloudfiles.credential</name>
<value>${jclouds.rackspace.key}</value> <value>${test.cloudfiles.credential}</value>
</property> </property>
<property> <property>
<name>s3.identity</name> <name>test.s3.identity</name>
<value>${jclouds.aws.accesskeyid}</value> <value>${test.s3.identity}</value>
</property> </property>
<property> <property>
<name>s3.credential</name> <name>test.s3.credential</name>
<value>${jclouds.aws.secretaccesskey}</value> <value>${test.s3.credential}</value>
</property> </property>
<property> <property>
<name>googlestorage.identity</name> <name>test.googlestorage.identity</name>
<value>${jclouds.googlestorage.accesskeyid}</value> <value>${test.googlestorage.identity}</value>
</property> </property>
<property> <property>
<name>googlestorage.credential</name> <name>test.googlestorage.credential</name>
<value>${jclouds.googlestorage.secretaccesskey}</value> <value>${test.googlestorage.credential}</value>
</property> </property>
<property> <property>
<name>appengine.home</name> <name>appengine.home</name>

View File

@ -39,6 +39,7 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.gogrid.domain.Ip; import org.jclouds.gogrid.domain.Ip;
import org.jclouds.gogrid.domain.IpPortPair; import org.jclouds.gogrid.domain.IpPortPair;
@ -60,7 +61,6 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.jsch.JschSshClient; import org.jclouds.ssh.jsch.JschSshClient;
import org.jclouds.ssh.jsch.predicates.InetSocketAddressConnect; import org.jclouds.ssh.jsch.predicates.InetSocketAddressConnect;
@ -106,9 +106,8 @@ public class GoGridLiveTestDisabled {
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
+ ".credential"); + ".credential");
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint"); endpoint = System.getProperty("test." + provider + ".endpoint");
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider apiversion = System.getProperty("test." + provider + ".apiversion");
+ ".apiversion");
} }
protected Properties setupProperties() { protected Properties setupProperties() {
@ -117,8 +116,10 @@ public class GoGridLiveTestDisabled {
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
overrides.setProperty(provider + ".identity", identity); overrides.setProperty(provider + ".identity", identity);
overrides.setProperty(provider + ".credential", credential); overrides.setProperty(provider + ".credential", credential);
overrides.setProperty(provider + ".endpoint", endpoint); if (endpoint != null)
overrides.setProperty(provider + ".apiversion", apiversion); overrides.setProperty(provider + ".endpoint", endpoint);
if (apiversion != null)
overrides.setProperty(provider + ".apiversion", apiversion);
return overrides; return overrides;
} }
@ -126,8 +127,8 @@ public class GoGridLiveTestDisabled {
public void setupClient() { public void setupClient() {
setupCredentials(); setupCredentials();
Properties overrides = setupProperties(); Properties overrides = setupProperties();
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()), context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
overrides); overrides).getProviderSpecificContext();
client = context.getApi(); client = context.getApi();
serverLatestJobCompleted = new RetryablePredicate<Server>(new ServerLatestJobCompleted(client.getJobServices()), serverLatestJobCompleted = new RetryablePredicate<Server>(new ServerLatestJobCompleted(client.getJobServices()),

View File

@ -85,7 +85,7 @@
<target name="create" description="create the nodes ${tag}" > <target name="create" description="create the nodes ${tag}" >
<compute actions="destroy,create" provider="${url}"> <compute actions="destroy,create" provider="${url}">
<nodes tag="${tag}" os="UBUNTU" size="SMALLEST" <nodes tag="${tag}" os="UBUNTU" hardware="SMALLEST"
runscript="runscript.sh" openports="22,${listenport}" runscript="runscript.sh" openports="22,${listenport}"
privatekeyfile="${privatekeyfile}" publickeyfile="${publickeyfile}" privatekeyfile="${privatekeyfile}" publickeyfile="${publickeyfile}"
hostproperty="host" usernameproperty="username" /> hostproperty="host" usernameproperty="username" />

View File

@ -22,8 +22,8 @@ apt-get update -qq
apt-get upgrade -y -qq apt-get upgrade -y -qq
apt-get install -y -qq wget apt-get install -y -qq wget
apt-get install -y -qq openjdk-6-jdk apt-get install -y -qq openjdk-6-jdk
wget -q http://mirrors.axint.net/apache/tomcat/tomcat-6/v6.0.24/bin/apache-tomcat-6.0.24.tar.gz wget -q http://mirrors.axint.net/apache/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.tar.gz
tar xzf apache-tomcat-6.0.24.tar.gz tar xzf apache-tomcat-6.0.29.tar.gz
mkdir -p /tmp/cargo/containers mkdir -p /tmp/cargo/containers
chmod 1777 /tmp/cargo chmod 1777 /tmp/cargo
mv apache-tomcat-6.0.24 /tmp/cargo/containers/tomcat6x mv apache-tomcat-6.0.29 /tmp/cargo/containers/tomcat6x

View File

@ -83,7 +83,7 @@
</target> </target>
<target name="list-hardwares" description="list the hardwares supported"> <target name="list-hardwares" description="list the hardwares supported">
<compute actions="list-hardwares" provider="${jclouds.compute.url}" /> <compute actions="list-sizes" provider="${jclouds.compute.url}" />
</target> </target>
<target name="list-locations" description="list the locations supported"> <target name="list-locations" description="list the locations supported">
@ -91,7 +91,7 @@
</target> </target>
<target name="dump" description="list all information we can obtain about the cloud"> <target name="dump" description="list all information we can obtain about the cloud">
<compute actions="list-locations,list-hardwares,list-images,list-details" provider="${jclouds.compute.url}" /> <compute actions="list-locations,list-sizes,list-images,list-details" provider="${jclouds.compute.url}" />
</target> </target>
<target name="reboot" depends="reboot-id,reboot-tag" /> <target name="reboot" depends="reboot-id,reboot-tag" />