Package org.virtualbox_4_0

Examples of org.virtualbox_4_0.IMedium


      for (IStorageController iStorageController : machine.getStorageControllers()) {

         Builder storageControllerBuilder = StorageController.builder();
         for (IMediumAttachment iMediumAttachment : machine.getMediumAttachmentsOfController(iStorageController
                  .getName())) {
            IMedium iMedium = iMediumAttachment.getMedium();
            if(iMedium != null) {
               if (iMedium.getDeviceType().equals(DeviceType.HardDisk)) {
                  storageControllerBuilder.attachHardDisk(HardDisk.builder().diskpath(iMedium.getLocation())
                           .autoDelete(true).controllerPort(iMediumAttachment.getPort())
                           .deviceSlot(iMediumAttachment.getDevice().intValue()).build());
               } else if (iMedium.getDeviceType().equals(DeviceType.DVD)) {
                  storageControllerBuilder.attachISO(iMediumAttachment.getPort(), iMediumAttachment.getDevice().intValue(),
                           iMedium.getLocation());
               }
            }
         }
         controllers.add(storageControllerBuilder.name(iStorageController.getName()).bus(iStorageController.getBus())
                  .build());
View Full Code Here


      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

      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' ");
      errorBuilder.append("is already attached to port 0, device 1 of controller 'IDE Controller' ");
View Full Code Here

      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");
      String isoAlreadyAttachedException = errorBuilder.toString();
View Full Code Here

   private void setupDvdsForController(VmSpec vmSpecification, String vmName, StorageController controller) {
      Set<IsoImage> dvds = controller.getIsoImages();
      for (IsoImage dvd : dvds) {
         String dvdSource = dvd.getSourcePath();
         final IMedium dvdMedium = manager.get().getVBox()
                  .openMedium(dvdSource, DeviceType.DVD, AccessMode.ReadOnly, vmSpecification.isForceOverwrite());
         ensureMachineDevicesAttached(vmName, dvdMedium, dvd.getDeviceDetails(), controller.getName());
      }
   }
View Full Code Here

            boolean deleted = new File(sourcePath).delete();
            if (!deleted) {
               logger.error(String.format("File %s could not be deleted.", sourcePath));
            }
         }
         IMedium medium = new CreateMediumIfNotAlreadyExists(manager, machineUtils, true).apply(hardDisk);
         ensureMachineDevicesAttached(vmName, medium, hardDisk.getDeviceDetails(), controller.getName());
      }
   }
View Full Code Here

      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

      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' ");
      errorBuilder.append("is already attached to port 0, device 1 of controller 'IDE Controller' ");
View Full Code Here

      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");
      String isoAlreadyAttachedException = errorBuilder.toString();
View Full Code Here

   public void testConvert() throws Exception {

      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();
View Full Code Here

TOP

Related Classes of org.virtualbox_4_0.IMedium

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.