refactored boot script to check if java is installed first, and also stream jboss so that it works with small vms

This commit is contained in:
Adrian Cole 2010-09-28 23:56:05 +01:00
parent 47697d6f7e
commit 546535340f
12 changed files with 256 additions and 200 deletions

View File

@ -19,7 +19,7 @@
package org.jclouds.aws; package org.jclouds.aws;
import static org.jclouds.compute.BaseComputeServiceLiveTest.buildScript; import static org.jclouds.compute.ComputeTestUtils.buildScript;
import static org.jclouds.compute.options.TemplateOptions.Builder.runScript; import static org.jclouds.compute.options.TemplateOptions.Builder.runScript;
import static org.jclouds.compute.util.ComputeServiceUtils.execHttpResponse; import static org.jclouds.compute.util.ComputeServiceUtils.execHttpResponse;
import static org.jclouds.compute.util.ComputeServiceUtils.extractTargzIntoDirectory; import static org.jclouds.compute.util.ComputeServiceUtils.extractTargzIntoDirectory;
@ -74,7 +74,7 @@ public class ComputeAndBlobStoreTogetherHappilyLiveTest extends BlobStoreAndComp
public void testWeCanIndirectBootstrapInstructionsToAnArbitraryAndPrivateBlobStore() throws RunNodesException { public void testWeCanIndirectBootstrapInstructionsToAnArbitraryAndPrivateBlobStore() throws RunNodesException {
OperatingSystem defaultOperatingSystem = computeContext.getComputeService().templateBuilder().build().getImage() OperatingSystem defaultOperatingSystem = computeContext.getComputeService().templateBuilder().build().getImage()
.getOperatingSystem(); .getOperatingSystem();
// using jclouds ability to detect operating systems before we launch them, we can avoid // using jclouds ability to detect operating systems before we launch them, we can avoid
// the bad practice of assuming everything is ubuntu. // the bad practice of assuming everything is ubuntu.
@ -89,22 +89,22 @@ public class ComputeAndBlobStoreTogetherHappilyLiveTest extends BlobStoreAndComp
// if we want to, we can mix and match batched and ad-hoc commands, such as extracting maven // if we want to, we can mix and match batched and ad-hoc commands, such as extracting maven
String mavenVersion = "3.0-beta-3"; String mavenVersion = "3.0-beta-3";
Statement extractMavenIntoUsrLocal = extractTargzIntoDirectory(URI Statement extractMavenIntoUsrLocal = extractTargzIntoDirectory(
.create("http://mirrors.ibiblio.org/pub/mirrors/apache//maven/binaries/apache-maven-" + mavenVersion URI.create("http://mirrors.ibiblio.org/pub/mirrors/apache//maven/binaries/apache-maven-" + mavenVersion
+ "-bin.tar.gz"), "/usr/local"); + "-bin.tar.gz"), "/usr/local");
// have both of these commands occur on boot // have both of these commands occur on boot
Statement bootstrapInstructions = newStatementList(installOpenJDK, extractMavenIntoUsrLocal); Statement bootstrapInstructions = newStatementList(installOpenJDK, extractMavenIntoUsrLocal);
// now that we have the correct instructions, kick-off the provisioner // now that we have the correct instructions, kick-off the provisioner
Iterable<? extends NodeMetadata> nodes = computeContext.getComputeService().runNodesWithTag(tag, 2, Iterable<? extends NodeMetadata> nodes = computeContext.getComputeService().runNodesWithTag(tag, 2,
runScript(bootstrapInstructions)); runScript(bootstrapInstructions));
// ensure the bootstrap operated by checking for the components we installed at boot time. // ensure the bootstrap operated by checking for the components we installed at boot time.
// Note this test will ensure both nodes are in sync. // Note this test will ensure both nodes are in sync.
assertSshOutputOfCommandContains(nodes, "java -version", "OpenJDK"); assertSshOutputOfCommandContains(nodes, "java -version", "OpenJDK");
assertSshOutputOfCommandContains(nodes, "/usr/local/apache-maven-" + mavenVersion + "/bin/mvn -version", assertSshOutputOfCommandContains(nodes, "/usr/local/apache-maven-" + mavenVersion + "/bin/mvn -version",
"Apache Maven " + mavenVersion + ""); "Apache Maven " + mavenVersion + "");
} }
} }

View File

