Package org.virtualbox_4_2

Examples of org.virtualbox_4_2.INATEngine


   @Test
   public void testCreateSameMediumTwiceWhenUsingOverwrite() throws Exception {
      String path = System.getProperty("user.home") + "/jclouds-virtualbox-test/test-medium-3.vdi";
      HardDisk hardDisk = HardDisk.builder().diskpath(path).controllerPort(0).deviceSlot(0).build();
      new CreateMediumIfNotAlreadyExists(manager, machineUtils, true).apply(hardDisk);
      IMedium iMedium = new CreateMediumIfNotAlreadyExists(manager, machineUtils, true).apply(hardDisk);
      manager.get().getVBox().openMedium(path, DeviceType.HardDisk, AccessMode.ReadWrite, true);
      try {
         assertFileCanBeDeleted(path);
      } finally {
         deleteMediumAndBlockUntilComplete(iMedium);
View Full Code Here


      expect(vBox.openMedium(adminDiskPath, DeviceType.HardDisk, AccessMode.ReadWrite, false)).andReturn(medium);

      String oldMachineId = "a1e03931-29f3-4370-ada3-9547b1009212";
      String oldMachineName = "oldMachine";
      IMachine oldMachine = createMock(IMachine.class);
      IMediumAttachment oldAttachment = createMock(IMediumAttachment.class);
      String oldAttachmentController = "oldAttachmentController";
      int oldAttachmentDevice = 1;
      int oldAttachmentPort = 2;
      IMedium oldMedium = createMock(IMedium.class);
      String oldMediumId = "oldMediumId";
      ISession detachSession = createNiceMock(ISession.class);

      StringBuilder errorBuilder = new StringBuilder();
      errorBuilder.append("org.virtualbox_4_2.VBoxException: VirtualBox error: ");
      errorBuilder.append("Cannot delete storage: medium '/Users/adriancole/jclouds-virtualbox-test/testadmin.vdi ");
      errorBuilder.append("is still attached to the following 1 virtual machine(s): ");
      errorBuilder.append(oldMachineId + " (0x80BB000C)");
      String errorMessage = errorBuilder.toString();

      VBoxException stillAttached = new VBoxException(createNiceMock(Throwable.class), errorMessage);
      expect(medium.deleteStorage()).andThrow(stillAttached);

      expect(vBox.findMachine(oldMachineId)).andReturn(oldMachine);
      expect(oldMachine.getMediumAttachments()).andReturn(ImmutableList.of(oldAttachment));
      expect(oldAttachment.getMedium()).andReturn(oldMedium);
      expect(oldMedium.getId()).andReturn(oldMediumId);
      // in this case, they are the same medium, so safe to detach
      expect(medium.getId()).andReturn(oldMediumId);
      expect(oldMachine.getName()).andReturn(oldMachineName);
      expect(oldAttachment.getController()).andReturn(oldAttachmentController);
      expect(oldAttachment.getDevice()).andReturn(oldAttachmentDevice);
      expect(oldAttachment.getPort()).andReturn(oldAttachmentPort);
      // TODO: is this ok that we searched by ID last time?
      expect(vBox.findMachine(oldMachineName)).andReturn(oldMachine);
      expect(manager.getSessionObject()).andReturn(detachSession);
      oldMachine.lockMachine(detachSession, LockType.Write);
      expect(detachSession.getMachine()).andReturn(oldMachine);
View Full Code Here

  @Test
  public void testApplyNetworkingToNonExistingAdapter() throws Exception {
    Long slotId = 0l;
    IMachine machine = createMock(IMachine.class);
    INetworkAdapter iNetworkAdapter = createMock(INetworkAdapter.class);
    INATEngine natEngine = createMock(INATEngine.class);

    expect(machine.getNetworkAdapter(slotId)).andReturn(iNetworkAdapter);
    iNetworkAdapter.setAttachmentType(NAT);
    expect(iNetworkAdapter.getNATEngine()).andReturn(natEngine).anyTimes();

    List<String> redirects = Lists.newArrayList();
    expect(natEngine.getRedirects()).andReturn(redirects);
    natEngine.addRedirect("TCP@127.0.0.1:2222->:22", TCP, "127.0.0.1",
        2222, "", 22);
    iNetworkAdapter.setEnabled(true);
    machine.saveSettings();

    replay(machine, iNetworkAdapter, natEngine);
View Full Code Here

  @Test
  public void testApplySkipsWhenAlreadyExists() throws Exception {
    Long slotId = 0l;
    IMachine machine = createMock(IMachine.class);
    INetworkAdapter iNetworkAdapter = createMock(INetworkAdapter.class);
    INATEngine natEngine = createMock(INATEngine.class);

    expect(machine.getNetworkAdapter(slotId)).andReturn(iNetworkAdapter);
    iNetworkAdapter.setAttachmentType(NAT);
    expect(iNetworkAdapter.getNATEngine()).andReturn(natEngine).anyTimes();

    List<String> redirects = Lists.newArrayList();
    expect(natEngine.getRedirects()).andReturn(redirects);

    natEngine.addRedirect("TCP@127.0.0.1:2222->:22", TCP, "127.0.0.1",
        2222, "", 22);
    expectLastCall()
        .andThrow(
            new VBoxException(null,
                "VirtualBox error: A NAT rule of this name already exists (0x80070057)"));
View Full Code Here

  @Test(enabled=false, expectedExceptions = VBoxException.class)
  public void testRethrowInvalidAdapterSlotException() throws Exception {
    Long slotId = 30l;
    IMachine machine = createMock(IMachine.class);
    INetworkAdapter iNetworkAdapter = createMock(INetworkAdapter.class);
    INATEngine natEngine = createMock(INATEngine.class);

    String error = "VirtualBox error: Argument slot is invalid "
        + "(must be slot < RT_ELEMENTS(mNetworkAdapters)) (0x80070057)";

    VBoxException invalidSlotException = new VBoxException(
View Full Code Here

      IMachine vm = createNiceMock(IMachine.class);
      VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      IGuestOSType iGuestOSType = createNiceMock(IGuestOSType.class);
      INetworkAdapter nat = createNiceMock(INetworkAdapter.class);
      INATEngine natEng = createNiceMock(INATEngine.class);

      expect(vm.getName()).andReturn(VIRTUALBOX_IMAGE_PREFIX + MASTER_NAME).anyTimes();
      expect(vm.getState()).andReturn(MachineState.PoweredOff).anyTimes();
      expect(vm.getNetworkAdapter(eq(0l))).andReturn(nat).once();
      expect(vm.getNetworkAdapter(eq(1l))).andReturn(null).once();
      expect(nat.getAttachmentType()).andReturn(NetworkAttachmentType.NAT).once();
      expect(nat.getNATEngine()).andReturn(natEng).anyTimes();
      expect(natEng.getHostIP()).andReturn("127.0.0.1").once();
      expect(natEng.getRedirects()).andReturn(ImmutableList.of("0,1,127.0.0.1,2222,,22"));
     
      expect(vbm.getVBox()).andReturn(vBox).anyTimes();
      expect(vm.getOSTypeId()).andReturn("RedHat_64").anyTimes();
      expect(vBox.getGuestOSType(vm.getOSTypeId())).andReturn(iGuestOSType);
     
View Full Code Here

               VIRTUALBOX_NODE_PREFIX + MASTER_NAME + VIRTUALBOX_NODE_NAME_SEPARATOR + group
                        + VIRTUALBOX_NODE_NAME_SEPARATOR + name).anyTimes();
      expect(vm.getState()).andReturn(MachineState.PoweredOff).anyTimes();

      INetworkAdapter nat = createNiceMock(INetworkAdapter.class);
      INATEngine natEng = createNiceMock(INATEngine.class);
     
      INetworkAdapter hostOnly = createNiceMock(INetworkAdapter.class);



      expect(vm.getNetworkAdapter(eq(0l))).andReturn(nat).once();
      expect(vm.getNetworkAdapter(eq(1l))).andReturn(hostOnly).once();
      expect(nat.getAttachmentType()).andReturn(NetworkAttachmentType.NAT).once();
      expect(nat.getNATEngine()).andReturn(natEng).anyTimes();
      expect(natEng.getHostIP()).andReturn("127.0.0.1").once();
      expect(natEng.getRedirects()).andReturn(ImmutableList.of("0,1,127.0.0.1,3000,,22"));
      NetworkUtils networkUtils = createNiceMock(NetworkUtils.class);

      replay(vm, nat, natEng, hostOnly, networkUtils);

      NodeMetadata node = new IMachineToNodeMetadata(Suppliers
View Full Code Here

  @Test
  public void testApplyNetworkingToNonExistingAdapter() throws Exception {
    Long slotId = 0l;
    IMachine machine = createMock(IMachine.class);
    INetworkAdapter iNetworkAdapter = createMock(INetworkAdapter.class);
    INATEngine natEngine = createMock(INATEngine.class);

    expect(machine.getNetworkAdapter(slotId)).andReturn(iNetworkAdapter);
    iNetworkAdapter.setAttachmentType(NAT);
    expect(iNetworkAdapter.getNATEngine()).andReturn(natEngine).anyTimes();

    List<String> redirects = Lists.newArrayList();
    expect(natEngine.getRedirects()).andReturn(redirects);
    natEngine.addRedirect("TCP@127.0.0.1:2222->:22", TCP, "127.0.0.1",
        2222, "", 22);
    iNetworkAdapter.setEnabled(true);
    machine.saveSettings();

    replay(machine, iNetworkAdapter, natEngine);
View Full Code Here

  @Test
  public void testApplySkipsWhenAlreadyExists() throws Exception {
    Long slotId = 0l;
    IMachine machine = createMock(IMachine.class);
    INetworkAdapter iNetworkAdapter = createMock(INetworkAdapter.class);
    INATEngine natEngine = createMock(INATEngine.class);

    expect(machine.getNetworkAdapter(slotId)).andReturn(iNetworkAdapter);
    iNetworkAdapter.setAttachmentType(NAT);
    expect(iNetworkAdapter.getNATEngine()).andReturn(natEngine).anyTimes();

    List<String> redirects = Lists.newArrayList();
    expect(natEngine.getRedirects()).andReturn(redirects);

    natEngine.addRedirect("TCP@127.0.0.1:2222->:22", TCP, "127.0.0.1",
        2222, "", 22);
    expectLastCall()
        .andThrow(
            new VBoxException(null,
                "VirtualBox error: A NAT rule of this name already exists (0x80070057)"));
View Full Code Here

  @Test(enabled = false, expectedExceptions = VBoxException.class)
  public void testRethrowInvalidAdapterSlotException() throws Exception {
    Long slotId = 30l;
    IMachine machine = createMock(IMachine.class);
    INetworkAdapter iNetworkAdapter = createMock(INetworkAdapter.class);
    INATEngine natEngine = createMock(INATEngine.class);

    String error = "VirtualBox error: Argument slot is invalid "
        + "(must be slot < RT_ELEMENTS(mNetworkAdapters)) (0x80070057)";

    VBoxException invalidSlotException = new VBoxException(
View Full Code Here

TOP

Related Classes of org.virtualbox_4_2.INATEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.