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;
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.util.ComputeServiceUtils.execHttpResponse;
import static org.jclouds.compute.util.ComputeServiceUtils.extractTargzIntoDirectory;
@ -89,8 +89,8 @@ public class ComputeAndBlobStoreTogetherHappilyLiveTest extends BlobStoreAndComp
// if we want to, we can mix and match batched and ad-hoc commands, such as extracting maven
String mavenVersion = "3.0-beta-3";
Statement extractMavenIntoUsrLocal = extractTargzIntoDirectory(URI
.create("http://mirrors.ibiblio.org/pub/mirrors/apache//maven/binaries/apache-maven-" + mavenVersion
Statement extractMavenIntoUsrLocal = extractTargzIntoDirectory(
URI.create("http://mirrors.ibiblio.org/pub/mirrors/apache//maven/binaries/apache-maven-" + mavenVersion
+ "-bin.tar.gz"), "/usr/local");
// have both of these commands occur on boot

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.collect.Iterables.get;
import static org.jclouds.compute.ComputeTestUtils.setupKeyPair;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -31,7 +32,6 @@ import org.jclouds.Constants;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.NodeMetadata;
@ -80,16 +80,17 @@ public class BlobStoreAndComputeServiceLiveTest {
}
protected void setupKeyPairForTest() throws FileNotFoundException, IOException {
keyPair = BaseComputeServiceLiveTest.setupKeyPair();
keyPair = setupKeyPair();
}
@BeforeGroups(groups = { "live" })
public void setupClient() throws FileNotFoundException, IOException {
setupKeyPairForTest();
computeContext = new ComputeServiceContextFactory().createContext(computeServiceProvider, ImmutableSet.of(
new Log4JLoggingModule(), new JschSshClientModule()), setupCredentials(computeServiceProvider));
blobContext = new BlobStoreContextFactory().createContext(blobStoreProvider, ImmutableSet
.of(new Log4JLoggingModule()), setupCredentials(blobStoreProvider));
computeContext = new ComputeServiceContextFactory().createContext(computeServiceProvider,
ImmutableSet.of(new Log4JLoggingModule(), new JschSshClientModule()),
setupCredentials(computeServiceProvider));
blobContext = new BlobStoreContextFactory().createContext(blobStoreProvider,
ImmutableSet.of(new Log4JLoggingModule()), setupCredentials(blobStoreProvider));
blobContext.getAsyncBlobStore().createContainerInLocation(null, tag);
computeContext.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag));
}
@ -98,8 +99,8 @@ public class BlobStoreAndComputeServiceLiveTest {
for (NodeMetadata node : nodes) {
IPSocket socket = new IPSocket(get(node.getPublicAddresses(), 0), 22);
SshClient ssh = computeContext.utils().sshFactory().create(socket, node.getCredentials().identity,
node.getCredentials().credential.getBytes());
SshClient ssh = computeContext.utils().sshFactory()
.create(socket, node.getCredentials().identity, node.getCredentials().credential.getBytes());
try {
ssh.connect();
ExecResponse exec = ssh.exec(cmd);

View File

@ -20,7 +20,13 @@
package org.jclouds.aws.ec2.services;
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.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.predicates.PlacementGroupAvailable;
import org.jclouds.aws.ec2.predicates.PlacementGroupDeleted;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
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.Throwables;
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;
/**
@ -108,9 +110,9 @@ public class PlacementGroupClientLiveTest {
public void setupClient() throws FileNotFoundException, IOException {
setupCredentials();
Properties overrides = setupProperties();
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet
.<Module> of(new Log4JLoggingModule()), overrides);
keyPair = BaseComputeServiceLiveTest.setupKeyPair();
context = new ComputeServiceContextFactory().createContext(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides);
keyPair = setupKeyPair();
client = EC2Client.class.cast(context.getProviderSpecificContext().getApi());
@ -122,13 +124,13 @@ public class PlacementGroupClientLiveTest {
@Test
void testDescribe() {
for (String region : Lists.newArrayList(Region.US_EAST_1)) {
SortedSet<PlacementGroup> allResults = Sets.newTreeSet(client.getPlacementGroupServices()
for (String region : newArrayList(Region.US_EAST_1)) {
SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupServices()
.describePlacementGroupsInRegion(region));
assertNotNull(allResults);
if (allResults.size() >= 1) {
PlacementGroup group = allResults.last();
SortedSet<PlacementGroup> result = Sets.newTreeSet(client.getPlacementGroupServices()
SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupServices()
.describePlacementGroupsInRegion(region, group.getName()));
assertNotNull(result);
PlacementGroup compare = result.last();
@ -136,7 +138,7 @@ public class PlacementGroupClientLiveTest {
}
}
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 {
client.getPlacementGroupServices().describePlacementGroupsInRegion(region);
assert false : "should be unsupported";
@ -169,7 +171,7 @@ public class PlacementGroupClientLiveTest {
public void testStartCCInstance() throws Exception {
Set<? extends Hardware> sizes = context.getComputeService().listHardwareProfiles();
assert Iterables.any(sizes, new Predicate<Hardware>() {
assert any(sizes, new Predicate<Hardware>() {
@Override
public boolean apply(Hardware arg0) {
@ -178,7 +180,7 @@ public class PlacementGroupClientLiveTest {
}) : sizes;
Set<? extends Image> images = context.getComputeService().listImages();
assert Iterables.any(images, new Predicate<Image>() {
assert any(images, new Predicate<Image>() {
@Override
public boolean apply(Image arg0) {
@ -193,18 +195,16 @@ public class PlacementGroupClientLiveTest {
assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17");
template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public"))
.runScript(
newStringPayload(BaseComputeServiceLiveTest.buildScript(template.getImage()
.getOperatingSystem())));
.runScript(exec(buildScript(template.getImage().getOperatingSystem())));
String tag = PREFIX + "cccluster";
context.getComputeService().destroyNodesMatching(NodePredicates.withTag(tag));
try {
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())));
} catch (RunNodesException e) {

View File

@ -162,11 +162,12 @@
<priority value="DEBUG" />
<appender-ref ref="ASYNCSSH" />
</category>
<!--
<category name="jclouds.wire">
<priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" />
</category>
-->
<category name="jclouds.blobstore">
<priority value="DEBUG" />
<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.Sets.filter;
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.overrideCredentialsWith;
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.assertNotNull;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
import java.util.Map;
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.TemplateBuilder;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.predicates.OperatingSystemPredicates;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
@ -79,16 +77,12 @@ import org.jclouds.rest.AuthorizationException;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.jclouds.util.Utils;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.Files;
import com.google.inject.Guice;
import com.google.inject.Module;
@ -119,21 +113,7 @@ public abstract class BaseComputeServiceLiveTest {
}
protected void setupKeyPairForTest() throws FileNotFoundException, IOException {
keyPair = 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));
keyPair = ComputeTestUtils.setupKeyPair();
}
protected String provider;
@ -178,18 +158,11 @@ public abstract class BaseComputeServiceLiveTest {
if (context != null)
context.close();
Properties props = setupProperties();
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.of(new Log4JLoggingModule(),
getSshModule()), props);
context = new ComputeServiceContextFactory().createContext(provider,
ImmutableSet.of(new Log4JLoggingModule(), getSshModule()), props);
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();
// wait up to 5 seconds for an auth exception
@ -197,8 +170,8 @@ public abstract class BaseComputeServiceLiveTest {
public void testCorrectAuthException() throws Exception {
ComputeServiceContext context = null;
try {
context = new ComputeServiceContextFactory().createContext(provider, "MOMMA", "MIA", ImmutableSet
.<Module> of(new Log4JLoggingModule()));
context = new ComputeServiceContextFactory().createContext(provider, "MOMMA", "MIA",
ImmutableSet.<Module> of(new Log4JLoggingModule()));
context.getComputeService().listNodes();
} catch (AuthorizationException e) {
throw 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();
// note this is a dependency on the template resolution
template.getOptions().runScript(
RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage()
.getOperatingSystem()));
try {
TreeSet<NodeMetadata> nodes = newTreeSet(client.runNodesWithTag(tag, 1, template));
NodeMetadata node = getOnlyElement(client.runNodesWithTag(tag, 1, template));
checkHttpGet(nodes);
checkHttpGet(node);
} finally {
client.destroyNodesMatching(withTag(tag));
}
}
protected void checkHttpGet(TreeSet<NodeMetadata> nodes) {
assert context.utils().http().get(
URI.create(String.format("http://%s:8080", get(nodes.last().getPublicAddresses(), 0)))) != null;
protected void checkHttpGet(NodeMetadata node) {
ComputeTestUtils.checkHttpGet(context.utils().http(), node, 8080);
}
@Test(enabled = true, dependsOnMethods = "testCreateAndRunAService")
@ -338,8 +310,8 @@ public abstract class BaseComputeServiceLiveTest {
protected void checkOsMatchesTemplate(NodeMetadata node) {
if (node.getOperatingSystem() != null)
assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String
.format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node
.getOperatingSystem());
.format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(),
node.getOperatingSystem());
}
void assertLocationSameOrChild(Location test, Location expected) {
@ -393,21 +365,10 @@ public abstract class BaseComputeServiceLiveTest {
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")
public void testGet() throws Exception {
Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(filter(client
.listNodesDetailsMatching(all()), and(withTag(tag), not(TERMINATED))),
Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(
filter(client.listNodesDetailsMatching(all()), and(withTag(tag), not(TERMINATED))),
new Function<NodeMetadata, String>() {
@Override
@ -600,8 +561,11 @@ public abstract class BaseComputeServiceLiveTest {
// a socket conection
// state.
SshClient ssh = (node.getCredentials().credential != null && !node.getCredentials().credential
.startsWith("-----BEGIN RSA PRIVATE KEY-----")) ? context.utils().sshFactory().create(socket,
node.getCredentials().identity, node.getCredentials().credential) : context.utils().sshFactory().create(
.startsWith("-----BEGIN RSA PRIVATE KEY-----")) ? context.utils().sshFactory()
.create(socket, node.getCredentials().identity, node.getCredentials().credential) : context
.utils()
.sshFactory()
.create(
socket,
node.getCredentials().identity,
node.getCredentials().credential != null ? node.getCredentials().credential.getBytes() : keyPair.get(
@ -611,7 +575,7 @@ public abstract class BaseComputeServiceLiveTest {
ExecResponse hello = ssh.exec("echo hello");
assertEquals(hello.getOutput().trim(), "hello");
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 {
if (ssh != null)
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;
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.interpret;
@ -40,8 +40,7 @@ import com.google.common.collect.ImmutableMap;
* @author Adrian Cole
*/
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";
public static String createScriptInstallBase(OperatingSystem os) {
@ -62,11 +61,14 @@ public class RunScriptData {
jbossHome,
jbossHome,
envVariables,
ImmutableList.<Statement> of(new AuthorizeRSAPublicKey(publicKey), exec(createScriptInstallBase(os)),
extractZipIntoDirectory(URI.create(String.format(
"http://superb-sea2.dl.sourceforge.net/project/jboss/JBoss/JBoss-%s/%s.zip",
jbossVersion, jboss)), "/usr/local"), exec("{md} " + jbossHome),
exec("mv /usr/local/jboss-" + jbossVersion + "/* " + jbossHome)),
ImmutableList.<Statement> of(
new AuthorizeRSAPublicKey(publicKey),
exec(createScriptInstallBase(os)),
exec("rm -rf /var/cache/apt /usr/lib/vmware-tools"),// jeos hasn't enough room!
extractTargzIntoDirectory(
URI.create("http://commondatastorage.googleapis.com/jclouds-repo/jboss-as-distribution-6.0.0.20100911-M5.tar.gz"),
"/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;
@ -77,33 +79,30 @@ public class RunScriptData {
.append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")//
.append(
"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("apt-get install -f -y -qq --force-yes curl\n")//
.append("apt-get install -f -y -qq --force-yes unzip\n")//
.append("apt-get install -f -y -qq --force-yes openjdk-6-jdk\n")//
.append("which curl || apt-get update -y -qq && apt-get install -f -y -qq --force-yes curl\n")//
.append(
"(which java && java -fullversion 2>&1|egrep -q 1.6 ) || apt-get install -f -y -qq --force-yes openjdk-6-jre\n")//
.append("rm -rf /var/cache/apt /usr/lib/vmware-tools\n")// jeos hasn't enough room!
.toString();
public static final String YUM_RUN_SCRIPT = new StringBuilder()
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\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("echo nameserver 208.67.222.222 >> /etc/resolv.conf\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(
"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("yum --nogpgcheck -y install unzip\n")//
.append("yum --nogpgcheck -y install curl\n")//
.append("yum --nogpgcheck -y install java-1.6.0-openjdk\n")//
// .append("which unzip ||yum --nogpgcheck -y install unzip\n")//
.append("which curl ||yum --nogpgcheck -y install curl\n")//
.append(
"(which java && java -fullversion 2>&1|egrep -q 1.6 ) || yum --nogpgcheck -y install java-1.6.0-openjdk&&")//
.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()//
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
.append("sudo zypper install unzip\n")//
.append("sudo zypper install curl\n")//
.append("sudo zypper install java-1.6.0-openjdk-devl\n")//
// .append("which unzip ||sudo zypper install unzip\n")//
.append("which curl || zypper install curl\n")//
.append("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk\n")//
.toString();
}

View File

@ -32,7 +32,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Serializable;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@ -105,7 +104,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
}
@Override
protected void checkHttpGet(TreeSet<NodeMetadata> nodes) {
protected void checkHttpGet(NodeMetadata node) {
}
@ -228,7 +227,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
client.connect();
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();
}

View File

@ -79,10 +79,9 @@ cd $INSTANCE_HOME
echo nameserver 208.67.222.222 >> /etc/resolv.conf
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
apt-get update -y -qq
apt-get install -f -y -qq --force-yes curl
apt-get install -f -y -qq --force-yes unzip
apt-get install -f -y -qq --force-yes openjdk-6-jdk
which curl || apt-get update -y -qq && 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
rm -rf /var/cache/apt /usr/lib/vmware-tools
mkdir -p ~/.ssh
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
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
apt-get update -y -qq
apt-get install -f -y -qq --force-yes curl
apt-get install -f -y -qq --force-yes unzip
apt-get install -f -y -qq --force-yes openjdk-6-jdk
which curl || apt-get update -y -qq && 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
rm -rf /var/cache/apt /usr/lib/vmware-tools
(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
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
# create runscript header

View File

@ -79,10 +79,9 @@ cd $INSTANCE_HOME
echo nameserver 208.67.222.222 >> /etc/resolv.conf
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
apt-get update -y -qq
apt-get install -f -y -qq --force-yes curl
apt-get install -f -y -qq --force-yes unzip
apt-get install -f -y -qq --force-yes openjdk-6-jdk
which curl || apt-get update -y -qq && 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
rm -rf /var/cache/apt /usr/lib/vmware-tools
END_OF_SCRIPT

View File

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