Examples of IVirtualBox


Examples of org.virtualbox_4_2.IVirtualBox

   @Test(enabled = false)
   public void testCreateAndSetMemoryWhenNotAlreadyExists() throws Exception {

      MachineUtils machineUtils = createMock(MachineUtils.class);
      VirtualBoxManager manager = createMock(VirtualBoxManager.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      String vmName = "jclouds-image-my-ubuntu-image";
      StorageController ideController = StorageController.builder().name("IDE Controller").bus(StorageBus.IDE).build();
      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();
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

   public void testFailIfMachineIsAlreadyRegistered() throws Exception {

      MachineUtils machineUtils = createMock(MachineUtils.class);

      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);

      VmSpec launchSpecification = VmSpec.builder().id(vmName).name(vmName).osTypeId("").memoryMB(1024)
            .cleanUpMode(CleanupMode.Full).build();
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

   public void testFailIfOtherVBoxExceptionIsThrown() throws Exception {

      MachineUtils machineUtils = createMock(MachineUtils.class);

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

      String errorMessage = "VirtualBox error: Some other VBox error";
      VBoxException vBoxException = new VBoxException(createNiceMock(Throwable.class), errorMessage);

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

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

      replay(manager, vBox, machineUtils);

      VmSpec launchSpecification = VmSpec.builder().id(vmName).name(vmName).osTypeId("").cleanUpMode(CleanupMode.Full)
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

   @Test(enabled=false)
   public void testCreateFromNode() throws Exception {

      IMachine vm = createNiceMock(IMachine.class);
      VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
      IVirtualBox vBox = createNiceMock(IVirtualBox.class);
      expect(vbm.getVBox()).andReturn(vBox).anyTimes();
      String group = "my-cluster-group";
      String name = "a-name-with-a-code-338";

      expect(vm.getName()).andReturn(
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

   public static final Pattern ATTACHED_PATTERN = Pattern.compile(".*is still attached.*: ([-0-9a-f]+) .*");

   @Override
   public IMedium apply(HardDisk hardDisk) {
      IVirtualBox vBox = manager.get().getVBox();
      try {
         String diskPath = hardDisk.getDiskPath();
         final IMedium medium = vBox.openMedium(diskPath, DeviceType.HardDisk, AccessMode.ReadWrite, false);
         if (overwriteIfExists) {
            try {
               deleteMediumAndBlockUntilComplete(medium);
            } catch (VBoxException e) {
               onAlreadyAttachedExceptionDetachOrPropagate(vBox, medium, e);
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      int controllerPort = 0;
      int deviceSlot = 1;

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium hardDisk = createNiceMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

      expect(manager.getVBox()).andReturn(vBox).anyTimes();
      expect(vBox.createHardDisk(diskFormat, diskPath)).andReturn(hardDisk);
      expect(hardDisk.createBaseStorage(anyLong(), anyLong())).andReturn(progress);

      machine.attachDevice(controllerName, controllerPort, deviceSlot, DeviceType.HardDisk, hardDisk);
      machine.saveSettings();
      replay(manager, machine, vBox, hardDisk);
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      int controllerPort = 0;
      int deviceSlot = 1;

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium hardDisk = createNiceMock(IMedium.class);

      final StringBuilder errorBuilder = new StringBuilder();
      errorBuilder.append("VirtualBox error: ");
      errorBuilder.append("Medium '/Users/mattias/jclouds-virtualbox-test/testadmin.vdi' ");
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      int controllerPort = 0;
      int deviceSlot = 1;

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium hardDisk = createNiceMock(IMedium.class);

      final StringBuilder errorBuilder = new StringBuilder();
      errorBuilder.append("VirtualBox error: ");
      errorBuilder.append("Some other VBox error");
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

      this.workingDir = workingDir;
   }

   @Override
   public IMachine apply(MasterSpec masterSpec) {
      final IVirtualBox vBox = manager.get().getVBox();
      String vmName = masterSpec.getVmSpec().getVmName();
      String vmId = masterSpec.getVmSpec().getVmId();

      try {
         vBox.findMachine(vmId);
         throw new IllegalStateException("Machine " + vmName + " is already registered.");
      } catch (VBoxException e) {
         if (machineNotFoundException(e))
            return createMachine(vBox, masterSpec);
         else
View Full Code Here

Examples of org.virtualbox_4_2.IVirtualBox

   @Test(enabled=false)
   public void testCreateFromMaster() throws Exception {

      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);
     
      INetworkAdapter hostOnly = createNiceMock(INetworkAdapter.class);
      NetworkUtils networkUtils = createNiceMock(NetworkUtils.class);

      replay(vm, vBox, iGuestOSType, nat, natEng, hostOnly, networkUtils);
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.