Examples of IMachine


Examples of org.virtualbox_4_2.IMachine

public class ApplyMemoryToMachineTest {

   @Test
   public void testSetRAMSizeSuccessful() throws Exception {
      long memorySize = 1024l;
      IMachine machine = createMock(IMachine.class);

      machine.setMemorySize(memorySize);
      machine.saveSettings();

      replay(machine);

      new ApplyMemoryToMachine(memorySize).apply(machine);
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

      // Mainly here for documentation purposes
      final String error = "VirtualBox error: Invalid RAM size: "
            + "3567587327 MB (must be in range [4, 2097152] MB) (0x80070057)";

      long memorySize = 1024l;
      IMachine machine = createMock(IMachine.class);

      VBoxException invalidRamSizeException = new VBoxException(createNiceMock(Throwable.class), error);
      machine.setMemorySize(memorySize);
      expectLastCall().andThrow(invalidRamSizeException);
      machine.saveSettings();

      replay(machine);

      new ApplyMemoryToMachine(memorySize).apply(machine);
   }
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

      VmSpec vmSpec = VmSpec.builder().id(vmName).name(vmName).osTypeId("").memoryMB(1024).controller(ideController)
            .cleanUpMode(CleanupMode.Full).build();
      MasterSpec machineSpec = MasterSpec.builder()
            .iso(IsoSpec.builder().sourcePath("some.iso").installationScript("").build()).vm(vmSpec)
            .network(NetworkSpec.builder().build()).build();
      IMachine createdMachine = createMock(IMachine.class);
      ISession session = createMock(ISession.class);

      expect(manager.getVBox()).andReturn(vBox).anyTimes();
      String flags = "";
      List<String> groups = Lists.newArrayList();
      String group = "";
      expect(vBox.composeMachineFilename(vmName, group, flags, "/tmp/workingDir")).andReturn("settingsFile");

      StringBuilder errorMessageBuilder = new StringBuilder();
      errorMessageBuilder.append("VirtualBox error: Could not find a registered machine with UUID {");
      errorMessageBuilder.append("'jclouds-image-virtualbox-iso-to-machine-test'} (0x80BB0001)");
      String errorMessage = errorMessageBuilder.toString();
      VBoxException vBoxException = new VBoxException(createNiceMock(Throwable.class), errorMessage);

      expect(vBox.findMachine(vmName)).andThrow(vBoxException);

      expect(vBox.createMachine(anyString(), eq(vmName), groups, anyString(), anyString())).andReturn(createdMachine)
            .anyTimes();
      vBox.registerMachine(createdMachine);

      expect(vBox.findMachine(vmName)).andReturn(createdMachine).anyTimes();
      expect(manager.getSessionObject()).andReturn(session);
      expect(session.getMachine()).andReturn(createdMachine);
      createdMachine.lockMachine(session, LockType.Write);
      createdMachine.setMemorySize(1024l);
      createdMachine.saveSettings();
      session.unlockMachine();

      // TODO: this mock test is not finished.
      replay(manager, createdMachine, vBox, session);
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      String vmName = "jclouds-image-my-ubuntu-image";

      IMachine registeredMachine = createMock(IMachine.class);

      expect(manager.getVBox()).andReturn(vBox).anyTimes();
      expect(vBox.findMachine(vmName)).andReturn(registeredMachine).anyTimes();

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

Examples of org.virtualbox_4_2.IMachine

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

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

