Package org.virtualbox_4_2

Examples of org.virtualbox_4_2.IAppliance


    config.store(baos, "This file has been generated by i-OSGi");
    oc.put(baos.toByteArray(), new File(deployDir, f.getPath()));
  }

  private IMachine importAppliance(IVirtualBox vbox, ISession s) {
    IAppliance app = vbox.createAppliance();
    IProgress p = app.read(appliance.getAbsolutePath());
    p.waitForCompletion(-1);
    app.interpret();
    Set<String> oids = this.getMachineIds(vbox);
    p = app.importMachines();
    p.waitForCompletion(-1);
    IMachine machine = null;
    for (IMachine m : vbox.getMachines()) {
      if (!oids.contains(m.getId())) {
        machine = m;
View Full Code Here


   * @param importFile
   *            file of the appliance to import
   * @return imported {@link IAppliance}
   */
  public IAppliance importAppliance(final Path importFile) {
    IAppliance appliance = vBox.createAppliance();

    IProgress readProgress = appliance.read(importFile.toAbsolutePath().toString());
    while (!readProgress.getCompleted()) {
      readProgress.waitForCompletion(1000);
    }

    appliance.interpret();

        logWarnings(appliance);

    // keep NAT MAC addresses
    List<ImportOptions> options = new LinkedList<>();
    options.add(ImportOptions.KeepNATMACs);
    IProgress importProgress = appliance.importMachines(options);
    while (!importProgress.getCompleted()) {
      importProgress.waitForCompletion(1000);
    }

        logWarnings(appliance);
View Full Code Here

      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();
      expect(machine.getState()).andReturn(MachineState.PoweredOff).anyTimes();

      expect(manager.openMachineSession(machine)).andReturn(session);

      expect(session.getConsole()).andReturn(console);
      expect(console.takeSnapshot(snapshotName, snapshotDesc)).andReturn(
            progress);
      expect(progress.getCompleted()).andReturn(true);

      session.unlockMachine();
      replay(manager, machine, vBox, session, console, progress);
View Full Code Here

      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);
      expect(machine.getCurrentSnapshot()).andReturn(null).anyTimes();
      expect(manager.openMachineSession(machine)).andReturn(session);
      expect(machine.getState()).andReturn(MachineState.PoweredOff).anyTimes();

      expect(machine.getName()).andReturn("machine").anyTimes();
      expect(session.getConsole()).andReturn(console);
      expect(console.takeSnapshot(snapshotName, snapshotDesc)).andReturn(
            progress);

      session.unlockMachine();
      replay(manager, machine, vBox, session, console, progress);
View Full Code Here

      if (nodeState == null)
         nodeState = Status.UNRECOGNIZED;
      nodeMetadataBuilder.status(nodeState);
      nodeMetadataBuilder = getIpAddresses(vm, nodeMetadataBuilder);
     
      IGuestOSType guestOSType = virtualboxManager.get().getVBox().getGuestOSType(vm.getOSTypeId());
      OsFamily family = parseOsFamilyOrUnrecognized(guestOSType.getDescription());
      String version = parseVersionOrReturnEmptyString(family, guestOSType.getDescription(), osVersionMap);
      OperatingSystem os = OperatingSystem.builder().description(guestOSType.getDescription()).family(family)
               .version(version).is64Bit(guestOSType.getIs64Bit()).build();
      nodeMetadataBuilder.operatingSystem(os);

      String guestOsUser = vm.getExtraData(GUEST_OS_USER);
      String guestOsPassword = vm.getExtraData(GUEST_OS_PASSWORD);
      nodeMetadataBuilder.credentials(LoginCredentials.builder()
View Full Code Here

   public void testDoNothingIfAlreadyTakenSnapshot() throws Exception {
      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);
      expect(machine.getCurrentSnapshot()).andReturn(null).anyTimes();
      expect(manager.openMachineSession(machine)).andReturn(session);
      expect(machine.getState()).andReturn(MachineState.PoweredOff).anyTimes();

      expect(machine.getName()).andReturn("machine").anyTimes();
      expect(session.getConsole()).andReturn(console);
      expect(console.takeSnapshot(snapshotName, snapshotDesc)).andReturn(
            progress);

      session.unlockMachine();
View Full Code Here

@Test(groups = "unit", testName = "AddIDEControllerIfNotExistsTest")
public class AddIDEControllerIfNotExistsTest {

   @Test
   public void testFine() throws Exception {
      IMachine vm = createMock(IMachine.class);

      String controllerName = "IDE Controller";
      StorageController storageController = StorageController.builder().bus(StorageBus.IDE).name(controllerName).build();

      expect(vm.addStorageController(controllerName, StorageBus.IDE)).andReturn(
              createNiceMock(IStorageController.class));
      vm.saveSettings();

      replay(vm);

      new AddIDEControllerIfNotExists(storageController).apply(vm);
View Full Code Here

      verify(vm);
   }

   @Test
   public void testAcceptableException() throws Exception {
      IMachine vm = createMock(IMachine.class);

      String controllerName = "IDE Controller";
      StorageController storageController = StorageController.builder().bus(StorageBus.IDE).name(controllerName).build();

      expect(vm.addStorageController(controllerName, StorageBus.IDE)).andThrow(
              new VBoxException(createNiceMock(Throwable.class),
                      "VirtualBox error: Storage controller named 'IDE Controller' already exists (0x80BB000C)"));

      replay(vm);
View Full Code Here

      verify(vm);
   }

   @Test(expectedExceptions = VBoxException.class)
   public void testUnacceptableException() throws Exception {
      IMachine vm = createMock(IMachine.class);

      String controllerName = "IDE Controller";
      StorageController storageController = StorageController.builder().bus(StorageBus.IDE).name(controllerName).build();

      expect(vm.addStorageController(controllerName, StorageBus.IDE)).andThrow(
              new VBoxException(createNiceMock(Throwable.class), "VirtualBox error: General Error"));

      replay(vm);

      new AddIDEControllerIfNotExists(storageController).apply(vm);
View Full Code Here

                              .build();
   }
  
   @Test
   public void testCloneMachineFromAnotherMachine() {
      IMachine source = getVmWithGuestAdditionsInstalled();
      CloneSpec cloneSpec = CloneSpec.builder().vm(machineSpec.getVmSpec()).network(machineSpec.getNetworkSpec())
               .master(source).linked(true).build();
      IMachine clone = checkNotNull(
              new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(manager, workingDir, machineUtils)
                                .apply(cloneSpec), "clone");
      assertEquals(clone.getName(), cloneSpec.getVmSpec().getVmName());

   }
View Full Code Here

TOP

Related Classes of org.virtualbox_4_2.IAppliance

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.