sshclien to the master is now workign

This commit is contained in:
David Ribeiro Alves 2012-03-04 18:54:57 +00:00
parent af662850a9
commit 406c6a9fc4
2 changed files with 7 additions and 14 deletions

View File

@ -57,18 +57,10 @@ public class IMachineToSshClient implements Function<IMachine, SshClient> {
@Override @Override
public SshClient apply(final IMachine vm) { public SshClient apply(final IMachine vm) {
INetworkAdapter networkAdapter = null; INetworkAdapter networkAdapter = vm.getNetworkAdapter(0L);
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); checkNotNull(networkAdapter);
for (String nameProtocolnumberAddressInboudportGuestTargetport : networkAdapter.getNatDriver().getRedirects()) { for (String nameProtocolnumberAddressInboudportGuestTargetport : networkAdapter.getNatDriver().getRedirects()) {
Iterable<String> stuff = Splitter.on(',').split(nameProtocolnumberAddressInboudportGuestTargetport); Iterable<String> stuff = Splitter.on(',').split(nameProtocolnumberAddressInboudportGuestTargetport);
String protocolNumber = Iterables.get(stuff, 1); String protocolNumber = Iterables.get(stuff, 1);
@ -77,7 +69,7 @@ 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); logger.warn("PROTOCOLNUMBER: "+nameProtocolnumberAddressInboudportGuestTargetport);
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());

View File

@ -20,7 +20,6 @@
package org.jclouds.virtualbox.compute; package org.jclouds.virtualbox.compute;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
@ -32,9 +31,12 @@ import org.jclouds.domain.LoginCredentials;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest; import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
import org.jclouds.virtualbox.domain.VmSpec;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.virtualbox_4_1.IMachine; import org.virtualbox_4_1.IMachine;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@Test(groups = "live", singleThreaded = true, testName = "VirtualBoxComputeServiceAdapterLiveTest") @Test(groups = "live", singleThreaded = true, testName = "VirtualBoxComputeServiceAdapterLiveTest")
@ -92,8 +94,7 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien
@Test @Test
public void testListHardwareProfiles() { public void testListHardwareProfiles() {
Iterable<IMachine> profiles = adapter.listHardwareProfiles(); Iterable<IMachine> profiles = adapter.listHardwareProfiles();
assertTrue(Iterables.isEmpty(profiles)); assertEquals(1,Iterables.size(profiles));
// check state;
} }
@Test @Test