From b9dc8912398b061a117289219338c9a993677c19 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 2 Oct 2010 16:29:09 +0100 Subject: [PATCH 1/5] corrected ant scripts --- tools/antcontrib/samples/cargooverssh/build.xml | 2 +- tools/antcontrib/samples/cargooverssh/runscript.sh | 6 +++--- tools/antcontrib/samples/compute/build.xml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/antcontrib/samples/cargooverssh/build.xml b/tools/antcontrib/samples/cargooverssh/build.xml index 5ebf3b0a9d..c61ea8afe7 100644 --- a/tools/antcontrib/samples/cargooverssh/build.xml +++ b/tools/antcontrib/samples/cargooverssh/build.xml @@ -85,7 +85,7 @@ - diff --git a/tools/antcontrib/samples/cargooverssh/runscript.sh b/tools/antcontrib/samples/cargooverssh/runscript.sh index 8dbde3ddb2..6c3f1505f6 100644 --- a/tools/antcontrib/samples/cargooverssh/runscript.sh +++ b/tools/antcontrib/samples/cargooverssh/runscript.sh @@ -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 diff --git a/tools/antcontrib/samples/compute/build.xml b/tools/antcontrib/samples/compute/build.xml index 159ef3ac74..c64cf06949 100644 --- a/tools/antcontrib/samples/compute/build.xml +++ b/tools/antcontrib/samples/compute/build.xml @@ -83,7 +83,7 @@ - + @@ -91,7 +91,7 @@ - + From e73b0275bfcd0e06e1ef3694891a33fb6c1ad7c8 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 3 Oct 2010 10:18:23 +0100 Subject: [PATCH 2/5] adjusted gogrid test properties --- .../jclouds/gogrid/GoGridLiveTestDisabled.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java b/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java index 61eeecd43f..811325390d 100644 --- a/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java +++ b/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java @@ -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. of(new Log4JLoggingModule()), - overrides); + context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), + overrides).getProviderSpecificContext(); client = context.getApi(); serverLatestJobCompleted = new RetryablePredicate(new ServerLatestJobCompleted(client.getJobServices()), From 3aa0c193d1d1b48d5b4f2314845a19b5dfe2b3c7 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 4 Oct 2010 16:45:58 +0100 Subject: [PATCH 3/5] Issue 375: expose userData --- .../internal/EC2TemplateBuilderImpl.java | 2 + .../compute/options/EC2TemplateOptions.java | 33 +++ ...rityGroupsAsNeededAndReturnRunOptions.java | 5 + ...GroupsAsNeededAndReturnRunOptionsTest.java | 205 ++++++++++++------ 4 files changed, 176 insertions(+), 69 deletions(-) diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/internal/EC2TemplateBuilderImpl.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/internal/EC2TemplateBuilderImpl.java index 05912abd5e..863b332922 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/internal/EC2TemplateBuilderImpl.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/internal/EC2TemplateBuilderImpl.java @@ -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()); } } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/options/EC2TemplateOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/options/EC2TemplateOptions.java index b09aa1726a..eb8fd2dd61 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/options/EC2TemplateOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/options/EC2TemplateOptions.java @@ -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; } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java index b18c854c2e..1bcf789798 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java @@ -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; } diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java index b177e56d26..bde0cf8938 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java @@ -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. of()); - assertEquals(runOptions.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", - size.getProviderId(), "AdditionalInfo", tag, "SecurityGroup.1", generatedGroup, "KeyName", - systemGeneratedKeyPairName).entries()); + assertEquals( + runOptions.buildFormParameters().entries(), + ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag, + "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName).entries()); assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. 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. of()); - assertEquals(runOptions.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", - size.getProviderId(), "AdditionalInfo", tag, "SecurityGroup.1", generatedGroup, "KeyName", - systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup).entries()); + assertEquals( + runOptions.buildFormParameters().entries(), + ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag, + "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName", + generatedGroup).entries()); assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. 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. of()); - assertEquals(runOptions.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", - size.getProviderId(), "AdditionalInfo", tag, "SecurityGroup.1", generatedGroup, "KeyName", - systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup).entries()); + assertEquals( + runOptions.buildFormParameters().entries(), + ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag, + "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName", + generatedGroup).entries()); assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. 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. of()); - assertEquals(runOptions.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", - size.getProviderId(), "AdditionalInfo", tag, "SubnetId", "1", "KeyName", systemGeneratedKeyPairName) - .entries()); + assertEquals( + runOptions.buildFormParameters().entries(), + ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag, + "SubnetId", "1", "KeyName", systemGeneratedKeyPairName).entries()); + assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of()); + assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. 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 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. of()); + assertEquals( + runOptions.buildFormParameters().entries(), + ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag, + "SecurityGroup.1", "group", "KeyName", systemGeneratedKeyPairName, "UserData", Base64.encodeBytes("hello".getBytes())).entries()); assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of()); assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. 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) { From 6d6862a5817274b7a9331f84f589389bd8cd11b1 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 6 Oct 2010 09:52:01 +0100 Subject: [PATCH 4/5] updated to beta-7 --- README.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index 7ad2d21887..4a000b28d2 100644 --- a/README.txt +++ b/README.txt @@ -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 From ff039698287d67300193d268bce10e7cda311db7 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 6 Oct 2010 09:52:24 +0100 Subject: [PATCH 5/5] started refactoring tweetstore launch properties --- demos/gae-tweetstore/pom.xml | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/demos/gae-tweetstore/pom.xml b/demos/gae-tweetstore/pom.xml index 9f3a676c18..6b3063661a 100644 --- a/demos/gae-tweetstore/pom.xml +++ b/demos/gae-tweetstore/pom.xml @@ -238,44 +238,44 @@ - twitter.identity - ${jclouds.twitter.user} + test.twitter.identity + ${test.twitter.identity} - twitter.credential - ${jclouds.twitter.password} + test.twitter.credential + ${test.twitter.credential} - azureblob.identity - ${jclouds.azure.storage.account} + test.azureblob.identity + ${test.azureblob.identity} - azureblob.credential - ${jclouds.azure.storage.key} + test.azureblob.credential + ${test.azureblob.credential} - cloudfiles.identity - ${jclouds.rackspace.user} + test.cloudfiles.identity + ${test.cloudfiles.identity} - cloudfiles.credential - ${jclouds.rackspace.key} + test.cloudfiles.credential + ${test.cloudfiles.credential} - s3.identity - ${jclouds.aws.accesskeyid} + test.s3.identity + ${test.s3.identity} - s3.credential - ${jclouds.aws.secretaccesskey} + test.s3.credential + ${test.s3.credential} - googlestorage.identity - ${jclouds.googlestorage.accesskeyid} + test.googlestorage.identity + ${test.googlestorage.identity} - googlestorage.credential - ${jclouds.googlestorage.secretaccesskey} + test.googlestorage.credential + ${test.googlestorage.credential} appengine.home