mirror of https://github.com/apache/jclouds.git
Issue 130: corrected type where UMBUNTU should have been UBUNTU, started integrating cargo
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2630 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
340d58e030
commit
befd1f0a4e
|
@ -83,7 +83,7 @@ public class EC2ComputeService implements ComputeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Image, String> imageAmiIdMap = ImmutableMap.<Image, String> builder().put(
|
private Map<Image, String> imageAmiIdMap = ImmutableMap.<Image, String> builder().put(
|
||||||
Image.UMBUNTU_90, "ami-7e28ca17").put(Image.RHEL_53, "ami-368b685f").build();// todo ami
|
Image.UBUNTU_90, "ami-7e28ca17").put(Image.RHEL_53, "ami-368b685f").build();// todo ami
|
||||||
// matrix of
|
// matrix of
|
||||||
// region
|
// region
|
||||||
// 32/64 bit
|
// 32/64 bit
|
||||||
|
@ -107,8 +107,11 @@ public class EC2ComputeService implements ComputeService {
|
||||||
createSecurityGroup(securityGroupName, 22, 80, 8080, 443);
|
createSecurityGroup(securityGroupName, 22, 80, 8080, 443);
|
||||||
|
|
||||||
String script = new ScriptBuilder() // update and install jdk
|
String script = new ScriptBuilder() // update and install jdk
|
||||||
.addStatement(exec("runurl run.alestic.com/apt/upgrade"))//
|
.addStatement(exec("apt-get update"))//
|
||||||
|
.addStatement(exec("apt-get upgrade -y"))//
|
||||||
.addStatement(exec("apt-get install -y openjdk-6-jdk"))//
|
.addStatement(exec("apt-get install -y openjdk-6-jdk"))//
|
||||||
|
.addStatement(exec("wget -qO/usr/bin/runurl run.alestic.com/runurl"))//
|
||||||
|
.addStatement(exec("chmod 755 /usr/bin/runurl"))//
|
||||||
.build(OsFamily.UNIX);
|
.build(OsFamily.UNIX);
|
||||||
|
|
||||||
logger.debug(">> running instance ami(%s) type(%s) keyPair(%s) securityGroup(%s)", ami, type,
|
logger.debug(">> running instance ami(%s) type(%s) keyPair(%s) securityGroup(%s)", ami, type,
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static org.jclouds.aws.sqs.options.ListQueuesOptions.Builder.queuePrefix;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
@ -33,7 +32,6 @@ import org.jclouds.enterprise.config.EnterpriseConfigurationModule;
|
||||||
import org.jclouds.logging.config.NullLoggingModule;
|
import org.jclouds.logging.config.NullLoggingModule;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
@ -56,58 +54,53 @@ public class SpeedTest {
|
||||||
if (args.length < PARAMETERS)
|
if (args.length < PARAMETERS)
|
||||||
throw new IllegalArgumentException(INVALID_SYNTAX);
|
throw new IllegalArgumentException(INVALID_SYNTAX);
|
||||||
|
|
||||||
|
boolean isEnterprise = System.getProperties().containsKey("jclouds.enterprise");
|
||||||
// Args
|
// Args
|
||||||
String accesskeyid = args[0];
|
String accesskeyid = args[0];
|
||||||
String secretkey = args[1];
|
String secretkey = args[1];
|
||||||
String queueName = args[2];
|
String queueName = args[2];
|
||||||
int messageCount = Integer.parseInt(args[3]);
|
int messageCount = Integer.parseInt(args[3]);
|
||||||
|
|
||||||
RestContext<SQSAsyncClient, SQSClient> nullLoggingDefaultContext = SQSContextFactory
|
RestContext<SQSAsyncClient, SQSClient> context = isEnterprise ? SQSContextFactory
|
||||||
.createContext(System.getProperties(), accesskeyid, secretkey,
|
.createContext(System.getProperties(), accesskeyid, secretkey,
|
||||||
|
new NullLoggingModule(), new EnterpriseConfigurationModule())
|
||||||
|
: SQSContextFactory.createContext(System.getProperties(), accesskeyid, secretkey,
|
||||||
new NullLoggingModule());
|
new NullLoggingModule());
|
||||||
|
|
||||||
RestContext<SQSAsyncClient, SQSClient> nullLoggingEnterpriseContext = SQSContextFactory
|
|
||||||
.createContext(System.getProperties(), accesskeyid, secretkey,
|
|
||||||
new NullLoggingModule(), new EnterpriseConfigurationModule());
|
|
||||||
try {
|
try {
|
||||||
Set<Queue> queues = Sets.newHashSet();
|
Set<Queue> queues = Sets.newHashSet();
|
||||||
if (purgeQueues(queueName, nullLoggingDefaultContext)) {
|
if (purgeQueues(queueName, context)) {
|
||||||
System.out.printf("pausing 60 seconds before recreating queues%n");
|
System.out.printf("pausing 60 seconds before recreating queues%n");
|
||||||
Thread.sleep(60 * 1000);
|
Thread.sleep(60 * 1000);
|
||||||
}
|
}
|
||||||
createQueues(queueName, nullLoggingDefaultContext, queues);
|
createQueues(queueName, context, queues);
|
||||||
runTests(messageCount, nullLoggingDefaultContext, nullLoggingEnterpriseContext, queues);
|
runTests(messageCount, isEnterprise ? "enterprise" : "default", context, queues);
|
||||||
} finally {
|
} finally {
|
||||||
purgeQueues(queueName, nullLoggingDefaultContext);
|
purgeQueues(queueName, context);
|
||||||
// Close connectons
|
// Close connectons
|
||||||
nullLoggingDefaultContext.close();
|
context.close();
|
||||||
nullLoggingEnterpriseContext.close();
|
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void runTests(int messageCount,
|
private static void runTests(int messageCount, String contextName,
|
||||||
RestContext<SQSAsyncClient, SQSClient> nullLoggingDefaultContext,
|
RestContext<SQSAsyncClient, SQSClient> context, Set<Queue> queues)
|
||||||
RestContext<SQSAsyncClient, SQSClient> nullLoggingEnterpriseContext, Set<Queue> queues)
|
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
String message = "1";
|
String message = "1";
|
||||||
long timeOut = messageCount * 200; // minimum rate should be at least 5/second
|
long timeOut = messageCount * 200; // minimum rate should be at least 5/second
|
||||||
|
|
||||||
for (Entry<String, RestContext<SQSAsyncClient, SQSClient>> entry : ImmutableMap
|
|
||||||
.<String, RestContext<SQSAsyncClient, SQSClient>> of("enterprise",
|
|
||||||
nullLoggingEnterpriseContext, "default", nullLoggingDefaultContext)
|
|
||||||
.entrySet()) {
|
|
||||||
for (Queue queue : queues) {
|
for (Queue queue : queues) {
|
||||||
|
|
||||||
int complete = 0;
|
int complete = 0;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
Set<ListenableFuture<byte[]>> responses = Sets.newHashSet();
|
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// fire off all the messages for the test
|
||||||
|
Set<ListenableFuture<byte[]>> responses = Sets.newHashSet();
|
||||||
for (int i = 0; i < messageCount; i++) {
|
for (int i = 0; i < messageCount; i++) {
|
||||||
responses.add(entry.getValue().getAsyncApi().sendMessage(queue, message));
|
responses.add(context.getAsyncApi().sendMessage(queue, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Set<ListenableFuture<byte[]>> retries = Sets.newHashSet();
|
Set<ListenableFuture<byte[]>> retries = Sets.newHashSet();
|
||||||
for (ListenableFuture<byte[]> response : responses) {
|
for (ListenableFuture<byte[]> response : responses) {
|
||||||
|
@ -126,18 +119,15 @@ public class SpeedTest {
|
||||||
long duration = System.currentTimeMillis() - start;
|
long duration = System.currentTimeMillis() - start;
|
||||||
if (duration > timeOut)
|
if (duration > timeOut)
|
||||||
System.out.printf("TIMEOUT: context: %s, region: %s, rate: %f messages/second%n",
|
System.out.printf("TIMEOUT: context: %s, region: %s, rate: %f messages/second%n",
|
||||||
entry.getKey(), queue.getRegion(), ((double) complete)
|
contextName, queue.getRegion(), ((double) complete) / (duration / 1000.0));
|
||||||
/ (duration / 1000.0));
|
|
||||||
else
|
else
|
||||||
System.out.printf("COMPLETE: context: %s, region: %s, rate: %f messages/second%n",
|
System.out.printf("COMPLETE: context: %s, region: %s, rate: %f messages/second%n",
|
||||||
entry.getKey(), queue.getRegion(), ((double) complete)
|
contextName, queue.getRegion(), ((double) complete) / (duration / 1000.0));
|
||||||
/ (duration / 1000.0));
|
|
||||||
System.out.println("pausing 5 seconds before the next run");
|
|
||||||
System.gc();
|
System.gc();
|
||||||
|
System.out.println("pausing 5 seconds before the next run");
|
||||||
Thread.sleep(5000);// let the network quiet down
|
Thread.sleep(5000);// let the network quiet down
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static void createQueues(String queueName,
|
private static void createQueues(String queueName,
|
||||||
RestContext<SQSAsyncClient, SQSClient> nullLoggingDefaultContext, Set<Queue> queues) {
|
RestContext<SQSAsyncClient, SQSClient> nullLoggingDefaultContext, Set<Queue> queues) {
|
||||||
|
|
|
@ -22,5 +22,5 @@ package org.jclouds.compute.domain;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public enum Image {
|
public enum Image {
|
||||||
CENTOS_53, RHEL_53, UMBUNTU_90, UMBUNTU_JEOS
|
CENTOS_53, RHEL_53, UBUNTU_90, UBUNTU_JEOS
|
||||||
}
|
}
|
|
@ -51,7 +51,7 @@ public class RimuHostingComputeService implements ComputeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Image, String> imageNameMap = ImmutableMap.<Image, String> builder().put(
|
private Map<Image, String> imageNameMap = ImmutableMap.<Image, String> builder().put(
|
||||||
Image.CENTOS_53, "centos53").put(Image.UMBUNTU_90, "ubuntu904").build();
|
Image.CENTOS_53, "centos53").put(Image.UBUNTU_90, "ubuntu904").build();
|
||||||
private Map<Profile, String> profileNameMap = ImmutableMap.<Profile, String> builder().put(
|
private Map<Profile, String> profileNameMap = ImmutableMap.<Profile, String> builder().put(
|
||||||
Profile.SMALLEST, "MIRO1B").build();
|
Profile.SMALLEST, "MIRO1B").build();
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
<target name="create" description="create the server ${jclouds.compute.servername}" >
|
<target name="create" description="create the server ${jclouds.compute.servername}" >
|
||||||
<compute action="create" provider="${jclouds.compute.url}">
|
<compute action="create" provider="${jclouds.compute.url}">
|
||||||
<server name="${jclouds.compute.servername}" image="CENTOS_53" profile="SMALLEST" />
|
<server name="${jclouds.compute.servername}" image="UBUNTU_90" profile="SMALLEST" />
|
||||||
</compute>
|
</compute>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
host=localhost
|
||||||
|
username=${user.name}
|
||||||
|
keyfile=${user.home}/.ssh/id_dsa
|
||||||
|
account=email@registered.with.terremark.org
|
||||||
|
key=your_password
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2009 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
<project xmlns:artifact="urn:maven-artifact-ant" name="cargooverssh" default="cargooverssh" basedir=".">
|
||||||
|
<property file="build.properties" />
|
||||||
|
<input message="Please enter the ip or hostname of the ssh machine" addproperty="host"/>
|
||||||
|
<input message="Please enter the user you will connect as" addproperty="username"/>
|
||||||
|
<input message="Please enter the path to the dsa key" addproperty="keyfile"/>
|
||||||
|
|
||||||
|
<!-- maven must be available before we use it -->
|
||||||
|
<delete dir="build/cargo"/>
|
||||||
|
<mkdir dir="build/cargo"/>
|
||||||
|
|
||||||
|
<get src="http://apache.imghat.com/maven/binaries/maven-ant-tasks-2.1.0.jar" dest="build/maven-ant-tasks-2.1.0.jar"/>
|
||||||
|
<get src="http://web-actions.googlecode.com/files/samples-blazeds.war" dest="build/samples-blazeds.war"/>
|
||||||
|
|
||||||
|
<!-- initialize maven tasks -->
|
||||||
|
<path id="maven-ant-tasks.classpath" path="build/maven-ant-tasks-2.1.0.jar"/>
|
||||||
|
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath"/>
|
||||||
|
<artifact:localRepository id="local.repository" path="${user.home}/.m2/repository"/>
|
||||||
|
<artifact:remoteRepository id="jclouds-snapshot.repository" url="http://jclouds.rimuhosting.com/maven2/snapshots"/>
|
||||||
|
<!-- Setup maven so that we can get latest version of jclouds, jclouds, and jruby -->
|
||||||
|
<artifact:dependencies pathId="jclouds.classpath">
|
||||||
|
<dependency groupid="org.codehaus.cargo" artifactId="cargo-ant" version="1.0.1-SNAPSHOT"/>
|
||||||
|
<dependency groupid="org.codehaus.cargo" artifactId="cargo-core-container-tomcat" version="1.0.1-SNAPSHOT"/>
|
||||||
|
<dependency groupId="org.jclouds" artifactId="jclouds-terremark" version="1.0-SNAPSHOT"/>
|
||||||
|
<dependency groupId="org.jclouds" artifactId="jclouds-ant-plugin" version="1.0-SNAPSHOT"/>
|
||||||
|
<dependency groupId="org.jclouds" artifactId="jclouds-antcontrib" version="1.0-SNAPSHOT"/>
|
||||||
|
<remoteRepository refid="jclouds-snapshot.repository"/>
|
||||||
|
<localRepository refid="local.repository"/>
|
||||||
|
</artifact:dependencies>
|
||||||
|
<typedef name="compute" classname="org.jclouds.tools.ant.ComputeTask" classpathref="jclouds.classpath"/>
|
||||||
|
<taskdef resource="cargo.tasks" classpathref="jclouds.classpath"/>
|
||||||
|
|
||||||
|
<property name="service" value="terremark"/>
|
||||||
|
<input message="What is your account on ${service}?" addproperty="account"/>
|
||||||
|
<input message="What is the key for ${account}?" addproperty="key"/>
|
||||||
|
<property name="jclouds.compute.url" value="compute://${account}:${key}@${service}"/>
|
||||||
|
|
||||||
|
<target name="boo">
|
||||||
|
<input message="What is the container you wish to store ${zip} in?" addproperty="container"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="cargooverssh">
|
||||||
|
<compute action="list-details" provider="${jclouds.compute.url}"/>
|
||||||
|
<cargo containerId="tomcat6x" output="build/output.log" log="build/cargo.log" action="start">
|
||||||
|
<sysproperty key="myproperty" value="myvalue"/>
|
||||||
|
<zipurlinstaller installurl="http://www.alliedquotes.com/mirrors/apache/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.zip"/>
|
||||||
|
<configuration home="build/cargo" type="standalone">
|
||||||
|
<property name="cargo.servlet.port" value="8080"/>
|
||||||
|
<property name="cargo.logging" value="high"/>
|
||||||
|
<deployable type="war" file="build/samples-blazeds.war"/>
|
||||||
|
</configuration>
|
||||||
|
</cargo>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
|
@ -51,7 +51,6 @@ import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.scriptbuilder.domain.StatementList;
|
import org.jclouds.scriptbuilder.domain.StatementList;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -70,18 +69,21 @@ public class SSHJava extends Java {
|
||||||
private File localDirectory;
|
private File localDirectory;
|
||||||
private File remotebase;
|
private File remotebase;
|
||||||
private File remotedir;
|
private File remotedir;
|
||||||
private Environment env = new Environment();
|
@VisibleForTesting
|
||||||
|
Environment env = new Environment();
|
||||||
|
|
||||||
private OsFamily osFamily = OsFamily.UNIX;
|
private OsFamily osFamily = OsFamily.UNIX;
|
||||||
private File errorFile;
|
private File errorFile;
|
||||||
private String errorProperty;
|
private String errorProperty;
|
||||||
private File outputFile;
|
private File outputFile;
|
||||||
private String outputProperty;
|
private String outputProperty;
|
||||||
private String id = "javassh" + new SecureRandom().nextLong();
|
private String id = "sshjava" + new SecureRandom().nextLong();
|
||||||
|
|
||||||
private boolean append;
|
private boolean append;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final Map<String, String> shiftMap = Maps.newHashMap();
|
final Map<String, String> shiftMap = Maps.newHashMap();
|
||||||
|
@VisibleForTesting
|
||||||
|
final Map<String, String> replace = Maps.newHashMap();
|
||||||
|
|
||||||
public SSHJava() {
|
public SSHJava() {
|
||||||
super();
|
super();
|
||||||
|
@ -114,9 +116,12 @@ public class SSHJava extends Java {
|
||||||
throw new BuildException(e);
|
throw new BuildException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remotedir == null)
|
if (remotedir == null)
|
||||||
remotedir = new File(remotebase, id);
|
remotedir = new File(remotebase, id);
|
||||||
|
|
||||||
|
replace.put(localDirectory.getAbsolutePath(), remotedir.getAbsolutePath());
|
||||||
|
|
||||||
if (osFamily == OsFamily.UNIX) {
|
if (osFamily == OsFamily.UNIX) {
|
||||||
log("removing old contents: " + remotedir.getAbsolutePath(), Project.MSG_VERBOSE);
|
log("removing old contents: " + remotedir.getAbsolutePath(), Project.MSG_VERBOSE);
|
||||||
sshexec(exec("rm -rf " + remotedir.getAbsolutePath()).render(osFamily));
|
sshexec(exec("rm -rf " + remotedir.getAbsolutePath()).render(osFamily));
|
||||||
|
@ -266,11 +271,21 @@ public class SSHJava extends Java {
|
||||||
}
|
}
|
||||||
|
|
||||||
String reprefix(String in) {
|
String reprefix(String in) {
|
||||||
|
log("comparing: " + in, Project.MSG_DEBUG);
|
||||||
for (Entry<String, String> entry : shiftMap.entrySet()) {
|
for (Entry<String, String> entry : shiftMap.entrySet()) {
|
||||||
if (in.startsWith(entry.getKey()))
|
if (in.startsWith(entry.getKey())) {
|
||||||
|
log("match shift map: " + entry.getKey(), Project.MSG_DEBUG);
|
||||||
in = remotebase + ShellToken.FS.to(osFamily) + entry.getValue()
|
in = remotebase + ShellToken.FS.to(osFamily) + entry.getValue()
|
||||||
+ in.substring(entry.getKey().length());
|
+ in.substring(entry.getKey().length());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
for (Entry<String, String> entry : replace.entrySet()) {
|
||||||
|
if (in.startsWith(entry.getKey())) {
|
||||||
|
log("match replaceMap: " + entry.getKey(), Project.MSG_DEBUG);
|
||||||
|
in = entry.getValue() + in.substring(entry.getKey().length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log("now: " + in, Project.MSG_DEBUG);
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +298,7 @@ public class SSHJava extends Java {
|
||||||
for (int i = 0; i < environment.length; i++) {
|
for (int i = 0; i < environment.length; i++) {
|
||||||
log("Setting environment variable: " + environment[i], Project.MSG_DEBUG);
|
log("Setting environment variable: " + environment[i], Project.MSG_DEBUG);
|
||||||
String[] keyValue = environment[i].split("=");
|
String[] keyValue = environment[i].split("=");
|
||||||
envVariables.put(keyValue[0], keyValue[1]);
|
envVariables.put(keyValue[0], reprefix(keyValue[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,8 +311,7 @@ public class SSHJava extends Java {
|
||||||
|
|
||||||
if (commandLine.getVmCommand().getArguments() != null
|
if (commandLine.getVmCommand().getArguments() != null
|
||||||
&& commandLine.getVmCommand().getArguments().length > 0) {
|
&& commandLine.getVmCommand().getArguments().length > 0) {
|
||||||
commandBuilder.append(" ").append(
|
reprefixArgs(commandLine.getVmCommand().getArguments(), commandBuilder);
|
||||||
Joiner.on(' ').join(commandLine.getVmCommand().getArguments()));
|
|
||||||
}
|
}
|
||||||
commandBuilder.append(" -cp classpath");
|
commandBuilder.append(" -cp classpath");
|
||||||
resetPathToUnderPrefixIfExistsAndIsFileIfNotExistsAddAsIs(commandLine.getClasspath(),
|
resetPathToUnderPrefixIfExistsAndIsFileIfNotExistsAddAsIs(commandLine.getClasspath(),
|
||||||
|
@ -306,22 +320,38 @@ public class SSHJava extends Java {
|
||||||
if (commandLine.getSystemProperties() != null
|
if (commandLine.getSystemProperties() != null
|
||||||
&& commandLine.getSystemProperties().getVariables() != null
|
&& commandLine.getSystemProperties().getVariables() != null
|
||||||
&& commandLine.getSystemProperties().getVariables().length > 0) {
|
&& commandLine.getSystemProperties().getVariables().length > 0) {
|
||||||
commandBuilder.append(" ").append(
|
reprefixValues(commandLine.getSystemProperties().getVariables(), commandBuilder);
|
||||||
Joiner.on(' ').join(commandLine.getSystemProperties().getVariables()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
commandBuilder.append(" ").append(commandLine.getClassname());
|
commandBuilder.append(" ").append(commandLine.getClassname());
|
||||||
|
|
||||||
if (commandLine.getJavaCommand().getArguments() != null
|
if (commandLine.getJavaCommand().getArguments() != null
|
||||||
&& commandLine.getJavaCommand().getArguments().length > 0) {
|
&& commandLine.getJavaCommand().getArguments().length > 0) {
|
||||||
commandBuilder.append(" ").append(
|
reprefixArgs(commandLine.getJavaCommand().getArguments(), commandBuilder);
|
||||||
Joiner.on(' ').join(commandLine.getJavaCommand().getArguments()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InitBuilder testInitBuilder = new InitBuilder(id, basedir, basedir, envVariables,
|
InitBuilder testInitBuilder = new InitBuilder(id, basedir, basedir, envVariables,
|
||||||
commandBuilder.toString());
|
commandBuilder.toString());
|
||||||
String script = testInitBuilder.build(osFamily);
|
return testInitBuilder.build(osFamily);
|
||||||
return reprefix(script);
|
}
|
||||||
|
|
||||||
|
private void reprefixValues(String[] variables, StringBuilder commandBuilder) {
|
||||||
|
for (String variable : variables) {
|
||||||
|
commandBuilder.append(" ");
|
||||||
|
String[] keyValue = variable.split("=");
|
||||||
|
if (keyValue.length == 2) {
|
||||||
|
String newVariable = keyValue[0] + '=' + reprefix(keyValue[1]);
|
||||||
|
commandBuilder.append(newVariable);
|
||||||
|
} else {
|
||||||
|
commandBuilder.append(variable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reprefixArgs(String[] args, StringBuilder commandBuilder) {
|
||||||
|
for (String arg : args) {
|
||||||
|
commandBuilder.append(" ").append(reprefix(arg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -508,8 +538,10 @@ public class SSHJava extends Java {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSysproperty(Variable sysp) {
|
public void addSysproperty(Variable sysp) {
|
||||||
if (sysp.getKey().startsWith("sshjava.map.")) {
|
if (sysp.getKey().startsWith("sshjava.shift.")) {
|
||||||
shiftMap.put(sysp.getKey().replaceFirst("sshjava.map.", ""), sysp.getValue());
|
shiftMap.put(sysp.getKey().replaceFirst("sshjava.shift.", ""), sysp.getValue());
|
||||||
|
} else if (sysp.getKey().startsWith("sshjava.replace.")) {
|
||||||
|
replace.put(sysp.getKey().replaceFirst("sshjava.replace.", ""), sysp.getValue());
|
||||||
} else if (sysp.getKey().equals("sshjava.id")) {
|
} else if (sysp.getKey().equals("sshjava.id")) {
|
||||||
setId(sysp.getValue());
|
setId(sysp.getValue());
|
||||||
} else if (sysp.getKey().equals("sshjava.remotebase")) {
|
} else if (sysp.getKey().equals("sshjava.remotebase")) {
|
||||||
|
|
|
@ -32,11 +32,15 @@ import org.apache.tools.ant.taskdefs.Java;
|
||||||
import org.apache.tools.ant.types.Environment;
|
import org.apache.tools.ant.types.Environment;
|
||||||
import org.apache.tools.ant.types.Path;
|
import org.apache.tools.ant.types.Path;
|
||||||
import org.apache.tools.ant.types.Environment.Variable;
|
import org.apache.tools.ant.types.Environment.Variable;
|
||||||
|
import org.jclouds.scriptbuilder.domain.OsFamily;
|
||||||
import org.jclouds.tools.ant.TestClass;
|
import org.jclouds.tools.ant.TestClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.io.CharStreams;
|
||||||
|
import com.google.common.io.Resources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -47,11 +51,17 @@ public class SSHJavaTest {
|
||||||
.entrySet());
|
.entrySet());
|
||||||
|
|
||||||
// TODO, this test will break in windows
|
// TODO, this test will break in windows
|
||||||
public void testShift() throws SecurityException, NoSuchMethodException {
|
@Test(enabled = false, groups = { "live" })
|
||||||
|
public void testShift() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
SSHJava task = makeSSHJava();
|
SSHJava task = makeSSHJava();
|
||||||
task = directoryShift(task);
|
task = directoryShift(task);
|
||||||
assertEquals(task.shiftMap, ImmutableMap.<String, String> of(System.getProperty("user.home")
|
assertEquals(task.shiftMap, ImmutableMap.<String, String> of(System.getProperty("user.home")
|
||||||
+ "/apache-maven-2.2.1", "maven"));
|
+ "/apache-maven-2.2.1", "maven"));
|
||||||
|
assertEquals(task.replace, ImmutableMap.<String, String> of(System.getProperty("user.name"),
|
||||||
|
"root"));
|
||||||
|
assertEquals(task.createInitScript(OsFamily.UNIX, "1", "remotedir", task.env, task
|
||||||
|
.getCommandLine()), CharStreams.toString(Resources.newReaderSupplier(Resources
|
||||||
|
.getResource("init.sh"), Charsets.UTF_8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Java populateTask(Java task) {
|
private Java populateTask(Java task) {
|
||||||
|
@ -155,7 +165,7 @@ public class SSHJavaTest {
|
||||||
|
|
||||||
private <T extends Java> T directoryShift(T java) {
|
private <T extends Java> T directoryShift(T java) {
|
||||||
Variable prop1 = new Environment.Variable();
|
Variable prop1 = new Environment.Variable();
|
||||||
prop1.setKey("sshjava.map." + System.getProperty("user.home") + "/apache-maven-2.2.1");
|
prop1.setKey("sshjava.shift." + System.getProperty("user.home") + "/apache-maven-2.2.1");
|
||||||
prop1.setValue("maven");
|
prop1.setValue("maven");
|
||||||
java.addSysproperty(prop1);
|
java.addSysproperty(prop1);
|
||||||
Variable prop2 = new Environment.Variable();
|
Variable prop2 = new Environment.Variable();
|
||||||
|
@ -166,6 +176,14 @@ public class SSHJavaTest {
|
||||||
prop3.setKey("appHome");
|
prop3.setKey("appHome");
|
||||||
prop3.setValue(System.getProperty("user.home") + "/apache-maven-2.2.1");
|
prop3.setValue(System.getProperty("user.home") + "/apache-maven-2.2.1");
|
||||||
java.addSysproperty(prop3);
|
java.addSysproperty(prop3);
|
||||||
|
Variable prop4 = new Environment.Variable();
|
||||||
|
prop4.setKey("sshjava.replace." + System.getProperty("user.name"));
|
||||||
|
prop4.setValue("root");
|
||||||
|
java.addSysproperty(prop4);
|
||||||
|
Variable prop5 = new Environment.Variable();
|
||||||
|
prop5.setKey("username");
|
||||||
|
prop5.setValue(System.getProperty("user.name"));
|
||||||
|
java.addSysproperty(prop5);
|
||||||
return java;
|
return java;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,8 @@ public class VCloudComputeClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Image, String> imageCatalogIdMap = ImmutableMap.<Image, String> builder().put(
|
private Map<Image, String> imageCatalogIdMap = ImmutableMap.<Image, String> builder().put(
|
||||||
Image.CENTOS_53, "3").put(Image.RHEL_53, "8").put(Image.UMBUNTU_90, "10").put(
|
Image.CENTOS_53, "3").put(Image.RHEL_53, "8").put(Image.UBUNTU_90, "10").put(
|
||||||
Image.UMBUNTU_JEOS, "11").build();
|
Image.UBUNTU_JEOS, "11").build();
|
||||||
|
|
||||||
public Map<String, String> start(String name, Image image, int minCores, int minMegs,
|
public Map<String, String> start(String name, Image image, int minCores, int minMegs,
|
||||||
long diskSize, Map<String, String> properties) {
|
long diskSize, Map<String, String> properties) {
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class VCloudComputeClientLiveTest {
|
||||||
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
||||||
Image.RHEL_53,
|
Image.RHEL_53,
|
||||||
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
||||||
Image.UMBUNTU_90, new Expectation(4194304, "Ubuntu Linux (64-bit)")).put(
|
Image.UBUNTU_90, new Expectation(4194304, "Ubuntu Linux (64-bit)")).put(
|
||||||
Image.UMBUNTU_JEOS, new Expectation(4194304, "Ubuntu Linux (32-bit)")).build();
|
Image.UBUNTU_JEOS, new Expectation(4194304, "Ubuntu Linux (32-bit)")).build();
|
||||||
|
|
||||||
private Predicate<InetAddress> addressTester;
|
private Predicate<InetAddress> addressTester;
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,8 @@ public class HostingDotComVCloudComputeClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Image, String> imageCatalogIdMap = ImmutableMap.<Image, String> builder().put(
|
private Map<Image, String> imageCatalogIdMap = ImmutableMap.<Image, String> builder().put(
|
||||||
Image.CENTOS_53, "3").put(Image.RHEL_53, "8").put(Image.UMBUNTU_90, "10").put(
|
Image.CENTOS_53, "3").put(Image.RHEL_53, "8").put(Image.UBUNTU_90, "10").put(
|
||||||
Image.UMBUNTU_JEOS, "11").build();
|
Image.UBUNTU_JEOS, "11").build();
|
||||||
|
|
||||||
public Map<String, String> start(String name, Image image, int minCores, int minMegs,
|
public Map<String, String> start(String name, Image image, int minCores, int minMegs,
|
||||||
long diskSize, Map<String, String> properties) {
|
long diskSize, Map<String, String> properties) {
|
||||||
|
|
|
@ -78,8 +78,8 @@ public class HostingDotComVCloudComputeClientLiveTest {
|
||||||
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
||||||
Image.RHEL_53,
|
Image.RHEL_53,
|
||||||
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
||||||
Image.UMBUNTU_90, new Expectation(4194304, "Ubuntu Linux (64-bit)")).put(
|
Image.UBUNTU_90, new Expectation(4194304, "Ubuntu Linux (64-bit)")).put(
|
||||||
Image.UMBUNTU_JEOS, new Expectation(4194304, "Ubuntu Linux (32-bit)")).build();
|
Image.UBUNTU_JEOS, new Expectation(4194304, "Ubuntu Linux (32-bit)")).build();
|
||||||
|
|
||||||
private Predicate<InetAddress> addressTester;
|
private Predicate<InetAddress> addressTester;
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,8 @@ public class TerremarkVCloudComputeClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Image, String> imageCatalogIdMap = ImmutableMap.<Image, String> builder().put(
|
private Map<Image, String> imageCatalogIdMap = ImmutableMap.<Image, String> builder().put(
|
||||||
Image.CENTOS_53, "6").put(Image.RHEL_53, "8").put(Image.UMBUNTU_90, "10").put(
|
Image.CENTOS_53, "6").put(Image.RHEL_53, "8").put(Image.UBUNTU_90, "10").put(
|
||||||
Image.UMBUNTU_JEOS, "11").build();
|
Image.UBUNTU_JEOS, "11").build();
|
||||||
|
|
||||||
public String start(String name, Image image, int minCores, int minMegs,
|
public String start(String name, Image image, int minCores, int minMegs,
|
||||||
Map<String, String> properties) {
|
Map<String, String> properties) {
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class TerremarkVCloudComputeClientLiveTest {
|
||||||
private Map<Image, Expectation> expectationMap = ImmutableMap.<Image, Expectation> builder()
|
private Map<Image, Expectation> expectationMap = ImmutableMap.<Image, Expectation> builder()
|
||||||
.put(Image.CENTOS_53, new Expectation(10485760, "Red Hat Enterprise Linux 5 (64-bit)"))
|
.put(Image.CENTOS_53, new Expectation(10485760, "Red Hat Enterprise Linux 5 (64-bit)"))
|
||||||
.put(Image.RHEL_53, new Expectation(10485760, "Red Hat Enterprise Linux 5 (64-bit)"))
|
.put(Image.RHEL_53, new Expectation(10485760, "Red Hat Enterprise Linux 5 (64-bit)"))
|
||||||
.put(Image.UMBUNTU_90, new Expectation(4194304, "Ubuntu Linux (64-bit)")).put(
|
.put(Image.UBUNTU_90, new Expectation(4194304, "Ubuntu Linux (64-bit)")).put(
|
||||||
Image.UMBUNTU_JEOS, new Expectation(4194304, "Ubuntu Linux (32-bit)")).build();
|
Image.UBUNTU_JEOS, new Expectation(4194304, "Ubuntu Linux (32-bit)")).build();
|
||||||
|
|
||||||
private Predicate<InetAddress> addressTester;
|
private Predicate<InetAddress> addressTester;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue