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 c98d29087a..1b9825ddf5 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 @@ -57,18 +57,10 @@ public class IMachineToSshClient implements Function { @Override public SshClient apply(final IMachine vm) { - 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; - } - } + INetworkAdapter networkAdapter = vm.getNetworkAdapter(0L); SshClient client = null; - checkState(networkAdapter != null); + checkNotNull(networkAdapter); for (String nameProtocolnumberAddressInboudportGuestTargetport : networkAdapter.getNatDriver().getRedirects()) { Iterable stuff = Splitter.on(',').split(nameProtocolnumberAddressInboudportGuestTargetport); String protocolNumber = Iterables.get(stuff, 1); @@ -77,7 +69,7 @@ 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); + logger.warn("PROTOCOLNUMBER: "+nameProtocolnumberAddressInboudportGuestTargetport); 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()); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapterLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapterLiveTest.java index 2bef129418..82b0473a74 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapterLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapterLiveTest.java @@ -20,7 +20,6 @@ package org.jclouds.virtualbox.compute; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.domain.ExecResponse; @@ -32,9 +31,12 @@ import org.jclouds.domain.LoginCredentials; import org.jclouds.net.IPSocket; import org.jclouds.ssh.SshClient; import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest; +import org.jclouds.virtualbox.domain.VmSpec; +import org.testng.annotations.AfterClass; import org.testng.annotations.Test; import org.virtualbox_4_1.IMachine; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @Test(groups = "live", singleThreaded = true, testName = "VirtualBoxComputeServiceAdapterLiveTest") @@ -92,8 +94,7 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien @Test public void testListHardwareProfiles() { Iterable profiles = adapter.listHardwareProfiles(); - assertTrue(Iterables.isEmpty(profiles)); - // check state; + assertEquals(1,Iterables.size(profiles)); } @Test