diff --git a/README.txt b/README.txt index d1a474d120..69f189f06e 100644 --- a/README.txt +++ b/README.txt @@ -77,7 +77,7 @@ Compute Example (Java): accesskeyid, secretaccesskey, ImmutableSet.of(new Log4JLoggingModule(), - new JschSshClientModule())); + new SshjSshClientModule())); client = context.getComputeService(); // define the requirements of your node @@ -96,9 +96,9 @@ Compute Example (Java): Compute Example (Clojure): (use 'org.jclouds.compute2) - ; create a compute service using ssh and log4j extensions + ; create a compute service using sshj and log4j extensions (def compute - (*compute* "trmk`-ecloud" "user" "password" :ssh :log4j)) + (*compute* "trmk`-ecloud" "user" "password" :sshj :log4j)) ; launch a couple nodes with the default operating system, installing your user. (create-nodes *compute* "mycluster" 2 diff --git a/apis/byon/pom.xml b/apis/byon/pom.xml index ea13793ee1..770c751c57 100644 --- a/apis/byon/pom.xml +++ b/apis/byon/pom.xml @@ -57,12 +57,6 @@ test-jar test - - log4j - log4j - 1.2.16 - test - org.jclouds.driver jclouds-log4j @@ -71,15 +65,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - org.yaml snakeyaml diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java index 76525671ab..e37ff0290f 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java @@ -24,8 +24,8 @@ import static org.jclouds.scriptbuilder.domain.Statements.exec; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Map; -import java.util.Properties; import java.util.Map.Entry; +import java.util.Properties; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; @@ -33,7 +33,7 @@ import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.scriptbuilder.domain.OsFamily; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -74,7 +74,7 @@ public class BYONComputeServiceLiveTest { contextProperties.setProperty("byon.nodes", nodes.toString()); context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet. of( - new JschSshClientModule(), new Log4JLoggingModule()), contextProperties); + new SshjSshClientModule(), new Log4JLoggingModule()), contextProperties); } public void testCanRunCommandAsCurrentUser() throws Exception { diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java index 89d5f76c1c..2d2a748a09 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java @@ -31,7 +31,7 @@ import org.jclouds.byon.functions.NodesFromYamlTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.domain.Location; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -64,7 +64,7 @@ public class BYONComputeServiceTest { Properties props = new Properties(); props.setProperty("byon.endpoint", endpoint); context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet - . of(new JschSshClientModule()), props); + . of(new SshjSshClientModule()), props); assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); @@ -92,7 +92,7 @@ public class BYONComputeServiceTest { Properties props = new Properties(); props.setProperty("byon.endpoint", endpoint); context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet - . of(new JschSshClientModule()), props); + . of(new SshjSshClientModule()), props); assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); diff --git a/apis/cloudservers/pom.xml b/apis/cloudservers/pom.xml index 83de0d1fde..88bcdbc538 100644 --- a/apis/cloudservers/pom.xml +++ b/apis/cloudservers/pom.xml @@ -76,27 +76,16 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - org.jclouds.driver jclouds-log4j ${project.version} test - - log4j - log4j - 1.2.16 - test - diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java index 01d3fc1bba..ff2ba7c9ee 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java @@ -58,7 +58,7 @@ import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.util.Strings2; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; @@ -116,7 +116,7 @@ public class CloudServersClientLiveTest { Properties overrides = setupProperties(); Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector(); + ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides).buildInjector(); client = injector.getInstance(CloudServersClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java index cba263d65a..ecb4b793b6 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java @@ -29,9 +29,11 @@ import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.LocationScope; import org.jclouds.rest.RestContext; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; +import com.google.inject.Module; + /** * * Generally disabled, as it incurs higher fees. @@ -45,8 +47,8 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected Module getSshModule() { + return new SshjSshClientModule(); } public void testAssignability() throws Exception { diff --git a/apis/deltacloud/pom.xml b/apis/deltacloud/pom.xml index c7353eec17..1b816897b3 100644 --- a/apis/deltacloud/pom.xml +++ b/apis/deltacloud/pom.xml @@ -78,21 +78,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - org.jclouds.driver jclouds-log4j diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java index 5ba64b8092..51588f7a86 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java @@ -34,7 +34,7 @@ import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRequest; import org.jclouds.net.IPSocket; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -134,7 +134,7 @@ public class DeltacloudClientLiveTest extends ReadOnlyDeltacloudClientLiveTest { } protected void doConnectViaSsh(Instance instance, Credentials creds) throws IOException { - SshClient ssh = Guice.createInjector(new JschSshClientModule()).getInstance(SshClient.Factory.class).create( + SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class).create( new IPSocket(Iterables.get(instance.getPublicAddresses(), 0), 22), creds); try { ssh.connect(); diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java index d6f8b0c98c..d3cb408a77 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java @@ -29,9 +29,11 @@ import org.jclouds.deltacloud.DeltacloudAsyncClient; import org.jclouds.deltacloud.DeltacloudClient; import org.jclouds.domain.LocationScope; import org.jclouds.rest.RestContext; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; +import com.google.inject.Module; + /** * * @@ -44,8 +46,8 @@ public class DeltacloudComputeServiceLiveTest extends BaseComputeServiceLiveTest } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected Module getSshModule() { + return new SshjSshClientModule(); } public void testAssignability() throws Exception { diff --git a/apis/ec2/pom.xml b/apis/ec2/pom.xml index e9ced2e714..81d2234921 100644 --- a/apis/ec2/pom.xml +++ b/apis/ec2/pom.xml @@ -78,21 +78,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java index 3c2d3819ab..9661c59239 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java @@ -47,7 +47,7 @@ import org.jclouds.ec2.services.ElasticBlockStoreClient; import org.jclouds.ec2.services.InstanceClient; import org.jclouds.ec2.services.KeyPairClient; import org.jclouds.ec2.services.SecurityGroupClient; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -69,7 +69,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Override protected Module getSshModule() { - return new JschSshClientModule(); + return new SshjSshClientModule(); } @Test(enabled = true, dependsOnMethods = "testCorrectAuthException") diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java index 8cab1e2ae5..72e367361a 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java @@ -31,7 +31,7 @@ import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.Template; import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -81,7 +81,7 @@ public class TestCanRecreateGroupLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides); + ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); } public void testCanRecreateGroup() throws Exception { diff --git a/apis/elasticstack/pom.xml b/apis/elasticstack/pom.xml index 88542f4c96..207b54262e 100644 --- a/apis/elasticstack/pom.xml +++ b/apis/elasticstack/pom.xml @@ -64,17 +64,6 @@ jclouds-compute ${project.version} - - org.jclouds.driver - jclouds-jsch - ${project.version} - test - - - com.jcraft - jsch - test - org.jclouds jclouds-core @@ -90,14 +79,14 @@ test - log4j - log4j - 1.2.16 + org.jclouds.driver + jclouds-log4j + ${project.version} test org.jclouds.driver - jclouds-log4j + jclouds-sshj ${project.version} test diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java index b6085157e0..905fb717fb 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java @@ -52,7 +52,7 @@ import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.util.Strings2; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; @@ -312,7 +312,7 @@ public class ElasticStackClientLiveTest { } protected void doConnectViaSsh(Server server, Credentials creds) throws IOException { - SshClient ssh = Guice.createInjector(new JschSshClientModule()).getInstance(SshClient.Factory.class).create( + SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class).create( new IPSocket(server.getVnc().getIp(), 22), creds); try { ssh.connect(); diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java index 3aedbf0397..8ac51d063e 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java @@ -21,9 +21,11 @@ package org.jclouds.elasticstack.compute; import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; +import com.google.inject.Module; + /** * @author Adrian Cole */ @@ -34,8 +36,8 @@ public class ElasticStackComputeServiceLiveTest extends BaseComputeServiceLiveTe } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected Module getSshModule() { + return new SshjSshClientModule(); } @Override diff --git a/apis/eucalyptus/pom.xml b/apis/eucalyptus/pom.xml index 07be116f29..9e7349a606 100644 --- a/apis/eucalyptus/pom.xml +++ b/apis/eucalyptus/pom.xml @@ -68,17 +68,6 @@ test-jar test - - org.jclouds.driver - jclouds-jsch - ${project.version} - test - - - com.jcraft - jsch - test - org.jclouds.driver jclouds-log4j @@ -86,9 +75,9 @@ test - log4j - log4j - 1.2.16 + org.jclouds.driver + jclouds-sshj + ${project.version} test diff --git a/apis/nova/pom.xml b/apis/nova/pom.xml index 6521c279b9..dea1e7b827 100644 --- a/apis/nova/pom.xml +++ b/apis/nova/pom.xml @@ -72,7 +72,7 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ComputeBase.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ComputeBase.java index c11c3eab81..ee08c37008 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ComputeBase.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ComputeBase.java @@ -55,12 +55,13 @@ import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.ssh.SshException; -import org.jclouds.ssh.jsch.JschSshClient; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.SshjSshClient; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.BeforeTest; import com.google.common.collect.ImmutableSet; import com.google.inject.Guice; +import com.google.inject.Module; /** * @author Victor Galkin @@ -91,8 +92,8 @@ public class ComputeBase { return new RetryablePredicate(socketOpen, 60, 1, TimeUnit.SECONDS); } - private JschSshClientModule getSshModule() { - return new JschSshClientModule(); + private Module getSshModule() { + return new SshjSshClientModule(); } protected TemplateBuilder getDefaultTemplateBuilder() { @@ -150,7 +151,7 @@ public class ComputeBase { protected void awaitForSshPort(String address, Credentials credentials) throws URISyntaxException { IPSocket socket = new IPSocket(address, 22); - JschSshClient ssh = new JschSshClient( + SshjSshClient ssh = new SshjSshClient( new BackoffLimitedRetryHandler(), socket, 10000, credentials.identity, null, credentials.credential.getBytes()); while (true) { try { diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ComputeServiceCheck.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ComputeServiceCheck.java index 3778b9be9f..6bcb61b6b5 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ComputeServiceCheck.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ComputeServiceCheck.java @@ -18,7 +18,14 @@ */ package org.jclouds.openstack.nova.live.compute; -import com.google.common.collect.ImmutableSet; +import static org.jclouds.openstack.nova.live.PropertyHelper.setupOverrides; +import static org.jclouds.openstack.nova.live.PropertyHelper.setupProperties; + +import java.io.IOException; +import java.util.NoSuchElementException; +import java.util.Properties; +import java.util.Set; + import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; @@ -27,18 +34,12 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import java.io.IOException; -import java.util.NoSuchElementException; -import java.util.Properties; -import java.util.Set; - -import static org.jclouds.openstack.nova.live.PropertyHelper.setupOverrides; -import static org.jclouds.openstack.nova.live.PropertyHelper.setupProperties; +import com.google.common.collect.ImmutableSet; /** * Not intended to be run with maven and does not performs a cleanup after tests @@ -54,7 +55,7 @@ public class ComputeServiceCheck { contextFactory = new ComputeServiceContextFactory(); Properties properties = setupOverrides(setupProperties(this.getClass())); context = contextFactory.createContext("nova", - ImmutableSet.of(new JschSshClientModule(), new SLF4JLoggingModule()), properties); + ImmutableSet.of(new SshjSshClientModule(), new SLF4JLoggingModule()), properties); } @Test diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java index 97571b0aa8..0ca8fedf16 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java @@ -18,16 +18,52 @@ */ package org.jclouds.openstack.nova.live.compute; -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; -import com.google.inject.Module; -import com.jcraft.jsch.JSchException; +import static com.google.common.base.Predicates.and; +import static com.google.common.base.Predicates.not; +import static com.google.common.collect.Iterables.getOnlyElement; +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.overrideCredentialsWith; +import static org.jclouds.compute.predicates.NodePredicates.TERMINATED; +import static org.jclouds.compute.predicates.NodePredicates.all; +import static org.jclouds.compute.predicates.NodePredicates.inGroup; +import static org.jclouds.compute.predicates.NodePredicates.runningInGroup; +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Collection; +import java.util.LinkedList; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Properties; +import java.util.Set; +import java.util.SortedSet; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.RunScriptOnNodesException; -import org.jclouds.compute.domain.*; +import org.jclouds.compute.domain.ComputeMetadata; +import org.jclouds.compute.domain.ComputeType; +import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.compute.domain.Hardware; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.NodeState; +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; @@ -40,25 +76,10 @@ import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.*; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; - -import static com.google.common.base.Predicates.and; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Iterables.getOnlyElement; -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.overrideCredentialsWith; -import static org.jclouds.compute.predicates.NodePredicates.*; -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; -import static org.testng.Assert.*; +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import com.google.inject.Module; /** * Generally disabled, as it incurs higher fees. @@ -129,7 +150,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase { .family(OsFamily.UBUNTU).description("ffoo").build())); } - @Test(expectedExceptions = JSchException.class, expectedExceptionsMessageRegExp = "Auth fail", timeOut = 120000) + @Test(expectedExceptions = AuthorizationException.class, expectedExceptionsMessageRegExp = "Auth fail", timeOut = 120000) void testScriptExecutionWithWrongCredentials() throws Throwable, RunScriptOnNodesException, URISyntaxException, InterruptedException { NodeMetadata node = getDefaultNodeImmediately(group); String address = awaitForPublicAddressAssigned(node.getId()); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java index 179b60e9c7..a3e1295d1b 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java @@ -37,7 +37,7 @@ import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.BeforeTest; import com.google.common.base.Predicate; @@ -65,7 +65,7 @@ public class ClientBase { Properties properties = setupOverrides(setupProperties(this.getClass())); Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet.of(new SLF4JLoggingModule(), new JschSshClientModule()), properties) + ImmutableSet.of(new SLF4JLoggingModule(), new SshjSshClientModule()), properties) .buildInjector(); client = injector.getInstance(NovaClient.class); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ServerCreateLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ServerCreateLiveTest.java index 9f3fb72947..6a8ccd73a3 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ServerCreateLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ServerCreateLiveTest.java @@ -18,11 +18,16 @@ */ package org.jclouds.openstack.nova.live.novaclient; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Injector; -import com.google.inject.Module; +import static org.jclouds.openstack.nova.live.PropertyHelper.setupKeyPair; +import static org.jclouds.openstack.nova.live.PropertyHelper.setupOverrides; +import static org.jclouds.openstack.nova.live.PropertyHelper.setupProperties; +import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; + +import java.io.IOException; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + import org.jclouds.http.HttpResponseException; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.net.IPSocket; @@ -33,18 +38,16 @@ import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import java.io.IOException; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -import static org.jclouds.openstack.nova.live.PropertyHelper.*; -import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Injector; +import com.google.inject.Module; /** * @author Victor Galkin @@ -67,7 +70,7 @@ public class ServerCreateLiveTest { Properties properties = setupOverrides(setupProperties(this.getClass())); Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet.of(new SLF4JLoggingModule(), new JschSshClientModule()), properties) + ImmutableSet.of(new SLF4JLoggingModule(), new SshjSshClientModule()), properties) .buildInjector(); client = injector.getInstance(NovaClient.class); diff --git a/apis/vcloud/pom.xml b/apis/vcloud/pom.xml index 0b361d6280..518e33cbaf 100644 --- a/apis/vcloud/pom.xml +++ b/apis/vcloud/pom.xml @@ -74,21 +74,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - org.jclouds.driver jclouds-log4j diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java index f7b66011c4..d0efc31a86 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java @@ -26,7 +26,7 @@ import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.rest.RestContext; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.vcloud.VCloudAsyncClient; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.domain.VApp; @@ -48,8 +48,8 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected Module getSshModule() { + return new SshjSshClientModule(); } public void testAssignability() throws Exception { diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java index e21cb2a86d..02920afd6a 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java @@ -34,7 +34,7 @@ import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient.Factory; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeClass; @@ -104,8 +104,8 @@ public abstract class BaseVCloudClientLiveTest { return RestContextFactory.getPropertiesFromResource("/rest.properties"); } - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected Module getSshModule() { + return new SshjSshClientModule(); } @AfterGroups(groups = { "live" }) diff --git a/common/trmk/pom.xml b/common/trmk/pom.xml index 3c4f3ed984..ce5e8d43ff 100644 --- a/common/trmk/pom.xml +++ b/common/trmk/pom.xml @@ -68,16 +68,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - log4j - log4j - 1.2.16 - test - diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java index bb7a242284..2b00246d3f 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java @@ -54,7 +54,7 @@ import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient.Factory; import org.jclouds.ssh.SshException; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.domain.Catalog; import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem; import org.jclouds.trmk.vcloud_0_8.domain.CustomizationParameters; @@ -469,7 +469,7 @@ public abstract class TerremarkClientLiveTest { Properties overrides = setupProperties(); injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector(); + ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides).buildInjector(); sshFactory = injector.getInstance(SshClient.Factory.class); socketTester = new RetryablePredicate(injector.getInstance(SocketOpen.class), 130, 10, TimeUnit.SECONDS);// make diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java index ce34dc9421..9f5736f403 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java @@ -30,9 +30,8 @@ import org.jclouds.compute.domain.Image; import org.jclouds.lifecycle.Closer; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContextFactory; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; -import org.jclouds.trmk.vcloud_0_8.compute.suppliers.VAppTemplatesInOrgs; import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem; import org.jclouds.trmk.vcloud_0_8.functions.AllCatalogItemsInOrg; import org.testng.annotations.AfterGroups; @@ -88,7 +87,7 @@ public class VAppTemplatesInOrgsLiveTest { Properties overrides = setupProperties(); Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()),overrides).buildInjector(); + ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()),overrides).buildInjector(); tmClient = injector.getInstance(TerremarkVCloudClient.class); allCatalogItemsInOrg = injector.getInstance(AllCatalogItemsInOrg.class); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java index 0fa3987277..4b9e18ac2e 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java @@ -34,7 +34,7 @@ import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient.Factory; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeClass; @@ -105,8 +105,8 @@ public abstract class BaseTerremarkClientLiveTest bouncycastle log4j slf4j + sshj jsch netty enterprise diff --git a/drivers/sshj/pom.xml b/drivers/sshj/pom.xml new file mode 100644 index 0000000000..3e189ab8d3 --- /dev/null +++ b/drivers/sshj/pom.xml @@ -0,0 +1,103 @@ + + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.1.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.driver + jclouds-sshj + jclouds sshj ssh client + jclouds sshj ssh client + bundle + + + + + jclouds-sona-snapshots-nexus + https://oss.sonatype.org/content/repositories/snapshots + + true + + + + + + + org.jclouds + jclouds-compute + ${project.version} + + + org.jclouds + jclouds-core + ${project.version} + + + org.jclouds.driver + jclouds-slf4j + ${project.version} + + + org.jclouds.driver + jclouds-bouncycastle + ${project.version} + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + net.schmizz + sshj + 0.4.1 + + + commons-io + commons-io + 1.4 + + + + + + + org.apache.felix + maven-bundle-plugin + + + ${project.artifactId} + org.jclouds.sshj.*;version="${project.version}" + org.jclouds.*;version="${project.version}",* + + + + + + diff --git a/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java b/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java new file mode 100644 index 0000000000..c2eac52e2b --- /dev/null +++ b/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java @@ -0,0 +1,483 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.sshj; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Predicates.instanceOf; +import static com.google.common.base.Predicates.or; +import static com.google.common.base.Throwables.getCausalChain; +import static com.google.common.collect.Iterables.any; + +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.TimeUnit; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.annotation.Resource; +import javax.inject.Named; + +import net.schmizz.sshj.common.IOUtils; +import net.schmizz.sshj.connection.ConnectionException; +import net.schmizz.sshj.connection.channel.direct.Session; +import net.schmizz.sshj.connection.channel.direct.Session.Command; +import net.schmizz.sshj.sftp.SFTPClient; +import net.schmizz.sshj.transport.TransportException; +import net.schmizz.sshj.transport.verification.PromiscuousVerifier; +import net.schmizz.sshj.userauth.UserAuthException; +import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile; +import net.schmizz.sshj.xfer.InMemorySourceFile; + +import org.apache.commons.io.input.ProxyInputStream; +import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.http.handlers.BackoffLimitedRetryHandler; +import org.jclouds.io.Payload; +import org.jclouds.io.Payloads; +import org.jclouds.logging.Logger; +import org.jclouds.net.IPSocket; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.ssh.SshClient; +import org.jclouds.ssh.SshException; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.base.Splitter; +import com.google.common.base.Throwables; +import com.google.inject.Inject; + +/** + * This class needs refactoring. It is not thread safe. + * + * @author Adrian Cole + */ +public class SshjSshClient implements SshClient { + + private final class CloseFtpChannelOnCloseInputStream extends ProxyInputStream { + + private final SFTPClient sftp; + + private CloseFtpChannelOnCloseInputStream(InputStream proxy, SFTPClient sftp) { + super(proxy); + this.sftp = sftp; + } + + @Override + public void close() throws IOException { + super.close(); + if (sftp != null) + sftp.close(); + } + } + + private final String host; + private final int port; + private final String username; + private final String password; + + @Inject(optional = true) + @Named("jclouds.ssh.max-retries") + @VisibleForTesting + int sshRetries = 5; + + @Inject(optional = true) + @Named("jclouds.ssh.retry-auth") + @VisibleForTesting + boolean retryAuth; + + @Inject(optional = true) + @Named("jclouds.ssh.retryable-messages") + @VisibleForTesting + String retryableMessages = ""; + + @Inject(optional = true) + @Named("jclouds.ssh.retry-predicate") + // NOTE cannot retry io exceptions, as SSHException is a part of the chain + private Predicate retryPredicate = or(instanceOf(ConnectionException.class), + instanceOf(TransportException.class)); + + @Resource + @Named("jclouds.ssh") + protected Logger logger = Logger.NULL; + + private net.schmizz.sshj.SSHClient ssh; + private final byte[] privateKey; + final byte[] emptyPassPhrase = new byte[0]; + private final int timeoutMillis; + private final BackoffLimitedRetryHandler backoffLimitedRetryHandler; + + public SshjSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket, int timeout, + String username, String password, byte[] privateKey) { + this.host = checkNotNull(socket, "socket").getAddress(); + checkArgument(socket.getPort() > 0, "ssh port must be greater then zero" + socket.getPort()); + checkArgument(password != null || privateKey != null, "you must specify a password or a key"); + this.port = socket.getPort(); + this.username = checkNotNull(username, "username"); + this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler"); + this.timeoutMillis = timeout; + this.password = password; + this.privateKey = privateKey; + } + + @Override + public void put(String path, String contents) { + put(path, Payloads.newStringPayload(checkNotNull(contents, "contents"))); + } + + private void checkConnected() { + checkState(ssh != null && ssh.isConnected(), String.format("(%s) ssh not connected!", toString())); + } + + public static interface Connection { + void clear() throws Exception; + + T create() throws Exception; + } + + Connection sshConnection = new Connection() { + + @Override + public void clear() { + if (ssh != null && ssh.isConnected()) { + try { + ssh.disconnect(); + } catch (IOException e) { + Throwables.propagate(e); + } + ssh = null; + } + } + + @Override + public net.schmizz.sshj.SSHClient create() throws Exception { + net.schmizz.sshj.SSHClient ssh = new net.schmizz.sshj.SSHClient(); + ssh.addHostKeyVerifier(new PromiscuousVerifier()); + if (timeoutMillis != 0) { + ssh.setTimeout(timeoutMillis); + ssh.setConnectTimeout(timeoutMillis); + } + ssh.connect(host, port); + if (password != null) { + ssh.authPassword(username, password); + } else { + OpenSSHKeyFile key = new OpenSSHKeyFile(); + key.init(new String(privateKey), null); + ssh.authPublickey(username, key); + } + return ssh; + } + + @Override + public String toString() { + return String.format("SSHClient(%s)", SshjSshClient.this.toString()); + } + }; + + private void backoffForAttempt(int retryAttempt, String message) { + backoffLimitedRetryHandler.imposeBackoffExponentialDelay(200L, 2, retryAttempt, sshRetries, message); + } + + protected > T acquire(C connection) { + String errorMessage = String.format("(%s) error acquiring %s", toString(), connection); + for (int i = 0; i < sshRetries; i++) { + try { + connection.clear(); + logger.debug(">> (%s) acquiring %s", toString(), connection); + T returnVal = connection.create(); + logger.debug("<< (%s) acquired %s", toString(), returnVal); + return returnVal; + } catch (Exception from) { + try { + connection.clear(); + } catch (Exception e1) { + logger.warn(from, "<< (%s) error closing connection", toString()); + } + if (i + 1 == sshRetries) { + throw propagate(from, errorMessage); + } else if (shouldRetry(from)) { + logger.warn(from, "<< " + errorMessage + ": " + from.getMessage()); + backoffForAttempt(i + 1, errorMessage + ": " + from.getMessage()); + continue; + } + } + } + assert false : "should not reach here"; + return null; + } + + @PostConstruct + public void connect() { + try { + ssh = acquire(sshConnection); + } catch (Exception e) { + Throwables.propagate(e); + } + } + + Connection sftpConnection = new Connection() { + + private SFTPClient sftp; + + @Override + public void clear() { + if (sftp != null) + try { + sftp.close(); + } catch (IOException e) { + Throwables.propagate(e); + } + } + + @Override + public SFTPClient create() throws IOException { + checkConnected(); + sftp = ssh.newSFTPClient(); + return sftp; + } + + @Override + public String toString() { + return "SFTPClient(" + SshjSshClient.this.toString() + ")"; + } + }; + + class GetConnection implements Connection { + private final String path; + private SFTPClient sftp; + + GetConnection(String path) { + this.path = checkNotNull(path, "path"); + } + + @Override + public void clear() throws IOException { + if (sftp != null) + sftp.close(); + } + + @Override + public Payload create() throws Exception { + sftp = acquire(sftpConnection); + return Payloads.newInputStreamPayload(new CloseFtpChannelOnCloseInputStream(sftp.getSFTPEngine().open(path) + .getInputStream(), sftp)); + } + + @Override + public String toString() { + return "Payload(" + SshjSshClient.this.toString() + ")[" + path + "]"; + } + }; + + public Payload get(String path) { + return acquire(new GetConnection(path)); + } + + class PutConnection implements Connection { + private final String path; + private final Payload contents; + private SFTPClient sftp; + + PutConnection(String path, Payload contents) { + this.path = checkNotNull(path, "path"); + this.contents = checkNotNull(contents, "contents"); + } + + @Override + public void clear() { + if (sftp != null) + try { + sftp.close(); + } catch (IOException e) { + Throwables.propagate(e); + } + } + + @Override + public Void create() throws Exception { + sftp = acquire(sftpConnection); + try { + sftp.put(new InMemorySourceFile() { + + @Override + public String getName() { + return path; + } + + @Override + public long getLength() { + return contents.getContentMetadata().getContentLength(); + } + + @Override + public InputStream getInputStream() throws IOException { + return checkNotNull(contents.getInput(), "inputstream for path %s", path); + } + + }, path); + } finally { + contents.release(); + } + return null; + } + + @Override + public String toString() { + return "Put(" + SshjSshClient.this.toString() + ")[" + path + "]"; + } + }; + + @Override + public void put(String path, Payload contents) { + acquire(new PutConnection(path, contents)); + } + + @VisibleForTesting + boolean shouldRetry(Exception from) { + Predicate predicate = retryAuth ? Predicates.or(retryPredicate, instanceOf(AuthorizationException.class)) + : retryPredicate; + if (any(getCausalChain(from), predicate)) + return true; + if (!retryableMessages.equals("")) + return any(Splitter.on(",").split(retryableMessages), causalChainHasMessageContaining(from)); + return false; + } + + @VisibleForTesting + Predicate causalChainHasMessageContaining(final Exception from) { + return new Predicate() { + + @Override + public boolean apply(final String input) { + return any(getCausalChain(from), new Predicate() { + + @Override + public boolean apply(Throwable arg0) { + return arg0.getMessage() != null && arg0.getMessage().indexOf(input) != -1; + } + + }); + } + + }; + } + + @VisibleForTesting + SshException propagate(Exception e, String message) { + message += ": " + e.getMessage(); + logger.error(e, "<< " + message); + if (e instanceof UserAuthException) + throw new AuthorizationException("(" + toString() + ") " + message, e); + throw e instanceof SshException ? SshException.class.cast(e) : new SshException( + "(" + toString() + ") " + message, e); + } + + @Override + public String toString() { + return String.format("%s@%s:%d", username, host, port); + } + + @PreDestroy + public void disconnect() { + try { + sshConnection.clear(); + } catch (Exception e) { + Throwables.propagate(e); + } + } + + protected Connection execConnection() { + + return new Connection() { + + private Session session = null; + + @Override + public void clear() throws TransportException, ConnectionException { + if (session != null) + session.close(); + } + + @Override + public Session create() throws Exception { + checkConnected(); + session = ssh.startSession(); + session.allocateDefaultPTY(); + return session; + } + + @Override + public String toString() { + return "Session(" + SshjSshClient.this.toString() + ")"; + } + }; + + } + + class ExecConnection implements Connection { + private final String command; + private Session session; + + ExecConnection(String command) { + this.command = checkNotNull(command, "command"); + } + + @Override + public void clear() throws TransportException, ConnectionException { + if (session != null) + session.close(); + } + + @Override + public ExecResponse create() throws Exception { + try { + session = acquire(execConnection()); + Command output = session.exec(checkNotNull(command, "command")); + String outputString = IOUtils.readFully(output.getInputStream()).toString(); + output.join(timeoutMillis, TimeUnit.SECONDS); + int errorStatus = output.getExitStatus(); + String errorString = IOUtils.readFully(output.getErrorStream()).toString(); + return new ExecResponse(outputString, errorString, errorStatus); + } finally { + clear(); + } + } + + @Override + public String toString() { + return "ExecResponse(" + SshjSshClient.this.toString() + ")[" + command + "]"; + } + } + + public ExecResponse exec(String command) { + return acquire(new ExecConnection(command)); + } + + @Override + public String getHostAddress() { + return this.host; + } + + @Override + public String getUsername() { + return this.username; + } + +} diff --git a/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java b/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java new file mode 100644 index 0000000000..1759d27c6a --- /dev/null +++ b/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java @@ -0,0 +1,84 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.sshj.config; + +import javax.inject.Named; + +import org.jclouds.Constants; +import org.jclouds.domain.Credentials; +import org.jclouds.http.handlers.BackoffLimitedRetryHandler; +import org.jclouds.net.IPSocket; +import org.jclouds.predicates.InetSocketAddressConnect; +import org.jclouds.predicates.SocketOpen; +import org.jclouds.ssh.ConfiguresSshClient; +import org.jclouds.ssh.SshClient; +import org.jclouds.sshj.SshjSshClient; +import org.jclouds.util.CredentialUtils; + +import com.google.inject.AbstractModule; +import com.google.inject.Inject; +import com.google.inject.Injector; +import com.google.inject.Scopes; + +/** + * + * @author Adrian Cole + */ +@ConfiguresSshClient +public class SshjSshClientModule extends AbstractModule { + + protected void configure() { + bind(SshClient.Factory.class).to(Factory.class).in(Scopes.SINGLETON); + bind(SocketOpen.class).to(InetSocketAddressConnect.class).in(Scopes.SINGLETON); + } + + private static class Factory implements SshClient.Factory { + @Named(Constants.PROPERTY_CONNECTION_TIMEOUT) + @Inject(optional = true) + int timeout = 60000; + + private final BackoffLimitedRetryHandler backoffLimitedRetryHandler; + private final Injector injector; + + @SuppressWarnings("unused") + @Inject + public Factory(BackoffLimitedRetryHandler backoffLimitedRetryHandler, Injector injector) { + this.backoffLimitedRetryHandler = backoffLimitedRetryHandler; + this.injector = injector; + } + + public SshClient create(IPSocket socket, String username, String password) { + SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, timeout, username, password, null); + injector.injectMembers(client);// add logger + return client; + } + + public SshClient create(IPSocket socket, String username, byte[] privateKey) { + SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, timeout, username, null, privateKey); + injector.injectMembers(client);// add logger + return client; + } + + @Override + public SshClient create(IPSocket socket, Credentials credentials) { + return CredentialUtils.isPrivateKeyCredential(credentials) ? create(socket, credentials.identity, + credentials.credential.getBytes()) : create(socket, credentials.identity, credentials.credential); + } + } +} diff --git a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java new file mode 100644 index 0000000000..0a712f55b7 --- /dev/null +++ b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java @@ -0,0 +1,145 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.sshj; + +import static org.testng.Assert.assertEquals; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.domain.Credentials; +import org.jclouds.io.Payload; +import org.jclouds.io.Payloads; +import org.jclouds.net.IPSocket; +import org.jclouds.ssh.SshClient; +import org.jclouds.sshj.config.SshjSshClientModule; +import org.jclouds.util.Strings2; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; + +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests the ability of a {@link SshjSshClient} + * + * @author Adrian Cole + */ +@Test(groups = "live") +public class SshjSshClientLiveTest { + protected static final String sshHost = System.getProperty("test.ssh.host", "localhost"); + protected static final String sshPort = System.getProperty("test.ssh.port", "22"); + protected static final String sshUser = System.getProperty("test.ssh.username"); + protected static final String sshPass = System.getProperty("test.ssh.password"); + protected static final String sshKeyFile = System.getProperty("test.ssh.keyfile"); + private File temp; + + @BeforeGroups(groups = { "live" }) + public SshClient setupClient() throws NumberFormatException, FileNotFoundException, IOException { + int port = Integer.parseInt(sshPort); + if (sshUser == null + || ((sshPass == null || sshPass.trim().equals("")) && (sshKeyFile == null || sshKeyFile.trim().equals(""))) + || sshUser.trim().equals("")) { + System.err.println("ssh credentials not present. Tests will be lame"); + return new SshClient() { + + public void connect() { + } + + public void disconnect() { + } + + public Payload get(String path) { + if (path.equals("/etc/passwd")) { + return Payloads.newStringPayload("root"); + } else if (path.equals(temp.getAbsolutePath())) { + return Payloads.newStringPayload("rabbit"); + } + throw new RuntimeException("path " + path + " not stubbed"); + } + + public ExecResponse exec(String command) { + if (command.equals("hostname")) { + return new ExecResponse(sshHost, "", 0); + } + throw new RuntimeException("command " + command + " not stubbed"); + } + + @Override + public void put(String path, Payload contents) { + + } + + @Override + public String getHostAddress() { + return null; + } + + @Override + public String getUsername() { + return null; + } + + @Override + public void put(String path, String contents) { + + } + + }; + } else { + Injector i = Guice.createInjector(new SshjSshClientModule()); + SshClient.Factory factory = i.getInstance(SshClient.Factory.class); + SshClient connection; + if (sshKeyFile != null && !sshKeyFile.trim().equals("")) { + connection = factory.create(new IPSocket(sshHost, port), + new Credentials(sshUser, Strings2.toStringAndClose(new FileInputStream(sshKeyFile)))); + } else { + connection = factory.create(new IPSocket(sshHost, port), new Credentials(sshUser, sshPass)); + } + connection.connect(); + return connection; + } + } + + public void testPutAndGet() throws IOException { + temp = File.createTempFile("foo", "bar"); + temp.deleteOnExit(); + SshClient client = setupClient(); + client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit")); + Payload input = setupClient().get(temp.getAbsolutePath()); + String contents = Strings2.toStringAndClose(input.getInput()); + assertEquals(contents, "rabbit"); + } + + public void testGetEtcPassword() throws IOException { + Payload input = setupClient().get("/etc/passwd"); + String contents = Strings2.toStringAndClose(input.getInput()); + assert contents.indexOf("root") >= 0 : "no root in " + contents; + } + + public void testExecHostname() throws IOException { + ExecResponse response = setupClient().exec("hostname"); + assertEquals(response.getError(), ""); + assertEquals(response.getOutput().trim(), sshHost); + } + +} diff --git a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java new file mode 100644 index 0000000000..bc8e3df1da --- /dev/null +++ b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java @@ -0,0 +1,98 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.sshj; + +import java.io.IOException; +import java.net.UnknownHostException; + +import net.schmizz.sshj.common.SSHException; +import net.schmizz.sshj.connection.ConnectionException; +import net.schmizz.sshj.transport.TransportException; +import net.schmizz.sshj.userauth.UserAuthException; + +import org.jclouds.domain.Credentials; +import org.jclouds.net.IPSocket; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.ssh.SshClient; +import org.jclouds.sshj.config.SshjSshClientModule; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + */ +@Test +public class SshjSshClientTest { + + protected SshjSshClient ssh; + + @BeforeTest + public void setupSsh() throws UnknownHostException { + ssh = createClient(); + } + + protected SshjSshClient createClient() throws UnknownHostException { + Injector i = Guice.createInjector(module()); + SshClient.Factory factory = i.getInstance(SshClient.Factory.class); + SshjSshClient ssh = SshjSshClient.class.cast(factory.create(new IPSocket("localhost", 22), new Credentials( + "username", "password"))); + return ssh; + } + + protected Module module() { + return new SshjSshClientModule(); + } + + @Test(expectedExceptions = AuthorizationException.class) + public void testPropateConvertsAuthException() { + ssh.propagate(new UserAuthException(""), ""); + } + + public void testExceptionClassesRetry() { + assert ssh.shouldRetry(new TransportException("socket closed")); + assert ssh.shouldRetry(new ConnectionException("problem")); + assert !ssh.shouldRetry(new IOException("channel %s is not open", new NullPointerException())); + } + + public void testOnlyRetryAuthWhenSet() throws UnknownHostException { + SshjSshClient ssh1 = createClient(); + assert !ssh1.shouldRetry(new AuthorizationException("problem", null)); + ssh1.retryAuth = true; + assert ssh1.shouldRetry(new AuthorizationException("problem", null)); + } + + public void testExceptionMessagesRetry() { + assert !ssh.shouldRetry(new SSHException("")); + assert !ssh.shouldRetry(new NullPointerException((String) null)); + } + + public void testCausalChainHasMessageContaining() { + assert ssh.causalChainHasMessageContaining( + new SSHException("Session.connect: java.io.IOException: End of IO Stream Read")).apply( + " End of IO Stream Read"); + assert ssh.causalChainHasMessageContaining( + new SSHException("Session.connect: java.net.SocketException: Connection reset")).apply("java.net.Socket"); + assert !ssh.causalChainHasMessageContaining(new NullPointerException()).apply(" End of IO Stream Read"); + } +} diff --git a/drivers/sshj/src/test/java/org/jclouds/sshj/config/SshjSshClientModuleTest.java b/drivers/sshj/src/test/java/org/jclouds/sshj/config/SshjSshClientModuleTest.java new file mode 100644 index 0000000000..83dad34f35 --- /dev/null +++ b/drivers/sshj/src/test/java/org/jclouds/sshj/config/SshjSshClientModuleTest.java @@ -0,0 +1,47 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.sshj.config; + +import java.net.UnknownHostException; + +import org.jclouds.domain.Credentials; +import org.jclouds.net.IPSocket; +import org.jclouds.ssh.SshClient; +import org.jclouds.sshj.SshjSshClient; +import org.testng.annotations.Test; + +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests the ability to configure a {@link SshjSshClient} + * + * @author Adrian Cole + */ +@Test +public class SshjSshClientModuleTest { + + public void testConfigureBindsClient() throws UnknownHostException { + + Injector i = Guice.createInjector(new SshjSshClientModule()); + SshClient.Factory factory = i.getInstance(SshClient.Factory.class); + SshClient connection = factory.create(new IPSocket("localhost", 22), new Credentials("username", "password")); + assert connection instanceof SshjSshClient; + } +} diff --git a/providers/aws-ec2/pom.xml b/providers/aws-ec2/pom.xml index 3979bcdd0e..2e101e8060 100644 --- a/providers/aws-ec2/pom.xml +++ b/providers/aws-ec2/pom.xml @@ -81,21 +81,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index ea74107d69..b2946d5137 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -85,7 +85,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { .build(); assert (template.getImage().getProviderId().startsWith("ami-")) : template; - assertEquals(template.getImage().getOperatingSystem().getVersion(), "10.10"); + assertEquals(template.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(template.getImage().getOperatingSystem().is64Bit(), false); assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); @@ -146,7 +146,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { fastestTemplate = context.getComputeService().templateBuilder().fastest().build(); assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate; assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC1_4XLARGE); - assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); + assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java index aa4ec6a140..fe3df85715 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java @@ -144,7 +144,7 @@ public class AMIClientLiveTest { .put("root-device-type", "ebs")// .build()).ownedBy("137112412989", "099720109477")); assertNotNull(twoResults); - assertEquals(twoResults.size(), 26); + assertEquals(twoResults.size(), 28); } @Test(enabled = false) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java index a499814c8d..21ef73a83b 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java @@ -52,7 +52,7 @@ import org.jclouds.domain.Credentials; import org.jclouds.ec2.domain.KeyPair; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -104,7 +104,7 @@ public class AWSKeyPairClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); computeContext = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new JschSshClientModule()), overrides); + new Log4JLoggingModule(), new SshjSshClientModule()), overrides); context = computeContext.getProviderSpecificContext(); client = context.getApi().getKeyPairServices(); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index cb31485d5b..76fbf6cffa 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -51,7 +51,7 @@ import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeGroups; @@ -108,7 +108,7 @@ public class PlacementGroupClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides); + ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); keyPair = setupKeyPair(); client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java index 439493a5e3..9904a021b3 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java @@ -47,7 +47,7 @@ import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeGroups; @@ -105,7 +105,7 @@ public class SpotInstanceClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new JschSshClientModule()), overrides); + new Log4JLoggingModule(), new SshjSshClientModule()), overrides); client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()); activeTester = new RetryablePredicate(new SpotInstanceRequestActive(client), diff --git a/providers/bluelock-vcdirector/pom.xml b/providers/bluelock-vcdirector/pom.xml index 60ebaa2a63..f59de24e4a 100644 --- a/providers/bluelock-vcdirector/pom.xml +++ b/providers/bluelock-vcdirector/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/bluelock-vcloud-vcenterprise/pom.xml b/providers/bluelock-vcloud-vcenterprise/pom.xml index 3b6649e3ff..4e059e214b 100644 --- a/providers/bluelock-vcloud-vcenterprise/pom.xml +++ b/providers/bluelock-vcloud-vcenterprise/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/bluelock-vcloud-zone01/pom.xml b/providers/bluelock-vcloud-zone01/pom.xml index 5749580a34..9826bff3d0 100644 --- a/providers/bluelock-vcloud-zone01/pom.xml +++ b/providers/bluelock-vcloud-zone01/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/cloudservers-uk/pom.xml b/providers/cloudservers-uk/pom.xml index aacae5b086..3eff9f3d78 100644 --- a/providers/cloudservers-uk/pom.xml +++ b/providers/cloudservers-uk/pom.xml @@ -81,21 +81,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/cloudservers-us/pom.xml b/providers/cloudservers-us/pom.xml index 3ead858b01..07914f1be4 100644 --- a/providers/cloudservers-us/pom.xml +++ b/providers/cloudservers-us/pom.xml @@ -81,21 +81,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/cloudsigma-zrh/pom.xml b/providers/cloudsigma-zrh/pom.xml index 1615ca2102..0f76dd0e19 100644 --- a/providers/cloudsigma-zrh/pom.xml +++ b/providers/cloudsigma-zrh/pom.xml @@ -53,15 +53,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - org.jclouds jclouds-core @@ -76,12 +71,6 @@ test-jar test - - log4j - log4j - 1.2.16 - test - org.jclouds.driver jclouds-log4j diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java index 0c190bc2bc..a46109fdb9 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java @@ -55,7 +55,7 @@ import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -411,7 +411,7 @@ public class CloudSigmaClientLiveTest { } protected void doConnectViaSsh(Server server, Credentials creds) throws IOException { - SshClient ssh = Guice.createInjector(new JschSshClientModule()).getInstance(SshClient.Factory.class) + SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class) .create(new IPSocket(server.getVnc().getIp(), 22), creds); try { ssh.connect(); diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java index 39554492d8..25551860f6 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java @@ -19,9 +19,11 @@ package org.jclouds.cloudsigma.compute; import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; +import com.google.inject.Module; + /** * @author Adrian Cole */ @@ -32,8 +34,8 @@ public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected Module getSshModule() { + return new SshjSshClientModule(); } } diff --git a/providers/elastichosts-lon-b/pom.xml b/providers/elastichosts-lon-b/pom.xml index 6246f98bc5..42ec681ec6 100644 --- a/providers/elastichosts-lon-b/pom.xml +++ b/providers/elastichosts-lon-b/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/elastichosts-lon-p/pom.xml b/providers/elastichosts-lon-p/pom.xml index 790c050f0c..f2bb50a6f3 100644 --- a/providers/elastichosts-lon-p/pom.xml +++ b/providers/elastichosts-lon-p/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/elastichosts-sat-p/pom.xml b/providers/elastichosts-sat-p/pom.xml index 6ede37a6bb..e4d897af3d 100644 --- a/providers/elastichosts-sat-p/pom.xml +++ b/providers/elastichosts-sat-p/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/eucalyptus-partnercloud-ec2/pom.xml b/providers/eucalyptus-partnercloud-ec2/pom.xml index 115c2caab5..c9303a9aff 100644 --- a/providers/eucalyptus-partnercloud-ec2/pom.xml +++ b/providers/eucalyptus-partnercloud-ec2/pom.xml @@ -82,17 +82,6 @@ test-jar test - - org.jclouds.driver - jclouds-jsch - ${project.version} - test - - - com.jcraft - jsch - test - org.jclouds.driver jclouds-log4j @@ -100,9 +89,9 @@ test - log4j - log4j - 1.2.16 + org.jclouds.driver + jclouds-sshj + ${project.version} test diff --git a/providers/gogrid/pom.xml b/providers/gogrid/pom.xml index 88120d148a..b91dd483ac 100644 --- a/providers/gogrid/pom.xml +++ b/providers/gogrid/pom.xml @@ -50,12 +50,8 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} - - - com.jcraft - jsch test @@ -72,12 +68,6 @@ test-jar test - - log4j - log4j - 1.2.16 - test - org.jclouds.driver jclouds-log4j diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java index 57812360a3..a331be580a 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java @@ -62,7 +62,7 @@ import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.jsch.JschSshClient; +import org.jclouds.sshj.SshjSshClient; import org.testng.SkipException; import org.testng.TestException; import org.testng.annotations.AfterTest; @@ -379,7 +379,7 @@ public class GoGridLiveTestDisabled { socketOpen.apply(socket); - SshClient sshClient = new JschSshClient(new BackoffLimitedRetryHandler(), socket, 60000, + SshClient sshClient = new SshjSshClient(new BackoffLimitedRetryHandler(), socket, 60000, instanceCredentials.identity, instanceCredentials.credential, null); sshClient.connect(); String output = sshClient.exec("df").getOutput(); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java index 68137dad29..fca45c3830 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java @@ -21,9 +21,11 @@ package org.jclouds.gogrid.compute; import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; +import com.google.inject.Module; + /** * @author Oleksiy Yarmula */ @@ -35,8 +37,8 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest { } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected Module getSshModule() { + return new SshjSshClientModule(); } protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) { diff --git a/providers/greenhousedata-element-vcloud/pom.xml b/providers/greenhousedata-element-vcloud/pom.xml index caf0cfe0ae..04d659f3f0 100644 --- a/providers/greenhousedata-element-vcloud/pom.xml +++ b/providers/greenhousedata-element-vcloud/pom.xml @@ -77,21 +77,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/openhosting-east1/pom.xml b/providers/openhosting-east1/pom.xml index 13a3f994cd..dda6f6530d 100644 --- a/providers/openhosting-east1/pom.xml +++ b/providers/openhosting-east1/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/savvis-symphonyvpdc/pom.xml b/providers/savvis-symphonyvpdc/pom.xml index 0d1967cf66..8f0bb95ee9 100644 --- a/providers/savvis-symphonyvpdc/pom.xml +++ b/providers/savvis-symphonyvpdc/pom.xml @@ -83,21 +83,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - org.jclouds.driver jclouds-log4j diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java index 1146178803..b361d5ff26 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java @@ -4,7 +4,7 @@ import java.util.Properties; import org.jclouds.Constants; import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; import com.google.inject.Module; @@ -38,7 +38,7 @@ public class VPDCComputeServiceLiveTestDisabled extends BaseComputeServiceLiveTe @Override protected Module getSshModule() { - return new JschSshClientModule(); + return new SshjSshClientModule(); } } diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java index 12e30f4951..fe55b42a1b 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java @@ -34,7 +34,7 @@ import org.jclouds.savvis.vpdc.VPDCAsyncClient; import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.savvis.vpdc.predicates.TaskSuccess; import org.jclouds.savvis.vpdc.reference.VPDCConstants; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -91,7 +91,7 @@ public class BaseVPDCClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new JschSshClientModule()), overrides); + new Log4JLoggingModule(), new SshjSshClientModule()), overrides); restContext = context.getProviderSpecificContext(); taskTester = new RetryablePredicate(new TaskSuccess(restContext.getApi()), 7200, 10, TimeUnit.SECONDS); } diff --git a/providers/serverlove-z1-man/pom.xml b/providers/serverlove-z1-man/pom.xml index 80eac56790..699274fc93 100644 --- a/providers/serverlove-z1-man/pom.xml +++ b/providers/serverlove-z1-man/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/skalicloud-sdg-my/pom.xml b/providers/skalicloud-sdg-my/pom.xml index ed9699511a..d409280fa9 100644 --- a/providers/skalicloud-sdg-my/pom.xml +++ b/providers/skalicloud-sdg-my/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/slicehost/pom.xml b/providers/slicehost/pom.xml index 4292e700f9..2a55a6a5fd 100644 --- a/providers/slicehost/pom.xml +++ b/providers/slicehost/pom.xml @@ -60,12 +60,6 @@ test-jar test - - log4j - log4j - 1.2.16 - test - org.jclouds.driver jclouds-log4j @@ -74,15 +68,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java index 4dda7f484a..f1609ac0c3 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java @@ -44,7 +44,7 @@ import org.jclouds.slicehost.domain.Image; import org.jclouds.slicehost.domain.Slice; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -96,7 +96,7 @@ public class SlicehostClientLiveTest { Properties overrides = setupProperties(); Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector(); + ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides).buildInjector(); client = injector.getInstance(SlicehostClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java index ec18651adf..2d2bbfb632 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java @@ -19,7 +19,7 @@ package org.jclouds.slicehost.compute; import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; /** @@ -35,8 +35,8 @@ public class SlicehostComputeServiceLiveTest extends BaseComputeServiceLiveTest } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected SshjSshClientModule getSshModule() { + return new SshjSshClientModule(); } @Test(expectedExceptions = UnsupportedOperationException.class) diff --git a/providers/stratogen-vcloud-mycloud/pom.xml b/providers/stratogen-vcloud-mycloud/pom.xml index ee80c902eb..d342619573 100644 --- a/providers/stratogen-vcloud-mycloud/pom.xml +++ b/providers/stratogen-vcloud-mycloud/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/trmk-ecloud/pom.xml b/providers/trmk-ecloud/pom.xml index 509a788c8a..ab50ade62f 100644 --- a/providers/trmk-ecloud/pom.xml +++ b/providers/trmk-ecloud/pom.xml @@ -77,21 +77,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java index 42a7ac0b2e..13fa3f4b45 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java @@ -32,12 +32,14 @@ import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.rest.RestContext; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; import org.jclouds.trmk.vcloud_0_8.domain.VApp; import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants; import org.testng.annotations.Test; +import com.google.inject.Module; + /** * This test is disabled, as it doesn't work while there are too few public ip * addresses. @@ -108,8 +110,8 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected Module getSshModule() { + return new SshjSshClientModule(); } } \ No newline at end of file diff --git a/providers/trmk-vcloudexpress/pom.xml b/providers/trmk-vcloudexpress/pom.xml index 931bc5dd28..a148161bcd 100644 --- a/providers/trmk-vcloudexpress/pom.xml +++ b/providers/trmk-vcloudexpress/pom.xml @@ -76,21 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java index 338ed5d66d..1422b45a0a 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java @@ -30,12 +30,10 @@ import org.jclouds.Constants; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.domain.InternetService; import org.jclouds.trmk.vcloud_0_8.domain.Node; import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress; -import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressAsyncClient; -import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressClient; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -123,7 +121,7 @@ public class InternetServiceLiveTest { Properties overrides = setupProperties(); context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides) + ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides) .getProviderSpecificContext(); tmClient = context.getApi(); diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java index 46399c984f..6007f93cab 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java @@ -30,7 +30,7 @@ import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.rest.RestContext; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; import org.jclouds.trmk.vcloud_0_8.domain.VApp; import org.testng.annotations.Test; @@ -93,8 +93,8 @@ public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeSer } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected SshjSshClientModule getSshModule() { + return new SshjSshClientModule(); } } \ No newline at end of file diff --git a/sandbox-apis/cloudstack/pom.xml b/sandbox-apis/cloudstack/pom.xml index 8afaca897c..bc0f863d3c 100644 --- a/sandbox-apis/cloudstack/pom.xml +++ b/sandbox-apis/cloudstack/pom.xml @@ -83,21 +83,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test - - - log4j - log4j - 1.2.16 - test - org.jclouds.driver jclouds-log4j diff --git a/sandbox-providers/ibm-smartcloud/pom.xml b/sandbox-providers/ibm-smartcloud/pom.xml index bee405ad6b..90c7ceb805 100644 --- a/sandbox-providers/ibm-smartcloud/pom.xml +++ b/sandbox-providers/ibm-smartcloud/pom.xml @@ -92,7 +92,7 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test diff --git a/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/BaseIBMSmartCloudClientLiveTest.java b/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/BaseIBMSmartCloudClientLiveTest.java index b4f8408bc4..678f70bdf3 100644 --- a/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/BaseIBMSmartCloudClientLiveTest.java +++ b/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/BaseIBMSmartCloudClientLiveTest.java @@ -30,7 +30,7 @@ import org.jclouds.compute.ComputeTestUtils; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContextFactory; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -82,7 +82,7 @@ public abstract class BaseIBMSmartCloudClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new RestContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule(), - new JschSshClientModule()), overrides); + new SshjSshClientModule()), overrides); connection = context.getApi(); keyPair = ComputeTestUtils.setupKeyPair(); diff --git a/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/IBMSmartCloudClientLiveTest.java b/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/IBMSmartCloudClientLiveTest.java index 7b93274586..631a1b023d 100644 --- a/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/IBMSmartCloudClientLiveTest.java +++ b/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/IBMSmartCloudClientLiveTest.java @@ -37,14 +37,14 @@ import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.ibm.smartcloud.domain.Address; import org.jclouds.ibm.smartcloud.domain.Image; import org.jclouds.ibm.smartcloud.domain.Instance; +import org.jclouds.ibm.smartcloud.domain.Instance.Software; import org.jclouds.ibm.smartcloud.domain.InstanceType; import org.jclouds.ibm.smartcloud.domain.Key; import org.jclouds.ibm.smartcloud.domain.Location; import org.jclouds.ibm.smartcloud.domain.Offering; import org.jclouds.ibm.smartcloud.domain.StorageOffering; -import org.jclouds.ibm.smartcloud.domain.Volume; -import org.jclouds.ibm.smartcloud.domain.Instance.Software; import org.jclouds.ibm.smartcloud.domain.StorageOffering.Format; +import org.jclouds.ibm.smartcloud.domain.Volume; import org.jclouds.ibm.smartcloud.predicates.AddressFree; import org.jclouds.ibm.smartcloud.predicates.InstanceActive; import org.jclouds.ibm.smartcloud.predicates.InstanceActiveOrFailed; @@ -55,7 +55,7 @@ import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; -import org.jclouds.ssh.jsch.JschSshClient; +import org.jclouds.sshj.SshjSshClient; import org.testng.annotations.AfterTest; import org.testng.annotations.Test; @@ -498,7 +498,7 @@ public class IBMSmartCloudClientLiveTest extends BaseIBMSmartCloudClientLiveTest socketOpen.apply(socket); - SshClient ssh = new JschSshClient(new BackoffLimitedRetryHandler(), socket, 60000, credentials.identity, null, + SshClient ssh = new SshjSshClient(new BackoffLimitedRetryHandler(), socket, 60000, credentials.identity, null, credentials.credential.getBytes()); try { ssh.connect(); diff --git a/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/compute/IBMSmartCloudComputeServiceLiveTest.java b/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/compute/IBMSmartCloudComputeServiceLiveTest.java index fe4e26d1aa..acdaa5203a 100644 --- a/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/compute/IBMSmartCloudComputeServiceLiveTest.java +++ b/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/compute/IBMSmartCloudComputeServiceLiveTest.java @@ -19,10 +19,12 @@ package org.jclouds.ibm.smartcloud.compute; import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.google.inject.Module; + /** * @author Adrian Cole */ @@ -36,7 +38,7 @@ public class IBMSmartCloudComputeServiceLiveTest extends BaseComputeServiceLiveT } @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); + protected Module getSshModule() { + return new SshjSshClientModule(); } } diff --git a/sandbox-providers/virtacore-vcloudexpress/pom.xml b/sandbox-providers/virtacore-vcloudexpress/pom.xml index fe4fcdd85b..ae2bb87393 100644 --- a/sandbox-providers/virtacore-vcloudexpress/pom.xml +++ b/sandbox-providers/virtacore-vcloudexpress/pom.xml @@ -76,15 +76,10 @@ org.jclouds.driver - jclouds-jsch + jclouds-sshj ${project.version} test - - com.jcraft - jsch - test -