      expect(session.getConsole()).andReturn(console);
      expect(console.takeSnapshot(snapshotName, snapshotDesc)).andReturn(
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

  private String hostInterface;

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

    expect(machine.getNetworkAdapter(adapterId)).andReturn(iNetworkAdapter);
    iNetworkAdapter.setAttachmentType(Bridged);
    iNetworkAdapter.setMACAddress(macAddress);
    iNetworkAdapter.setBridgedInterface(hostInterface);
    iNetworkAdapter.setEnabled(true);
    machine.saveSettings();

    replay(machine, iNetworkAdapter);
    NetworkAdapter networkAdapter = NetworkAdapter.builder()
        .networkAttachmentType(NetworkAttachmentType.Bridged).build();
    NetworkInterfaceCard networkInterfaceCard = NetworkInterfaceCard
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

      VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
      IStorageController iStorageController = createNiceMock(IStorageController.class);
      IMediumAttachment iMediumAttachment = createNiceMock(IMediumAttachment.class);
      IMedium hd = createNiceMock(IMedium.class);
      IMedium dvd = createNiceMock(IMedium.class);
      IMachine vm = createNiceMock(IMachine.class);

      expect(vm.getStorageControllers()).andReturn(Lists.newArrayList(iStorageController)).anyTimes();
      expect(iStorageController.getName()).andReturn(CONTROLLER_NAME).anyTimes();
      expect(iStorageController.getBus()).andReturn(CONTROLLER_BUS).anyTimes();
      expect(vm.getMediumAttachmentsOfController(CONTROLLER_NAME)).andReturn(Lists.newArrayList(iMediumAttachment)).anyTimes();
      expect(iMediumAttachment.getPort()).andReturn(0).once();
      expect(iMediumAttachment.getDevice()).andReturn(0).once();

      expect(iMediumAttachment.getMedium()).andReturn(hd);
      expect(hd.getDeviceType()).andReturn(DeviceType.HardDisk).once();
      expect(hd.getLocation()).andReturn(PATH_TO_HD).once();

      expect(iMediumAttachment.getMedium()).andReturn(dvd);
      expect(dvd.getDeviceType()).andReturn(DeviceType.DVD).once();
      expect(dvd.getLocation()).andReturn(PATH_TO_DVD).once();

      expect(vm.getName()).andReturn(VM_NAME).anyTimes();
      expect(vm.getId()).andReturn(VM_ID).anyTimes();
      expect(vm.getOSTypeId()).andReturn(OS_TYPE_ID).anyTimes();
      expect(vm.getMemorySize()).andReturn(MEMORY_SIZE).anyTimes();

      replay(vbm, iStorageController, iMediumAttachment, hd, dvd, vm);

      VmSpec vmSpec = new IMachineToVmSpec().apply(vm);
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

   @Override
   public synchronized NodeAndInitialCredentials<IMachine> apply(NodeSpec nodeSpec) {
      checkNotNull(nodeSpec, "NodeSpec");
      Master master = checkNotNull(nodeSpec.getMaster(), "Master");
      IMachine masterMachine = master.getMachine();
      String guestOsUser = masterMachine.getExtraData(GUEST_OS_USER);
      String guestOsPassword = masterMachine.getExtraData(GUEST_OS_PASSWORD);

      cleanUpMaster(master);
      CloneSpec cloneSpec = configureCloneSpec(nodeSpec, guestOsUser, guestOsPassword);
      IMachine clone = cloner.apply(cloneSpec);
      String cloneName =  cloneSpec.getVmSpec().getVmName();
      logger.debug("<< cloned a vm(%s) from master(%s)", cloneName, nodeSpec.getMaster().getMachine().getName());
      machineController.ensureMachineIsLaunched(cloneName);
      logger.debug("<< cloned vm(%s) is up and running", cloneName);
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

   @Test
   public void testDetachDistroMedium() throws Exception {

      String controller = "IDE Controller";
      IMachine machine = createMock(IMachine.class);

      int controllerPort = 0;
      int device = 1;

      machine.saveSettings();
      machine.detachDevice(controller, controllerPort, device);

      replay(machine);

      new DetachDistroMediumFromMachine(controller, controllerPort, device).apply(machine);
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

   @Test
   public void testAcceptAlreadyDetachedDistroMedium() throws Exception {

      String controller = "IDE Controller";

      IMachine machine = createNiceMock(IMachine.class);

      final StringBuilder errorBuilder = new StringBuilder();
      errorBuilder.append("VirtualBox error: ");
      errorBuilder.append("Medium '/Users/johndoe/jclouds-virtualbox-test/ubuntu-11.04-server-i386.iso' ");
      errorBuilder.append("is already detached from port 0, device 0 of controller 'IDE Controller' ");
      errorBuilder.append("of this virtual machine (0x80BB000C)");
      String isoAlreadyAttachedException = errorBuilder.toString();

      int controllerPort = 0;
      int device = 1;

      VBoxException isoAttachedException = new VBoxException(createNiceMock(Throwable.class), isoAlreadyAttachedException);
      machine.detachDevice(controller, controllerPort, device);
      expectLastCall().andThrow(isoAttachedException);

      replay(machine);

      new DetachDistroMediumFromMachine(controller, controllerPort, device).apply(machine);
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.