Examples of IVirtualBox


Examples of org.virtualbox_4_0.IVirtualBox

    cleanup();
    URI nid = URI.create("/" + nextId.getAndIncrement() + "/0");
    VirtualBoxManager vboxMgr = null;
    try {
      vboxMgr = this.connect();
      IVirtualBox vbox = vboxMgr.getVBox();
      ISession s = vboxMgr.getSessionObject();
      IMachine machine = this.importAppliance(vbox, s);
      /* TODO Headless */
      IProgress p = machine.launchVMProcess(s, "gui", "");
      p.waitForCompletion(-1);
View Full Code Here

Examples of org.virtualbox_4_0.IVirtualBox

  }

  private synchronized void cleanup() {
    VirtualBoxManager vboxMgr = this.connect();
    try {
      IVirtualBox vbox = vboxMgr.getVBox();
      for (IMachine m : vbox.getMachines()) {
        if (m.getState() != MachineState.PoweredOff
            || !m.getName().startsWith("iosgi-")) {
          continue;
        }
        LOGGER.debug("cleaning up {}", m.getName());
View Full Code Here

Examples of org.virtualbox_4_0.IVirtualBox

      if (e.getValue().getAddress()
          .equals(Networking.getPrimaryAddress())) {
        mac = e.getKey();
      }
    }
    IVirtualBox vbox = vboxMgr.getVBox();
    for (final IMachine m : vbox.getMachines()) {
      MacAddress mmac = new MacAddress(m.getNetworkAdapter(0L)
          .getMACAddress());
      if (mmac.equals(mac)) {
        EXEC_SVC.submit(new Callable<Void>() {
          @Override
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      String snapshotName = "snap";
      String snapshotDesc = "snapDesc";

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      ISession session = createMock(ISession.class);
      IConsole console = createNiceMock(IConsole.class);
      IProgress progress = createNiceMock(IProgress.class);
      ISnapshot snapshot = createNiceMock(ISnapshot.class);
      expect(machine.getCurrentSnapshot()).andReturn(snapshot).anyTimes();
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      String snapshotName = "snap";
      String snapshotDesc = "snapDesc";

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      ISession session = createMock(ISession.class);
      IConsole console = createNiceMock(IConsole.class);

      IProgress progress = createNiceMock(IProgress.class);
      expect(progress.getCompleted()).andReturn(true);
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      MachineUtils machineUtils = createMock(MachineUtils.class);

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

      StringBuilder errorBuilder = new StringBuilder();
      errorBuilder.append("org.virtualbox_4_2.VBoxException: VirtualBox error: ");
      errorBuilder.append("Could not find file for the medium ");
      errorBuilder.append("'/Users/johndoe/jclouds-virtualbox-test/testadmin.vdi' (0x80BB0001)");
      String errorMessage = errorBuilder.toString();
      expect(manager.getVBox()).andReturn(vBox).anyTimes();

      VBoxException notFoundException = new VBoxException(createNiceMock(Throwable.class), errorMessage);
      expect(vBox.openMedium(adminDiskPath, DeviceType.HardDisk, AccessMode.ReadWrite, false)).andThrow(notFoundException);
      expect(vBox.createHardDisk(diskFormat, adminDiskPath)).andReturn(medium);
      expect(medium.createBaseStorage(anyLong(), anyLong())).andReturn(progress);
      //expect(machineUtils.writeLockMachineAndApply(anyString(), new DetachDistroMediumFromMachine(anyString(), anyInt() , anyInt()))).andReturn().anyTimes();

      replay(manager, machine, vBox, medium, machineUtils);
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      MachineUtils machineUtils = createMock(MachineUtils.class);

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);
      IMedium newHardDisk = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

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

      expect(medium.deleteStorage()).andReturn(progress);
      expect(vBox.createHardDisk(diskFormat, adminDiskPath)).andReturn(newHardDisk);
      expect(newHardDisk.createBaseStorage(anyLong(), anyLong())).andReturn(progress);

      //expect(machineUtils.writeLockMachineAndApply(anyString(), new DetachDistroMediumFromMachine(anyString(), anyInt() , anyInt()))).andReturn(v).anyTimes();

      replay(manager, machine, vBox, medium, newHardDisk, progress, machineUtils);
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      MachineUtils machineUtils = createMock(MachineUtils.class);

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);

      IMedium newHardDisk = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

      expect(manager.getVBox()).andReturn(vBox).anyTimes();
      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);
      oldMachine.detachDevice(oldAttachmentController, oldAttachmentPort, oldAttachmentDevice);
      oldMachine.saveSettings();

      expect(medium.deleteStorage()).andReturn(progress);
      expect(vBox.createHardDisk(diskFormat, adminDiskPath)).andReturn(newHardDisk);
      expect(newHardDisk.createBaseStorage(anyLong(), anyLong())).andReturn(progress);

      replay(manager, oldMachine, oldAttachment, oldMedium, detachSession, machine, vBox, medium, newHardDisk, progress, machineUtils);

      IMedium newDisk = new CreateMediumIfNotAlreadyExists(Suppliers.ofInstance(manager), machineUtils, true).apply(hardDisk);
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      MachineUtils machineUtils = createMock(MachineUtils.class);

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);
      IMedium newHardDisk = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

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

      replay(manager, machine, vBox, medium, newHardDisk, progress, machineUtils);

      new CreateMediumIfNotAlreadyExists(Suppliers.ofInstance(manager), machineUtils, false).apply(hardDisk);
   }
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      MachineUtils machineUtils = createMock(MachineUtils.class);

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

      String errorMessage = "VirtualBox error: Some other VBox error";

      expect(manager.getVBox()).andReturn(vBox).anyTimes();

      VBoxException notFoundException = new VBoxException(createNiceMock(Throwable.class), errorMessage);
      expect(vBox.openMedium(adminDiskPath, DeviceType.HardDisk, AccessMode.ReadWrite, false)).andThrow(notFoundException);
      expect(vBox.createHardDisk(diskFormat, adminDiskPath)).andReturn(medium);
      expect(medium.createBaseStorage(anyLong(), anyLong())).andReturn(progress);

      replay(manager, machine, vBox, medium, machineUtils);

      new CreateMediumIfNotAlreadyExists(Suppliers.ofInstance(manager), machineUtils, true).apply(hardDisk);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.