corrected IMachineToNodeMetadata to comply with the new non-natted ip

This commit is contained in:
David Ribeiro Alves 2012-03-21 22:19:03 +00:00
parent 92a940e95d
commit 5bca27923c
2 changed files with 15 additions and 11 deletions

View File

@ -248,7 +248,8 @@ public class VirtualBoxComputeServiceContextModule extends
@VisibleForTesting @VisibleForTesting
public static final Map<MachineState, NodeState> machineToNodeState = ImmutableMap public static final Map<MachineState, NodeState> machineToNodeState = ImmutableMap
.<MachineState, NodeState> builder().put(MachineState.Running, NodeState.RUNNING) .<MachineState, NodeState> builder()
.put(MachineState.Running, NodeState.RUNNING)
.put(MachineState.PoweredOff, NodeState.SUSPENDED) .put(MachineState.PoweredOff, NodeState.SUSPENDED)
.put(MachineState.DeletingSnapshot, NodeState.PENDING) .put(MachineState.DeletingSnapshot, NodeState.PENDING)
.put(MachineState.DeletingSnapshotOnline, NodeState.PENDING) .put(MachineState.DeletingSnapshotOnline, NodeState.PENDING)
@ -260,12 +261,15 @@ public class VirtualBoxComputeServiceContextModule extends
.put(MachineState.Stopping, NodeState.PENDING) .put(MachineState.Stopping, NodeState.PENDING)
.put(MachineState.Restoring, NodeState.PENDING) .put(MachineState.Restoring, NodeState.PENDING)
// TODO What to map these states to? // TODO What to map these states to?
.put(MachineState.FirstOnline, NodeState.PENDING).put(MachineState.FirstTransient, NodeState.PENDING) .put(MachineState.FirstOnline, NodeState.PENDING)
.put(MachineState.LastOnline, NodeState.PENDING).put(MachineState.LastTransient, NodeState.PENDING) .put(MachineState.FirstTransient, NodeState.PENDING)
.put(MachineState.Teleported, NodeState.PENDING).put(MachineState.TeleportingIn, NodeState.PENDING) .put(MachineState.LastOnline, NodeState.PENDING)
.put(MachineState.TeleportingPausedVM, NodeState.PENDING).put(MachineState.Aborted, NodeState.ERROR) .put(MachineState.LastTransient, NodeState.PENDING)
.put(MachineState.Teleported, NodeState.PENDING)
.put(MachineState.TeleportingIn, NodeState.PENDING)
.put(MachineState.TeleportingPausedVM, NodeState.PENDING)
.put(MachineState.Aborted, NodeState.ERROR)
.put(MachineState.Stuck, NodeState.ERROR) .put(MachineState.Stuck, NodeState.ERROR)
.put(MachineState.Null, NodeState.UNRECOGNIZED).build(); .put(MachineState.Null, NodeState.UNRECOGNIZED).build();
} }

View File

@ -44,7 +44,7 @@ public class IMachineToNodeMetadataTest {
IMachine vm = createNiceMock(IMachine.class); IMachine vm = createNiceMock(IMachine.class);
expect(vm.getName()).andReturn("mocked-vm").anyTimes(); expect(vm.getName()).andReturn("mocked-vm").anyTimes();
expect(vm.getState()).andReturn(MachineState.PoweredOff).once(); expect(vm.getState()).andReturn(MachineState.PoweredOff).anyTimes();
INetworkAdapter nat = createNiceMock(INetworkAdapter.class); INetworkAdapter nat = createNiceMock(INetworkAdapter.class);
INATEngine natEng = createNiceMock(INATEngine.class); INATEngine natEng = createNiceMock(INATEngine.class);
@ -53,7 +53,7 @@ public class IMachineToNodeMetadataTest {
expect(nat.getAttachmentType()).andReturn(NetworkAttachmentType.NAT).once(); expect(nat.getAttachmentType()).andReturn(NetworkAttachmentType.NAT).once();
expect(nat.getNatDriver()).andReturn(natEng).anyTimes(); expect(nat.getNatDriver()).andReturn(natEng).anyTimes();
expect(natEng.getHostIP()).andReturn("127.0.0.1").once(); expect(natEng.getHostIP()).andReturn("127.0.0.1").once();
expect(natEng.getRedirects()).andReturn(ImmutableList.of("0,1,127.0.0.1,3001,,22")); expect(natEng.getRedirects()).andReturn(ImmutableList.of("0,1,127.0.0.1,3000,,22"));
INetworkAdapter hostOnly = createNiceMock(INetworkAdapter.class); INetworkAdapter hostOnly = createNiceMock(INetworkAdapter.class);
@ -63,9 +63,9 @@ public class IMachineToNodeMetadataTest {
assertEquals("mocked-vm", node.getName()); assertEquals("mocked-vm", node.getName());
assertEquals(1, node.getPrivateAddresses().size()); assertEquals(1, node.getPrivateAddresses().size());
assertEquals((NodeCreator.VMS_NETWORK + 1), Iterables.get(node.getPrivateAddresses(), 0)); assertEquals((NodeCreator.VMS_NETWORK + 2), Iterables.get(node.getPrivateAddresses(), 0));
assertEquals(1, node.getPublicAddresses().size()); assertEquals(1, node.getPublicAddresses().size());
assertEquals("127.0.0.1", Iterables.get(node.getPublicAddresses(), 0)); assertEquals((NodeCreator.VMS_NETWORK + 2), Iterables.get(node.getPublicAddresses(), 0));
assertEquals(3001, node.getLoginPort()); assertEquals(22, node.getLoginPort());
} }
} }