@ -21,6 +21,7 @@ package org.jclouds.aws.ec2.compute;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.get; import static com.google.common.collect.Iterables.get;
import static org.jclouds.compute.ComputeTestUtils.setupKeyPair;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@ -31,7 +32,6 @@ import org.jclouds.Constants;
import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.blobstore.BlobStoreContextFactory;
import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
@ -62,9 +62,9 @@ public class BlobStoreAndComputeServiceLiveTest {
protected Properties setupCredentials(String provider) { protected Properties setupCredentials(String provider) {
String identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider String identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider
+ ".identity"); + ".identity");
String credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider String credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
+ ".credential"); + ".credential");
String endpoint = System.getProperty("test." + provider + ".endpoint"); String endpoint = System.getProperty("test." + provider + ".endpoint");
String apiversion = System.getProperty("test." + provider + ".apiversion"); String apiversion = System.getProperty("test." + provider + ".apiversion");
Properties overrides = new Properties(); Properties overrides = new Properties();
@ -80,16 +80,17 @@ public class BlobStoreAndComputeServiceLiveTest {
} }
protected void setupKeyPairForTest() throws FileNotFoundException, IOException { protected void setupKeyPairForTest() throws FileNotFoundException, IOException {
keyPair = BaseComputeServiceLiveTest.setupKeyPair(); keyPair = setupKeyPair();
} }
@BeforeGroups(groups = { "live" }) @BeforeGroups(groups = { "live" })
public void setupClient() throws FileNotFoundException, IOException { public void setupClient() throws FileNotFoundException, IOException {
setupKeyPairForTest(); setupKeyPairForTest();
computeContext = new ComputeServiceContextFactory().createContext(computeServiceProvider, ImmutableSet.of( computeContext = new ComputeServiceContextFactory().createContext(computeServiceProvider,
new Log4JLoggingModule(), new JschSshClientModule()), setupCredentials(computeServiceProvider)); ImmutableSet.of(new Log4JLoggingModule(), new JschSshClientModule()),
blobContext = new BlobStoreContextFactory().createContext(blobStoreProvider, ImmutableSet setupCredentials(computeServiceProvider));
.of(new Log4JLoggingModule()), setupCredentials(blobStoreProvider)); blobContext = new BlobStoreContextFactory().createContext(blobStoreProvider,
ImmutableSet.of(new Log4JLoggingModule()), setupCredentials(blobStoreProvider));
blobContext.getAsyncBlobStore().createContainerInLocation(null, tag); blobContext.getAsyncBlobStore().createContainerInLocation(null, tag);
computeContext.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag)); computeContext.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag));
} }
@ -98,8 +99,8 @@ public class BlobStoreAndComputeServiceLiveTest {
for (NodeMetadata node : nodes) { for (NodeMetadata node : nodes) {
IPSocket socket = new IPSocket(get(node.getPublicAddresses(), 0), 22); IPSocket socket = new IPSocket(get(node.getPublicAddresses(), 0), 22);
SshClient ssh = computeContext.utils().sshFactory().create(socket, node.getCredentials().identity, SshClient ssh = computeContext.utils().sshFactory()
node.getCredentials().credential.getBytes()); .create(socket, node.getCredentials().identity, node.getCredentials().credential.getBytes());
try { try {
ssh.connect(); ssh.connect();
ExecResponse exec = ssh.exec(cmd); ExecResponse exec = ssh.exec(cmd);

View File

@ -20,7 +20,13 @@
package org.jclouds.aws.ec2.services; package org.jclouds.aws.ec2.services;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.io.Payloads.newStringPayload; import static com.google.common.collect.Iterables.any;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newTreeSet;
import static org.jclouds.compute.ComputeTestUtils.buildScript;
import static org.jclouds.compute.ComputeTestUtils.setupKeyPair;
import static org.jclouds.scriptbuilder.domain.Statements.exec;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
@ -41,7 +47,6 @@ import org.jclouds.aws.ec2.domain.PlacementGroup;
import org.jclouds.aws.ec2.domain.PlacementGroup.State; import org.jclouds.aws.ec2.domain.PlacementGroup.State;
import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable; import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable;
import org.jclouds.aws.ec2.predicates.PlacementGroupDeleted; import org.jclouds.aws.ec2.predicates.PlacementGroupDeleted;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.RunNodesException; import org.jclouds.compute.RunNodesException;
@ -59,9 +64,6 @@ import org.testng.annotations.Test;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.inject.Module; import com.google.inject.Module;
/** /**
@ -87,10 +89,10 @@ public class PlacementGroupClientLiveTest {
protected void setupCredentials() { protected void setupCredentials() {
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 = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint");
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider
+ ".apiversion"); + ".apiversion");
} }
protected Properties setupProperties() { protected Properties setupProperties() {
@ -108,35 +110,35 @@ public class PlacementGroupClientLiveTest {
public void setupClient() throws FileNotFoundException, IOException { public void setupClient() throws FileNotFoundException, IOException {
setupCredentials(); setupCredentials();
Properties overrides = setupProperties(); Properties overrides = setupProperties();
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet context = new ComputeServiceContextFactory().createContext(provider,
.<Module> of(new Log4JLoggingModule()), overrides); ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides);
keyPair = BaseComputeServiceLiveTest.setupKeyPair(); keyPair = setupKeyPair();
client = EC2Client.class.cast(context.getProviderSpecificContext().getApi()); client = EC2Client.class.cast(context.getProviderSpecificContext().getApi());
availableTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupAvailable(client), 60, 1, availableTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupAvailable(client), 60, 1,
TimeUnit.SECONDS); TimeUnit.SECONDS);
deletedTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupDeleted(client), 60, 1, TimeUnit.SECONDS); deletedTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupDeleted(client), 60, 1, TimeUnit.SECONDS);
} }
@Test @Test
void testDescribe() { void testDescribe() {
for (String region : Lists.newArrayList(Region.US_EAST_1)) { for (String region : newArrayList(Region.US_EAST_1)) {
SortedSet<PlacementGroup> allResults = Sets.newTreeSet(client.getPlacementGroupServices() SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupServices()
.describePlacementGroupsInRegion(region)); .describePlacementGroupsInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);
if (allResults.size() >= 1) { if (allResults.size() >= 1) {
PlacementGroup group = allResults.last(); PlacementGroup group = allResults.last();
SortedSet<PlacementGroup> result = Sets.newTreeSet(client.getPlacementGroupServices() SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupServices()
.describePlacementGroupsInRegion(region, group.getName())); .describePlacementGroupsInRegion(region, group.getName()));
assertNotNull(result); assertNotNull(result);
PlacementGroup compare = result.last(); PlacementGroup compare = result.last();
assertEquals(compare, group); assertEquals(compare, group);
} }
} }
for (String region : Lists.newArrayList(Region.EU_WEST_1, Region.US_WEST_1, Region.AP_SOUTHEAST_1)) { for (String region : newArrayList(Region.EU_WEST_1, Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
try { try {
client.getPlacementGroupServices().describePlacementGroupsInRegion(region); client.getPlacementGroupServices().describePlacementGroupsInRegion(region);
assert false : "should be unsupported"; assert false : "should be unsupported";
@ -158,7 +160,7 @@ public class PlacementGroupClientLiveTest {
private void verifyPlacementGroup(String groupName) { private void verifyPlacementGroup(String groupName) {
assert availableTester.apply(new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group; assert availableTester.apply(new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group;
Set<PlacementGroup> oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null, Set<PlacementGroup> oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null,
groupName); groupName);
assertNotNull(oneResult); assertNotNull(oneResult);
assertEquals(oneResult.size(), 1); assertEquals(oneResult.size(), 1);
group = oneResult.iterator().next(); group = oneResult.iterator().next();
@ -169,7 +171,7 @@ public class PlacementGroupClientLiveTest {
public void testStartCCInstance() throws Exception { public void testStartCCInstance() throws Exception {
Set<? extends Hardware> sizes = context.getComputeService().listHardwareProfiles(); Set<? extends Hardware> sizes = context.getComputeService().listHardwareProfiles();
assert Iterables.any(sizes, new Predicate<Hardware>() { assert any(sizes, new Predicate<Hardware>() {
@Override @Override
public boolean apply(Hardware arg0) { public boolean apply(Hardware arg0) {
@ -178,7 +180,7 @@ public class PlacementGroupClientLiveTest {
}) : sizes; }) : sizes;
Set<? extends Image> images = context.getComputeService().listImages(); Set<? extends Image> images = context.getComputeService().listImages();
assert Iterables.any(images, new Predicate<Image>() { assert any(images, new Predicate<Image>() {
@Override @Override
public boolean apply(Image arg0) { public boolean apply(Image arg0) {
@ -193,19 +195,17 @@ public class PlacementGroupClientLiveTest {
assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17"); assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17");
template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public")) template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public"))
.runScript( .runScript(exec(buildScript(template.getImage().getOperatingSystem())));
newStringPayload(BaseComputeServiceLiveTest.buildScript(template.getImage()
.getOperatingSystem())));
String tag = PREFIX + "cccluster"; String tag = PREFIX + "cccluster";
context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag)); context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag));
try { try {
Set<? extends NodeMetadata> nodes = context.getComputeService().runNodesWithTag(tag, 1, template); Set<? extends NodeMetadata> nodes = context.getComputeService().runNodesWithTag(tag, 1, template);
NodeMetadata node = Iterables.getOnlyElement(nodes); NodeMetadata node = getOnlyElement(nodes);
Iterables.getOnlyElement(Iterables.getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null, getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null,
node.getProviderId()))); node.getProviderId())));
} catch (RunNodesException e) { } catch (RunNodesException e) {
System.err.println(e.getNodeErrors().keySet()); System.err.println(e.getNodeErrors().keySet());

View File

@ -162,11 +162,12 @@
<priority value="DEBUG" /> <priority value="DEBUG" />
<appender-ref ref="ASYNCSSH" /> <appender-ref ref="ASYNCSSH" />
</category> </category>
<!--
<category name="jclouds.wire"> <category name="jclouds.wire">
<priority value="DEBUG" /> <priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" /> <appender-ref ref="ASYNCWIRE" />
</category> </category>
-->
<category name="jclouds.blobstore"> <category name="jclouds.blobstore">
<priority value="DEBUG" /> <priority value="DEBUG" />
<appender-ref ref="ASYNCBLOBSTORE" /> <appender-ref ref="ASYNCBLOBSTORE" />

View File

@ -30,6 +30,7 @@ import static com.google.common.collect.Maps.newLinkedHashMap;
import static com.google.common.collect.Maps.uniqueIndex; import static com.google.common.collect.Maps.uniqueIndex;
import static com.google.common.collect.Sets.filter; import static com.google.common.collect.Sets.filter;
import static com.google.common.collect.Sets.newTreeSet; import static com.google.common.collect.Sets.newTreeSet;
import static org.jclouds.compute.ComputeTestUtils.buildScript;
import static org.jclouds.compute.options.TemplateOptions.Builder.blockOnComplete; import static org.jclouds.compute.options.TemplateOptions.Builder.blockOnComplete;
import static org.jclouds.compute.options.TemplateOptions.Builder.overrideCredentialsWith; import static org.jclouds.compute.options.TemplateOptions.Builder.overrideCredentialsWith;
import static org.jclouds.compute.predicates.NodePredicates.TERMINATED; import static org.jclouds.compute.predicates.NodePredicates.TERMINATED;
@ -41,10 +42,8 @@ import static org.jclouds.io.Payloads.newStringPayload;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.net.URI;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
@ -67,7 +66,6 @@ import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.predicates.OperatingSystemPredicates;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope; import org.jclouds.domain.LocationScope;
@ -79,16 +77,12 @@ import org.jclouds.rest.AuthorizationException;
import org.jclouds.ssh.ExecResponse; import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException; import org.jclouds.ssh.SshException;
import org.jclouds.util.Utils;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Charsets;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.io.Files;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Module; import com.google.inject.Module;
@ -119,21 +113,7 @@ public abstract class BaseComputeServiceLiveTest {
} }
protected void setupKeyPairForTest() throws FileNotFoundException, IOException { protected void setupKeyPairForTest() throws FileNotFoundException, IOException {
keyPair = setupKeyPair(); keyPair = ComputeTestUtils.setupKeyPair();
}
public static Map<String, String> setupKeyPair() throws FileNotFoundException, IOException {
String secretKeyFile;
try {
secretKeyFile = checkNotNull(System.getProperty("test.ssh.keyfile"), "test.ssh.keyfile");
} catch (NullPointerException e) {
secretKeyFile = System.getProperty("user.home") + "/.ssh/id_rsa";
}
checkSecretKeyFile(secretKeyFile);
String secret = Files.toString(new File(secretKeyFile), Charsets.UTF_8);
assert secret.startsWith("-----BEGIN RSA PRIVATE KEY-----") : "invalid key:\n" + secret;
return ImmutableMap.<String, String> of("private", secret, "public", Files.toString(new File(secretKeyFile
+ ".pub"), Charsets.UTF_8));
} }
protected String provider; protected String provider;
@ -178,18 +158,11 @@ public abstract class BaseComputeServiceLiveTest {
if (context != null) if (context != null)
context.close(); context.close();
Properties props = setupProperties(); Properties props = setupProperties();
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.of(new Log4JLoggingModule(), context = new ComputeServiceContextFactory().createContext(provider,
getSshModule()), props); ImmutableSet.of(new Log4JLoggingModule(), getSshModule()), props);
client = context.getComputeService(); client = context.getComputeService();
} }
private static void checkSecretKeyFile(String secretKeyFile) throws FileNotFoundException {
Utils.checkNotEmpty(secretKeyFile, "System property: [test.ssh.keyfile] set to an empty string");
if (!new File(secretKeyFile).exists()) {
throw new FileNotFoundException("secretKeyFile not found at: " + secretKeyFile);
}
}
abstract protected Module getSshModule(); abstract protected Module getSshModule();
// wait up to 5 seconds for an auth exception // wait up to 5 seconds for an auth exception
@ -197,8 +170,8 @@ public abstract class BaseComputeServiceLiveTest {
public void testCorrectAuthException() throws Exception { public void testCorrectAuthException() throws Exception {
ComputeServiceContext context = null; ComputeServiceContext context = null;
try { try {
context = new ComputeServiceContextFactory().createContext(provider, "MOMMA", "MIA", ImmutableSet context = new ComputeServiceContextFactory().createContext(provider, "MOMMA", "MIA",
.<Module> of(new Log4JLoggingModule())); ImmutableSet.<Module> of(new Log4JLoggingModule()));
context.getComputeService().listNodes(); context.getComputeService().listNodes();
} catch (AuthorizationException e) { } catch (AuthorizationException e) {
throw e; throw e;
@ -241,7 +214,7 @@ public abstract class BaseComputeServiceLiveTest {
OperatingSystem os = get(nodes, 0).getOperatingSystem(); OperatingSystem os = get(nodes, 0).getOperatingSystem();
try { try {
Map<? extends NodeMetadata, ExecResponse> responses = runScriptWithCreds(tag, os, new Credentials( Map<? extends NodeMetadata, ExecResponse> responses = runScriptWithCreds(tag, os, new Credentials(
good.identity, "romeo")); good.identity, "romeo"));
assert false : "shouldn't pass with a bad password\n" + responses; assert false : "shouldn't pass with a bad password\n" + responses;
} catch (RunScriptOnNodesException e) { } catch (RunScriptOnNodesException e) {
assert getRootCause(e).getMessage().contains("Auth fail") : e; assert getRootCause(e).getMessage().contains("Auth fail") : e;
@ -273,25 +246,24 @@ public abstract class BaseComputeServiceLiveTest {
} }
template = client.templateBuilder().options(blockOnComplete(false).blockOnPort(8080, 300).inboundPorts(22, 8080)) template = client.templateBuilder().options(blockOnComplete(false).blockOnPort(8080, 600).inboundPorts(22, 8080))
.build(); .build();
// note this is a dependency on the template resolution // note this is a dependency on the template resolution
template.getOptions().runScript( template.getOptions().runScript(
RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage() RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage()
.getOperatingSystem())); .getOperatingSystem()));
try { try {
TreeSet<NodeMetadata> nodes = newTreeSet(client.runNodesWithTag(tag, 1, template)); NodeMetadata node = getOnlyElement(client.runNodesWithTag(tag, 1, template));
checkHttpGet(nodes); checkHttpGet(node);
} finally { } finally {
client.destroyNodesMatching(withTag(tag)); client.destroyNodesMatching(withTag(tag));
} }
} }
protected void checkHttpGet(TreeSet<NodeMetadata> nodes) { protected void checkHttpGet(NodeMetadata node) {
assert context.utils().http().get( ComputeTestUtils.checkHttpGet(context.utils().http(), node, 8080);
URI.create(String.format("http://%s:8080", get(nodes.last().getPublicAddresses(), 0)))) != null;
} }
@Test(enabled = true, dependsOnMethods = "testCreateAndRunAService") @Test(enabled = true, dependsOnMethods = "testCreateAndRunAService")
@ -327,7 +299,7 @@ public abstract class BaseComputeServiceLiveTest {
template = buildTemplate(client.templateBuilder()); template = buildTemplate(client.templateBuilder());
template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public")) template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public"))
.runScript(newStringPayload(buildScript(template.getImage().getOperatingSystem()))); .runScript(newStringPayload(buildScript(template.getImage().getOperatingSystem())));
} }
protected void checkImageIdMatchesTemplate(NodeMetadata node) { protected void checkImageIdMatchesTemplate(NodeMetadata node) {
@ -338,8 +310,8 @@ public abstract class BaseComputeServiceLiveTest {
protected void checkOsMatchesTemplate(NodeMetadata node) { protected void checkOsMatchesTemplate(NodeMetadata node) {
if (node.getOperatingSystem() != null) if (node.getOperatingSystem() != null)
assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String
.format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node .format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(),
.getOperatingSystem()); node.getOperatingSystem());
} }
void assertLocationSameOrChild(Location test, Location expected) { void assertLocationSameOrChild(Location test, Location expected) {
@ -364,10 +336,10 @@ public abstract class BaseComputeServiceLiveTest {
} }
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String tag, OperatingSystem os, protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String tag, OperatingSystem os,
Credentials creds) throws RunScriptOnNodesException { Credentials creds) throws RunScriptOnNodesException {
try { try {
return client.runScriptOnNodesMatching(runningWithTag(tag), newStringPayload(buildScript(os)), return client.runScriptOnNodesMatching(runningWithTag(tag), newStringPayload(buildScript(os)),
overrideCredentialsWith(creds).nameTask("runScriptWithCreds")); overrideCredentialsWith(creds).nameTask("runScriptWithCreds"));
} catch (SshException e) { } catch (SshException e) {
throw e; throw e;
} }
@ -393,29 +365,18 @@ public abstract class BaseComputeServiceLiveTest {
return templateBuilder.build(); return templateBuilder.build();
} }
public static String buildScript(OperatingSystem os) {
if (OperatingSystemPredicates.supportsApt().apply(os))
return RunScriptData.APT_RUN_SCRIPT;
else if (OperatingSystemPredicates.supportsYum().apply(os))
return RunScriptData.YUM_RUN_SCRIPT;
else if (OperatingSystemPredicates.supportsZypper().apply(os))
return RunScriptData.ZYPPER_RUN_SCRIPT;
else
throw new IllegalArgumentException("don't know how to handle" + os.toString());
}
@Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") @Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired")
public void testGet() throws Exception { public void testGet() throws Exception {
Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(filter(client Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(
.listNodesDetailsMatching(all()), and(withTag(tag), not(TERMINATED))), filter(client.listNodesDetailsMatching(all()), and(withTag(tag), not(TERMINATED))),
new Function<NodeMetadata, String>() { new Function<NodeMetadata, String>() {
@Override @Override
public String apply(NodeMetadata from) { public String apply(NodeMetadata from) {
return from.getId(); return from.getId();
} }
})); }));
for (NodeMetadata node : nodes) { for (NodeMetadata node : nodes) {
metadataMap.remove(node.getId()); metadataMap.remove(node.getId());
NodeMetadata metadata = client.getNodeMetadata(node.getId()); NodeMetadata metadata = client.getNodeMetadata(node.getId());
@ -433,7 +394,7 @@ public abstract class BaseComputeServiceLiveTest {
protected void assertNodeZero(Collection<? extends NodeMetadata> metadataSet) { protected void assertNodeZero(Collection<? extends NodeMetadata> metadataSet) {
assert metadataSet.size() == 0 : String.format("nodes left in set: [%s] which didn't match set: [%s]", assert metadataSet.size() == 0 : String.format("nodes left in set: [%s] which didn't match set: [%s]",
metadataSet, nodes); metadataSet, nodes);
} }
@Test(enabled = true, dependsOnMethods = "testGet") @Test(enabled = true, dependsOnMethods = "testGet")
@ -494,26 +455,26 @@ public abstract class BaseComputeServiceLiveTest {
assert location != location.getParent() : location; assert location != location.getParent() : location;
assert location.getScope() != null : location; assert location.getScope() != null : location;
switch (location.getScope()) { switch (location.getScope()) {
case PROVIDER: case PROVIDER:
assertProvider(location); assertProvider(location);
break; break;
case REGION: case REGION:
assertProvider(location.getParent()); assertProvider(location.getParent());
break; break;
case ZONE: case ZONE:
Location provider = location.getParent().getParent(); Location provider = location.getParent().getParent();
// zone can be a direct descendant of provider // zone can be a direct descendant of provider
if (provider == null) if (provider == null)
provider = location.getParent(); provider = location.getParent();
assertProvider(provider); assertProvider(provider);
break; break;
case HOST: case HOST:
Location provider2 = location.getParent().getParent().getParent(); Location provider2 = location.getParent().getParent().getParent();
// zone can be a direct descendant of provider // zone can be a direct descendant of provider
if (provider2 == null) if (provider2 == null)
provider2 = location.getParent().getParent(); provider2 = location.getParent().getParent();
assertProvider(provider2); assertProvider(provider2);
break; break;
} }
} }
} }
@ -600,18 +561,21 @@ public abstract class BaseComputeServiceLiveTest {
// a socket conection // a socket conection
// state. // state.
SshClient ssh = (node.getCredentials().credential != null && !node.getCredentials().credential SshClient ssh = (node.getCredentials().credential != null && !node.getCredentials().credential
.startsWith("-----BEGIN RSA PRIVATE KEY-----")) ? context.utils().sshFactory().create(socket, .startsWith("-----BEGIN RSA PRIVATE KEY-----")) ? context.utils().sshFactory()
node.getCredentials().identity, node.getCredentials().credential) : context.utils().sshFactory().create( .create(socket, node.getCredentials().identity, node.getCredentials().credential) : context
socket, .utils()
node.getCredentials().identity, .sshFactory()
node.getCredentials().credential != null ? node.getCredentials().credential.getBytes() : keyPair.get( .create(
socket,
node.getCredentials().identity,
node.getCredentials().credential != null ? node.getCredentials().credential.getBytes() : keyPair.get(
"private").getBytes()); "private").getBytes());
try { try {
ssh.connect(); ssh.connect();
ExecResponse hello = ssh.exec("echo hello"); ExecResponse hello = ssh.exec("echo hello");
assertEquals(hello.getOutput().trim(), "hello"); assertEquals(hello.getOutput().trim(), "hello");
ExecResponse exec = ssh.exec("java -version"); ExecResponse exec = ssh.exec("java -version");
assert exec.getError().indexOf("OpenJDK") != -1 || exec.getOutput().indexOf("OpenJDK") != -1 : exec; assert exec.getError().indexOf("1.6") != -1 || exec.getOutput().indexOf("1.6") != -1 : exec;
} finally { } finally {
if (ssh != null) if (ssh != null)
ssh.disconnect(); ssh.disconnect();

View File

@ -0,0 +1,94 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.compute;
import static org.jclouds.util.Utils.checkNotEmpty;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.URI;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import static org.testng.Assert.assertEquals;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.predicates.OperatingSystemPredicates;
import org.jclouds.rest.HttpClient;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import static com.google.common.collect.Iterables.get;
/**
* utilities helpful in testing compute providers
*
* @author Adrian Cole
*/
public class ComputeTestUtils {
public static String buildScript(OperatingSystem os) {
if (OperatingSystemPredicates.supportsApt().apply(os))
return RunScriptData.APT_RUN_SCRIPT;
else if (OperatingSystemPredicates.supportsYum().apply(os))
return RunScriptData.YUM_RUN_SCRIPT;
else if (OperatingSystemPredicates.supportsZypper().apply(os))
return RunScriptData.ZYPPER_RUN_SCRIPT;
else
throw new IllegalArgumentException("don't know how to handle" + os.toString());
}
public static Map<String, String> setupKeyPair() throws FileNotFoundException, IOException {
String secretKeyFile;
try {
secretKeyFile = checkNotNull(System.getProperty("test.ssh.keyfile"), "test.ssh.keyfile");
} catch (NullPointerException e) {
secretKeyFile = System.getProperty("user.home") + "/.ssh/id_rsa";
}
checkSecretKeyFile(secretKeyFile);
String secret = Files.toString(new File(secretKeyFile), Charsets.UTF_8);
assert secret.startsWith("-----BEGIN RSA PRIVATE KEY-----") : "invalid key:\n" + secret;
return ImmutableMap.<String, String> of("private", secret, "public",
Files.toString(new File(secretKeyFile + ".pub"), Charsets.UTF_8));
}
public static void checkSecretKeyFile(String secretKeyFile) throws FileNotFoundException {
checkNotEmpty(secretKeyFile, "System property: [test.ssh.keyfile] set to an empty string");
if (!new File(secretKeyFile).exists()) {
throw new FileNotFoundException("secretKeyFile not found at: " + secretKeyFile);
}
}
public static void checkHttpGet(HttpClient client, NodeMetadata node, int port) {
for (int i = 0; i < 5; i++)
try {
assert client.get(URI.create(String.format("http://%s:%d", get(node.getPublicAddresses(), 0), port))) != null;
break;
} catch (UndeclaredThrowableException e) {
assertEquals(e.getCause().getClass(), TimeoutException.class);
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
}
}
}
}

View File

@ -19,7 +19,7 @@
package org.jclouds.compute; package org.jclouds.compute;
import static org.jclouds.compute.util.ComputeServiceUtils.extractZipIntoDirectory; import static org.jclouds.compute.util.ComputeServiceUtils.extractTargzIntoDirectory;
import static org.jclouds.scriptbuilder.domain.Statements.exec; import static org.jclouds.scriptbuilder.domain.Statements.exec;
import static org.jclouds.scriptbuilder.domain.Statements.interpret; import static org.jclouds.scriptbuilder.domain.Statements.interpret;
@ -40,8 +40,7 @@ import com.google.common.collect.ImmutableMap;
* @author Adrian Cole * @author Adrian Cole
*/ */
public class RunScriptData { public class RunScriptData {
private static String jbossVersion = "5.0.0.CR2";
private static String jboss = String.format("jboss-%s-jdk6", jbossVersion);
private static String jbossHome = "/usr/local/jboss"; private static String jbossHome = "/usr/local/jboss";
public static String createScriptInstallBase(OperatingSystem os) { public static String createScriptInstallBase(OperatingSystem os) {
@ -58,52 +57,52 @@ public class RunScriptData {
public static Statement createScriptInstallAndStartJBoss(String publicKey, OperatingSystem os) { public static Statement createScriptInstallAndStartJBoss(String publicKey, OperatingSystem os) {
Map<String, String> envVariables = ImmutableMap.of("jbossHome", jbossHome); Map<String, String> envVariables = ImmutableMap.of("jbossHome", jbossHome);
Statement toReturn = new InitBuilder( Statement toReturn = new InitBuilder(
"jboss", "jboss",
jbossHome, jbossHome,
jbossHome, jbossHome,
envVariables, envVariables,
ImmutableList.<Statement> of(new AuthorizeRSAPublicKey(publicKey), exec(createScriptInstallBase(os)), ImmutableList.<Statement> of(
extractZipIntoDirectory(URI.create(String.format( new AuthorizeRSAPublicKey(publicKey),
"http://superb-sea2.dl.sourceforge.net/project/jboss/JBoss/JBoss-%s/%s.zip", exec(createScriptInstallBase(os)),
jbossVersion, jboss)), "/usr/local"), exec("{md} " + jbossHome), exec("rm -rf /var/cache/apt /usr/lib/vmware-tools"),// jeos hasn't enough room!
exec("mv /usr/local/jboss-" + jbossVersion + "/* " + jbossHome)), extractTargzIntoDirectory(
ImmutableList URI.create("http://commondatastorage.googleapis.com/jclouds-repo/jboss-as-distribution-6.0.0.20100911-M5.tar.gz"),
.<Statement> of(interpret("java -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs=lib/endorsed -classpath bin/run.jar org.jboss.Main -b 0.0.0.0"))); "/usr/local"), exec("{md} " + jbossHome), exec("mv /usr/local/jboss-*/* " + jbossHome),
exec("chmod -R oug+r+w " + jbossHome)),
ImmutableList
.<Statement> of(interpret("java -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs=lib/endorsed -classpath bin/run.jar org.jboss.Main -b 0.0.0.0")));
return toReturn; return toReturn;
} }
public static final String APT_RUN_SCRIPT = new StringBuilder()// public static final String APT_RUN_SCRIPT = new StringBuilder()//
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
.append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")// .append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")//
.append( .append(
"sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")// "sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")//
.append("apt-get update -y -qq\n")// .append("which curl || apt-get update -y -qq && apt-get install -f -y -qq --force-yes curl\n")//
.append("apt-get install -f -y -qq --force-yes curl\n")// .append(
.append("apt-get install -f -y -qq --force-yes unzip\n")// "(which java && java -fullversion 2>&1|egrep -q 1.6 ) || apt-get install -f -y -qq --force-yes openjdk-6-jre\n")//
.append("apt-get install -f -y -qq --force-yes openjdk-6-jdk\n")// .append("rm -rf /var/cache/apt /usr/lib/vmware-tools\n")// jeos hasn't enough room!
.toString(); .toString();
public static final String YUM_RUN_SCRIPT = new StringBuilder() public static final String YUM_RUN_SCRIPT = new StringBuilder()
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") //
// .append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n") //
.append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n") .append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n") //
// .append(
.append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n") "echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")//
// .append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")//
.append( // .append("which unzip ||yum --nogpgcheck -y install unzip\n")//
"echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")// .append("which curl ||yum --nogpgcheck -y install curl\n")//
.append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")// .append(
.append("yum --nogpgcheck -y install unzip\n")// "(which java && java -fullversion 2>&1|egrep -q 1.6 ) || yum --nogpgcheck -y install java-1.6.0-openjdk&&")//
.append("yum --nogpgcheck -y install curl\n")// .append("echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n")//
.append("yum --nogpgcheck -y install java-1.6.0-openjdk\n")// .toString();
.append("echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n")//
.toString();
public static final String ZYPPER_RUN_SCRIPT = new StringBuilder()// public static final String ZYPPER_RUN_SCRIPT = new StringBuilder()//
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
.append("sudo zypper install unzip\n")// // .append("which unzip ||sudo zypper install unzip\n")//
.append("sudo zypper install curl\n")// .append("which curl || zypper install curl\n")//
.append("sudo zypper install java-1.6.0-openjdk-devl\n")// .append("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk\n")//
.toString(); .toString();
} }

View File

@ -32,7 +32,6 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -105,7 +104,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
} }
@Override @Override
protected void checkHttpGet(TreeSet<NodeMetadata> nodes) { protected void checkHttpGet(NodeMetadata node) {
} }
@ -228,7 +227,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
client.connect(); client.connect();
expect(client.exec("echo hello")).andReturn(new ExecResponse("hello", "", 0)); expect(client.exec("echo hello")).andReturn(new ExecResponse("hello", "", 0));
expect(client.exec("java -version")).andReturn(new ExecResponse("", "OpenJDK", 0)); expect(client.exec("java -version")).andReturn(new ExecResponse("", "1.6", 0));
client.disconnect(); client.disconnect();
} }

View File

@ -79,10 +79,9 @@ cd $INSTANCE_HOME
echo nameserver 208.67.222.222 >> /etc/resolv.conf echo nameserver 208.67.222.222 >> /etc/resolv.conf
cp /etc/apt/sources.list /etc/apt/sources.list.old cp /etc/apt/sources.list /etc/apt/sources.list.old
sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list
apt-get update -y -qq which curl || apt-get update -y -qq && apt-get install -f -y -qq --force-yes curl
apt-get install -f -y -qq --force-yes curl (which java && java -fullversion 2>&1|egrep -q 1.6 ) || apt-get install -f -y -qq --force-yes openjdk-6-jre
apt-get install -f -y -qq --force-yes unzip rm -rf /var/cache/apt /usr/lib/vmware-tools
apt-get install -f -y -qq --force-yes openjdk-6-jdk
mkdir -p ~/.ssh mkdir -p ~/.ssh
cat >> ~/.ssh/authorized_keys <<'END_OF_FILE' cat >> ~/.ssh/authorized_keys <<'END_OF_FILE'

View File

@ -66,14 +66,15 @@ END_OF_FILE
echo nameserver 208.67.222.222 >> /etc/resolv.conf echo nameserver 208.67.222.222 >> /etc/resolv.conf
cp /etc/apt/sources.list /etc/apt/sources.list.old cp /etc/apt/sources.list /etc/apt/sources.list.old
sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list
apt-get update -y -qq which curl || apt-get update -y -qq && apt-get install -f -y -qq --force-yes curl
apt-get install -f -y -qq --force-yes curl (which java && java -fullversion 2>&1|egrep -q 1.6 ) || apt-get install -f -y -qq --force-yes openjdk-6-jre
apt-get install -f -y -qq --force-yes unzip rm -rf /var/cache/apt /usr/lib/vmware-tools
apt-get install -f -y -qq --force-yes openjdk-6-jdk
(mkdir -p /usr/local &&cd /usr/local &&curl -X GET -s --retry 20 http://superb-sea2.dl.sourceforge.net/project/jboss/JBoss/JBoss-5.0.0.CR2/jboss-5.0.0.CR2-jdk6.zip >extract.zip && unzip -o -qq extract.zip&& rm extract.zip) rm -rf /var/cache/apt /usr/lib/vmware-tools
curl -X GET -s --retry 20 http://commondatastorage.googleapis.com/jclouds-repo/jboss-as-distribution-6.0.0.20100911-M5.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mkdir -p /usr/local/jboss mkdir -p /usr/local/jboss
mv /usr/local/jboss-5.0.0.CR2/* /usr/local/jboss mv /usr/local/jboss-*/* /usr/local/jboss
chmod -R oug+r+w /usr/local/jboss
mkdir -p $INSTANCE_HOME mkdir -p $INSTANCE_HOME
# create runscript header # create runscript header

View File

@ -79,10 +79,9 @@ cd $INSTANCE_HOME
echo nameserver 208.67.222.222 >> /etc/resolv.conf echo nameserver 208.67.222.222 >> /etc/resolv.conf
cp /etc/apt/sources.list /etc/apt/sources.list.old cp /etc/apt/sources.list /etc/apt/sources.list.old
sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list
apt-get update -y -qq which curl || apt-get update -y -qq && apt-get install -f -y -qq --force-yes curl
apt-get install -f -y -qq --force-yes curl (which java && java -fullversion 2>&1|egrep -q 1.6 ) || apt-get install -f -y -qq --force-yes openjdk-6-jre
apt-get install -f -y -qq --force-yes unzip rm -rf /var/cache/apt /usr/lib/vmware-tools
apt-get install -f -y -qq --force-yes openjdk-6-jdk
END_OF_SCRIPT END_OF_SCRIPT

View File

@ -54,7 +54,6 @@ public class InitBuilder extends ScriptBuilder {
this(instanceName, instanceHome, logDir, variables, ImmutableSet.<Statement>of(), statements); this(instanceName, instanceHome, logDir, variables, ImmutableSet.<Statement>of(), statements);
} }
@SuppressWarnings("unchecked")
public InitBuilder(String instanceName, String instanceHome, String logDir, Map<String, String> variables, public InitBuilder(String instanceName, String instanceHome, String logDir, Map<String, String> variables,
Iterable<Statement> initStatements, Iterable<Statement> statements) { Iterable<Statement> initStatements, Iterable<Statement> statements) {
this.instanceName = checkNotNull(instanceName, "instanceName"); this.instanceName = checkNotNull(instanceName, "instanceName");
@ -67,7 +66,7 @@ public class InitBuilder extends ScriptBuilder {
.addStatement( .addStatement(
switchArg( switchArg(
1, 1,
new ImmutableMap.Builder() new ImmutableMap.Builder<String,Statement>()
.put( .put(
"init", "init",
newStatementList(call("default"), call(instanceName), newStatementList(call("default"), call(instanceName),