mirror of https://github.com/apache/jclouds.git
added dependencies
This commit is contained in:
parent
960e6f8e0a
commit
d0e770c99b
|
@ -78,6 +78,16 @@
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.driver</groupId>
|
||||||
|
<artifactId>jclouds-sshj</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.driver</groupId>
|
||||||
|
<artifactId>jclouds-slf4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-core</artifactId>
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
@ -92,18 +102,6 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds.driver</groupId>
|
|
||||||
<artifactId>jclouds-sshj</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds.driver</groupId>
|
|
||||||
<artifactId>jclouds-slf4j</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
|
|
|
@ -18,15 +18,23 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.INetworkAdapter;
|
import org.virtualbox_4_1.INetworkAdapter;
|
||||||
|
import org.virtualbox_4_1.ISystemProperties;
|
||||||
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
import org.virtualbox_4_1.jaxws.ISystemPropertiesGetMaxNetworkAdapters;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -35,6 +43,11 @@ import com.google.inject.Inject;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class IMachineToSshClient implements Function<IMachine, SshClient> {
|
public class IMachineToSshClient implements Function<IMachine, SshClient> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final SshClient.Factory sshClientFactory;
|
private final SshClient.Factory sshClientFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -44,7 +57,16 @@ public class IMachineToSshClient implements Function<IMachine, SshClient> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SshClient apply(final IMachine vm) {
|
public SshClient apply(final IMachine vm) {
|
||||||
INetworkAdapter networkAdapter = vm.getNetworkAdapter(0l);
|
INetworkAdapter networkAdapter = null;
|
||||||
|
for (long i = 0 ; i < 1000 ; i++){
|
||||||
|
try {
|
||||||
|
networkAdapter = vm.getNetworkAdapter(i);
|
||||||
|
logger.warn("NATDRIVERREDIRECTS: "+networkAdapter.getNatDriver().getRedirects().toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SshClient client = null;
|
SshClient client = null;
|
||||||
checkState(networkAdapter != null);
|
checkState(networkAdapter != null);
|
||||||
for (String nameProtocolnumberAddressInboudportGuestTargetport : networkAdapter.getNatDriver().getRedirects()) {
|
for (String nameProtocolnumberAddressInboudportGuestTargetport : networkAdapter.getNatDriver().getRedirects()) {
|
||||||
|
@ -55,11 +77,13 @@ public class IMachineToSshClient implements Function<IMachine, SshClient> {
|
||||||
String targetPort = Iterables.get(stuff, 5);
|
String targetPort = Iterables.get(stuff, 5);
|
||||||
// TODO: we need a way to align the default login credentials from the iso with the
|
// TODO: we need a way to align the default login credentials from the iso with the
|
||||||
// vmspec
|
// vmspec
|
||||||
|
logger.warn("PROTOCOLNUMBER: "+protocolNumber);
|
||||||
if ("1".equals(protocolNumber) && "22".equals(targetPort)) {
|
if ("1".equals(protocolNumber) && "22".equals(targetPort)) {
|
||||||
client = sshClientFactory.create(new IPSocket(hostAddress, Integer.parseInt(inboundPort)),
|
client = sshClientFactory.create(new IPSocket(hostAddress, Integer.parseInt(inboundPort)),
|
||||||
LoginCredentials.builder().user("toor").password("password").authenticateSudo(true).build());
|
LoginCredentials.builder().user("toor").password("password").authenticateSudo(true).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
checkNotNull(client);
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,7 +31,7 @@ import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrea Turli
|
* @author Andrea Turli
|
||||||
|
@ -62,6 +62,6 @@ public class ImageFromYamlStringTest {
|
||||||
return yamlFileLines.toString();
|
return yamlFileLines.toString();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertEquals(parser.get(), ImmutableMap.of(TEST1.getId(), TEST1));
|
assertEquals(Iterables.getFirst(parser.get().keySet(), null), TEST1);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue