diff --git a/labs/virtualbox/pom.xml b/labs/virtualbox/pom.xml
index 0731a0a42c..e168f345a6 100644
--- a/labs/virtualbox/pom.xml
+++ b/labs/virtualbox/pom.xml
@@ -78,6 +78,16 @@
commons-io
1.4
+
+ org.jclouds.driver
+ jclouds-sshj
+ ${project.version}
+
+
+ org.jclouds.driver
+ jclouds-slf4j
+ ${project.version}
+
org.jclouds
jclouds-core
@@ -92,18 +102,6 @@
test-jar
test
-
- org.jclouds.driver
- jclouds-sshj
- ${project.version}
- test
-
-
- org.jclouds.driver
- jclouds-slf4j
- ${project.version}
- test
-
ch.qos.logback
logback-classic
diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToSshClient.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToSshClient.java
index a636da289b..c98d29087a 100644
--- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToSshClient.java
+++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToSshClient.java
@@ -18,15 +18,23 @@
*/
package org.jclouds.virtualbox.functions;
+import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
+import javax.annotation.Resource;
+import javax.inject.Named;
import javax.inject.Singleton;
+import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.LoginCredentials;
+import org.jclouds.logging.Logger;
import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient;
import org.virtualbox_4_1.IMachine;
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.Splitter;
@@ -35,6 +43,11 @@ import com.google.inject.Inject;
@Singleton
public class IMachineToSshClient implements Function {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
private final SshClient.Factory sshClientFactory;
@Inject
@@ -44,7 +57,16 @@ public class IMachineToSshClient implements Function {
@Override
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;
checkState(networkAdapter != null);
for (String nameProtocolnumberAddressInboudportGuestTargetport : networkAdapter.getNatDriver().getRedirects()) {
@@ -55,11 +77,13 @@ public class IMachineToSshClient implements Function {
String targetPort = Iterables.get(stuff, 5);
// TODO: we need a way to align the default login credentials from the iso with the
// vmspec
+ logger.warn("PROTOCOLNUMBER: "+protocolNumber);
if ("1".equals(protocolNumber) && "22".equals(targetPort)) {
client = sshClientFactory.create(new IPSocket(hostAddress, Integer.parseInt(inboundPort)),
LoginCredentials.builder().user("toor").password("password").authenticateSudo(true).build());
}
}
+ checkNotNull(client);
return client;
}
}
\ No newline at end of file
diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/ImageFromYamlStringTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/ImageFromYamlStringTest.java
index 13e3aa273d..6160723751 100644
--- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/ImageFromYamlStringTest.java
+++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/ImageFromYamlStringTest.java
@@ -31,7 +31,7 @@ import org.jclouds.compute.domain.OsFamily;
import org.testng.annotations.Test;
import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
/**
* @author Andrea Turli
@@ -62,6 +62,6 @@ public class ImageFromYamlStringTest {
return yamlFileLines.toString();
}
});
- assertEquals(parser.get(), ImmutableMap.of(TEST1.getId(), TEST1));
+ assertEquals(Iterables.getFirst(parser.get().keySet(), null), TEST1);
}
}
\ No newline at end of file