mirror of https://github.com/apache/jclouds.git
Merge remote branch 'origin'
Conflicts: tools/antcontrib/samples/compute/build.xml
This commit is contained in:
commit
7a459aaf77
|
@ -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
|
||||
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 compute api supports: ec2, gogrid, rackspace, rimuhosting, vcloud, trmk-ecloud,
|
||||
|
@ -98,13 +98,13 @@ Compute Example (Clojure):
|
|||
(run-nodes "mycluster" 2))
|
||||
|
||||
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
|
||||
* snapshot repo: http://jclouds.rimuhosting.com/maven2/snapshots
|
||||
|
||||
Links:
|
||||
* 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/
|
||||
* community: http://code.google.com/p/jclouds/wiki/AppsThatUseJClouds
|
||||
* user group: http://groups.google.com/group/jclouds
|
||||
|
|
|
@ -75,6 +75,8 @@ public class EC2TemplateBuilderImpl extends TemplateBuilderImpl {
|
|||
eTo.subnetId(eFrom.getSubnetId());
|
||||
if (eFrom.isMonitoringEnabled())
|
||||
eTo.enableMonitoring();
|
||||
if (eFrom.getUserData() != null)
|
||||
eTo.userData(eFrom.getUserData());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ public class EC2TemplateOptions extends TemplateOptions {
|
|||
private String placementGroup = null;
|
||||
private boolean noPlacementGroup;
|
||||
private String subnetId;
|
||||
private byte[] userData;
|
||||
|
||||
public static final EC2TemplateOptions NONE = new EC2TemplateOptions();
|
||||
|
||||
|
@ -94,6 +95,17 @@ public class EC2TemplateOptions extends TemplateOptions {
|
|||
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
|
||||
*/
|
||||
|
@ -169,6 +181,14 @@ public class EC2TemplateOptions extends TemplateOptions {
|
|||
EC2TemplateOptions options = new EC2TemplateOptions();
|
||||
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
|
||||
|
@ -435,6 +455,13 @@ public class EC2TemplateOptions extends TemplateOptions {
|
|||
public String getSubnetId() {
|
||||
return subnetId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return unencoded user data.
|
||||
*/
|
||||
public byte[] getUserData() {
|
||||
return userData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -447,6 +474,7 @@ public class EC2TemplateOptions extends TemplateOptions {
|
|||
result = prime * result + (monitoringEnabled ? 1231 : 1237);
|
||||
result = prime * result + ((placementGroup == null) ? 0 : placementGroup.hashCode());
|
||||
result = prime * result + ((subnetId == null) ? 0 : subnetId.hashCode());
|
||||
result = prime * result + ((userData == null) ? 0 : userData.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -485,6 +513,11 @@ public class EC2TemplateOptions extends TemplateOptions {
|
|||
return false;
|
||||
} else if (!subnetId.equals(other.subnetId))
|
||||
return false;
|
||||
if (userData == null) {
|
||||
if (other.userData != null)
|
||||
return false;
|
||||
} else if (!userData.equals(other.userData))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,11 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions
|
|||
if (placementGroupName != null)
|
||||
instanceOptions.inPlacementGroup(placementGroupName);
|
||||
|
||||
byte[] userData = EC2TemplateOptions.class.cast(template.getOptions()).getUserData();
|
||||
|
||||
if (userData != null)
|
||||
instanceOptions.withUserData(userData);
|
||||
|
||||
return instanceOptions;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.jclouds.aws.ec2.domain.PlacementGroup;
|
|||
import org.jclouds.aws.ec2.options.RunInstancesOptions;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.options.TemplateOptions;
|
||||
import org.jclouds.encryption.internal.Base64;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
@ -65,16 +66,16 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
|
||||
// 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) });
|
||||
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);
|
||||
|
@ -83,9 +84,10 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(template.getHardware()).andReturn(size).atLeastOnce();
|
||||
expect(template.getOptions()).andReturn(options).atLeastOnce();
|
||||
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
|
||||
systemGeneratedKeyPairName);
|
||||
systemGeneratedKeyPairName);
|
||||
expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups);
|
||||
expect(options.getSubnetId()).andReturn(null);
|
||||
expect(options.getUserData()).andReturn(null);
|
||||
|
||||
// replay mocks
|
||||
replay(options);
|
||||
|
@ -95,9 +97,10 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
// 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", generatedGroup, "KeyName",
|
||||
systemGeneratedKeyPairName).entries());
|
||||
assertEquals(
|
||||
runOptions.buildFormParameters().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.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
|
||||
assertEquals(runOptions.buildStringPayload(), null);
|
||||
|
@ -119,16 +122,16 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
|
||||
// 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) });
|
||||
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);
|
||||
|
@ -137,11 +140,12 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(template.getHardware()).andReturn(size).atLeastOnce();
|
||||
expect(template.getOptions()).andReturn(options).atLeastOnce();
|
||||
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
|
||||
systemGeneratedKeyPairName);
|
||||
systemGeneratedKeyPairName);
|
||||
expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
|
||||
generatedGroup);
|
||||
generatedGroup);
|
||||
expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups);
|
||||
expect(options.getSubnetId()).andReturn(null);
|
||||
expect(options.getUserData()).andReturn(null);
|
||||
|
||||
// replay mocks
|
||||
replay(options);
|
||||
|
@ -151,9 +155,11 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
// 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", generatedGroup, "KeyName",
|
||||
systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup).entries());
|
||||
assertEquals(
|
||||
runOptions.buildFormParameters().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.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
|
||||
assertEquals(runOptions.buildStringPayload(), null);
|
||||
|
@ -175,16 +181,16 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
|
||||
// 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) });
|
||||
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);
|
||||
|
@ -193,11 +199,12 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(template.getHardware()).andReturn(size).atLeastOnce();
|
||||
expect(template.getOptions()).andReturn(options).atLeastOnce();
|
||||
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
|
||||
systemGeneratedKeyPairName);
|
||||
systemGeneratedKeyPairName);
|
||||
expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
|
||||
generatedGroup);
|
||||
generatedGroup);
|
||||
expect(strategy.getSecurityGroupsForTagAndOptions(region, tag, options)).andReturn(generatedGroups);
|
||||
expect(options.getSubnetId()).andReturn(null);
|
||||
expect(options.getUserData()).andReturn(null);
|
||||
|
||||
// replay mocks
|
||||
replay(options);
|
||||
|
@ -207,9 +214,11 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
// 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", generatedGroup, "KeyName",
|
||||
systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup).entries());
|
||||
assertEquals(
|
||||
runOptions.buildFormParameters().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.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
|
||||
assertEquals(runOptions.buildStringPayload(), null);
|
||||
|
@ -229,16 +238,16 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
|
||||
// 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) });
|
||||
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);
|
||||
|
@ -247,8 +256,9 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(template.getHardware()).andReturn(size).atLeastOnce();
|
||||
expect(template.getOptions()).andReturn(options).atLeastOnce();
|
||||
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options)).andReturn(
|
||||
systemGeneratedKeyPairName);
|
||||
systemGeneratedKeyPairName);
|
||||
expect(options.getSubnetId()).andReturn("1");
|
||||
expect(options.getUserData()).andReturn(null);
|
||||
|
||||
// replay mocks
|
||||
replay(options);
|
||||
|
@ -258,9 +268,66 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
// 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, "SubnetId", "1", "KeyName", systemGeneratedKeyPairName)
|
||||
.entries());
|
||||
assertEquals(
|
||||
runOptions.buildFormParameters().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.buildRequestHeaders(), ImmutableMultimap.<String, String> of());
|
||||
assertEquals(runOptions.buildStringPayload(), null);
|
||||
|
@ -318,7 +385,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(strategy.createUniqueKeyPair.apply(new RegionAndName(region, tag))).andReturn(keyPair);
|
||||
expect(keyPair.getKeyName()).andReturn(systemGeneratedKeyPairName).atLeastOnce();
|
||||
expect(strategy.credentialsMap.put(new RegionAndName(region, systemGeneratedKeyPairName), keyPair)).andReturn(
|
||||
null);
|
||||
null);
|
||||
|
||||
// replay mocks
|
||||
replay(options);
|
||||
|
@ -327,7 +394,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
|
||||
// run
|
||||
assertEquals(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, options),
|
||||
systemGeneratedKeyPairName);
|
||||
systemGeneratedKeyPairName);
|
||||
|
||||
// verify mocks
|
||||
verify(options);
|
||||
|
@ -385,7 +452,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf);
|
||||
ports, shouldAuthorizeSelf);
|
||||
expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted);
|
||||
expect(strategy.createSecurityGroupIfNeeded.apply(regionNameAndIngressRules)).andReturn(generatedMarkerGroup);
|
||||
expect(strategy.securityGroupMap.put(regionNameAndIngressRules, generatedMarkerGroup)).andReturn(null);
|
||||
|
@ -421,7 +488,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf);
|
||||
ports, shouldAuthorizeSelf);
|
||||
expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted);
|
||||
expect(strategy.createSecurityGroupIfNeeded.apply(regionNameAndIngressRules)).andReturn(generatedMarkerGroup);
|
||||
expect(strategy.securityGroupMap.put(regionNameAndIngressRules, generatedMarkerGroup)).andReturn(null);
|
||||
|
@ -457,7 +524,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf);
|
||||
ports, shouldAuthorizeSelf);
|
||||
expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted);
|
||||
|
||||
// replay mocks
|
||||
|
@ -490,7 +557,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf); // note
|
||||
ports, shouldAuthorizeSelf); // note
|
||||
// this
|
||||
// works
|
||||
// since
|
||||
|
@ -531,7 +598,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
|
||||
// run
|
||||
assertEquals(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options),
|
||||
userSuppliedPlacementGroup);
|
||||
userSuppliedPlacementGroup);
|
||||
|
||||
// verify mocks
|
||||
verify(options);
|
||||
|
@ -556,9 +623,9 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(options.shouldAutomaticallyCreatePlacementGroup()).andReturn(shouldAutomaticallyCreatePlacementGroup);
|
||||
expect(strategy.placementGroupMap.containsKey(new RegionAndName(region, generatedMarkerGroup))).andReturn(false);
|
||||
expect(strategy.createPlacementGroupIfNeeded.apply(new RegionAndName(region, generatedMarkerGroup))).andReturn(
|
||||
generatedMarkerGroup);
|
||||
generatedMarkerGroup);
|
||||
expect(strategy.placementGroupMap.put(new RegionAndName(region, generatedMarkerGroup), generatedMarkerGroup))
|
||||
.andReturn(null);
|
||||
.andReturn(null);
|
||||
|
||||
// replay mocks
|
||||
replay(options);
|
||||
|
@ -566,7 +633,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
|
||||
// run
|
||||
assertEquals(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, tag, options),
|
||||
generatedMarkerGroup);
|
||||
generatedMarkerGroup);
|
||||
|
||||
// verify mocks
|
||||
verify(options);
|
||||
|
@ -623,7 +690,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded = createMock(CreatePlacementGroupIfNeeded.class);
|
||||
|
||||
return new CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(credentialsMap, securityGroupMap,
|
||||
placementGroupMap, createUniqueKeyPair, createSecurityGroupIfNeeded, createPlacementGroupIfNeeded);
|
||||
placementGroupMap, createUniqueKeyPair, createSecurityGroupIfNeeded, createPlacementGroupIfNeeded);
|
||||
}
|
||||
|
||||
private void replayStrategy(CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy) {
|
||||
|
|
|
@ -238,44 +238,44 @@
|
|||
<configuration>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>twitter.identity</name>
|
||||
<value>${jclouds.twitter.user}</value>
|
||||
<name>test.twitter.identity</name>
|
||||
<value>${test.twitter.identity}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>twitter.credential</name>
|
||||
<value>${jclouds.twitter.password}</value>
|
||||
<name>test.twitter.credential</name>
|
||||
<value>${test.twitter.credential}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>azureblob.identity</name>
|
||||
<value>${jclouds.azure.storage.account}</value>
|
||||
<name>test.azureblob.identity</name>
|
||||
<value>${test.azureblob.identity}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>azureblob.credential</name>
|
||||
<value>${jclouds.azure.storage.key}</value>
|
||||
<name>test.azureblob.credential</name>
|
||||
<value>${test.azureblob.credential}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>cloudfiles.identity</name>
|
||||
<value>${jclouds.rackspace.user}</value>
|
||||
<name>test.cloudfiles.identity</name>
|
||||
<value>${test.cloudfiles.identity}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>cloudfiles.credential</name>
|
||||
<value>${jclouds.rackspace.key}</value>
|
||||
<name>test.cloudfiles.credential</name>
|
||||
<value>${test.cloudfiles.credential}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>s3.identity</name>
|
||||
<value>${jclouds.aws.accesskeyid}</value>
|
||||
<name>test.s3.identity</name>
|
||||
<value>${test.s3.identity}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>s3.credential</name>
|
||||
<value>${jclouds.aws.secretaccesskey}</value>
|
||||
<name>test.s3.credential</name>
|
||||
<value>${test.s3.credential}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>googlestorage.identity</name>
|
||||
<value>${jclouds.googlestorage.accesskeyid}</value>
|
||||
<name>test.googlestorage.identity</name>
|
||||
<value>${test.googlestorage.identity}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>googlestorage.credential</name>
|
||||
<value>${jclouds.googlestorage.secretaccesskey}</value>
|
||||
<name>test.googlestorage.credential</name>
|
||||
<value>${test.googlestorage.credential}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>appengine.home</name>
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.gogrid.domain.Ip;
|
||||
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.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.jsch.JschSshClient;
|
||||
import org.jclouds.ssh.jsch.predicates.InetSocketAddressConnect;
|
||||
|
@ -106,9 +106,8 @@ public class GoGridLiveTestDisabled {
|
|||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||
+ ".credential");
|
||||
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint");
|
||||
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider
|
||||
+ ".apiversion");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||
}
|
||||
|
||||
protected Properties setupProperties() {
|
||||
|
@ -117,8 +116,10 @@ public class GoGridLiveTestDisabled {
|
|||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||
overrides.setProperty(provider + ".identity", identity);
|
||||
overrides.setProperty(provider + ".credential", credential);
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
if (endpoint != null)
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
if (apiversion != null)
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
return overrides;
|
||||
}
|
||||
|
||||
|
@ -126,8 +127,8 @@ public class GoGridLiveTestDisabled {
|
|||
public void setupClient() {
|
||||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
||||
overrides);
|
||||
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
||||
overrides).getProviderSpecificContext();
|
||||
|
||||
client = context.getApi();
|
||||
serverLatestJobCompleted = new RetryablePredicate<Server>(new ServerLatestJobCompleted(client.getJobServices()),
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
|
||||
<target name="create" description="create the nodes ${tag}" >
|
||||
<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}"
|
||||
privatekeyfile="${privatekeyfile}" publickeyfile="${publickeyfile}"
|
||||
hostproperty="host" usernameproperty="username" />
|
||||
|
|
|
@ -22,8 +22,8 @@ apt-get update -qq
|
|||
apt-get upgrade -y -qq
|
||||
apt-get install -y -qq wget
|
||||
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
|
||||
tar xzf 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.29.tar.gz
|
||||
mkdir -p /tmp/cargo/containers
|
||||
chmod 1777 /tmp/cargo
|
||||
mv apache-tomcat-6.0.24 /tmp/cargo/containers/tomcat6x
|
||||
mv apache-tomcat-6.0.29 /tmp/cargo/containers/tomcat6x
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
</target>
|
||||
|
||||
<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 name="list-locations" description="list the locations supported">
|
||||
|
@ -91,7 +91,7 @@
|
|||
</target>
|
||||
|
||||
<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 name="reboot" depends="reboot-id,reboot-tag" />
|
||||
|
@ -189,4 +189,4 @@
|
|||
</compute>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
</project>
|
Loading…
Reference in New Issue