Examples of IMachine


Examples of org.virtualbox_4_2.IMachine

   @Override
   public ListenableFuture<Image> createImage(ImageTemplate template) {
      checkState(template instanceof CloneImageTemplate, " vbox image extension only supports cloning for the moment.");
      CloneImageTemplate cloneTemplate = CloneImageTemplate.class.cast(template);

      IMachine source = manager.get().getVBox().findMachine(cloneTemplate.getSourceNodeId());

      String flags = "";
      List<String> groups = ImmutableList.of();
      String group = "";
      String settingsFile = manager.get().getVBox().composeMachineFilename(template.getName(), group , flags , workingDir);
      IMachine clonedMachine = manager.get().getVBox()
               .createMachine(settingsFile, template.getName(), groups, source.getOSTypeId(), flags);

      List<CloneOptions> options = Lists.newArrayList();
      if (isLinkedClone)
         options.add(CloneOptions.Link);

      // TODO snapshot name
      ISnapshot currentSnapshot = new TakeSnapshotIfNotAlreadyAttached(manager, "pre-image-spawn", "before spawning "
               + template.getName(), logger).apply(source);

      checkNotNull(currentSnapshot);

      // clone
      IProgress progress = currentSnapshot.getMachine().cloneTo(clonedMachine, CloneMode.MachineState, options);
      progress.waitForCompletion(-1);

      logger.debug(String.format("<< master(%s) is cloned correctly to vm(%s)", source.getName(), clonedMachine.getName()));

      // registering
      manager.get().getVBox().registerMachine(clonedMachine);

      return Futures.immediateFuture(imachineToImage.apply(clonedMachine));
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

   }

   @Override
   public boolean deleteImage(String id) {
      try {
         IMachine machine = manager.get().getVBox().findMachine(VIRTUALBOX_IMAGE_PREFIX + id);
         machineUtils.applyForMachine(machine.getId(), new UnregisterMachineIfExistsAndDeleteItsMedia(
                  new IMachineToVmSpec().apply(machine)));
      } catch (Exception e) {
         logger.error(e, "Could not delete machine with id %s ", id);
         return false;
      }
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

         return masters.get(key.getId());
      }
      checkState(!key.getId().contains(VIRTUALBOX_NODE_NAME_SEPARATOR), "master image names cannot contain \""
            + VIRTUALBOX_NODE_NAME_SEPARATOR + "\"");
      String vmName = VIRTUALBOX_IMAGE_PREFIX + key.getId();
      IMachine masterMachine;
      Master master;
      // ready the preseed file server
      PreseedCfgServer server = new PreseedCfgServer();
      try {
         // try and find a master machine in vbox
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

      }
   }
  
   @Override
   public Image getImage(String vmName) {
      IMachine image = getNode(vmName);
      if (image == null)
         return null;
      return imachineToImage.apply(image);
   }
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

      return imachineToImage.apply(image);
   }

   @Override
   public synchronized void destroyNode(String vmName) {
      IMachine machine = manager.get().getVBox().findMachine(vmName);
      powerDownMachine(machine);
      try {
         new UnregisterMachineIfExistsAndForceDeleteItsMedia().apply(machine);
      } catch (Exception e) {
         logger.error("Machine (%s) not unregistered!", vmName);
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

      }
   }

   @Override
   public void rebootNode(String vmName) {
      IMachine machine = manager.get().getVBox().findMachine(vmName);
      powerDownMachine(machine);
      launchVMProcess(machine, manager.get().getSessionObject());
   }
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

      launchVMProcess(machine, manager.get().getSessionObject());
   }

   @Override
   public void resumeNode(String vmName) {
      IMachine machine = manager.get().getVBox().findMachine(vmName);
      ISession machineSession;
      try {
         machineSession = manager.get().openMachineSession(machine);
         machineSession.getConsole().resume();
         machineSession.unlockMachine();
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

      }
   }

   @Override
   public void suspendNode(String vmName) {
      IMachine machine = manager.get().getVBox().findMachine(vmName);
      ISession machineSession;
      try {
         machineSession = manager.get().openMachineSession(machine);
         machineSession.getConsole().pause();
         machineSession.unlockMachine();
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

   private void onAlreadyAttachedExceptionDetachOrPropagate(IVirtualBox vBox, final IMedium medium, VBoxException e) {
      Matcher matcher = ATTACHED_PATTERN.matcher(e.getMessage());
      if (matcher.find()) {
         String machineId = matcher.group(1);
         IMachine immutableMachine = vBox.findMachine(machineId);
         IMediumAttachment mediumAttachment = Iterables.find(immutableMachine.getMediumAttachments(),
                  new Predicate<IMediumAttachment>() {
                     public boolean apply(IMediumAttachment in) {
                        return in.getMedium().getId().equals(medium.getId());
                     }
                  });
         machineUtils.writeLockMachineAndApply(immutableMachine.getName(), new DetachDistroMediumFromMachine(
               mediumAttachment.getController(), mediumAttachment.getPort(), mediumAttachment.getDevice()));
         deleteMediumAndBlockUntilComplete(medium);
      } else {
         throw e;
      }
View Full Code Here

Examples of org.virtualbox_4_2.IMachine

         throw new RuntimeException("error reading default-keystroke-sequence file");
      }
   }

   protected void undoVm(String vmNameOrId) {
      IMachine vm = null;
      try {
         vm = manager.get().getVBox().findMachine(vmNameOrId);
         VmSpec vmSpec = new IMachineToVmSpec().apply(vm);
         int attempts = 0;
         while (attempts < 10 && !vm.getSessionState().equals(SessionState.Unlocked)) {
            attempts++;
            Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
         }
         machineUtils.applyForMachine(vmNameOrId, new UnregisterMachineIfExistsAndDeleteItsMedia(vmSpec));
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.