Пример #1
0
 @Override
 public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
   if (getParameters().isRemoveDisks()) {
     List<QuotaConsumptionParameter> list = new ArrayList<>();
     ImagesHandler.fillImagesBySnapshots(getVm());
     for (DiskImage disk : getVm().getDiskList()) {
       for (DiskImage snapshot : disk.getSnapshots()) {
         if (snapshot.getQuotaId() != null && !Guid.Empty.equals(snapshot.getQuotaId())) {
           if (snapshot.getActive()) {
             list.add(
                 new QuotaStorageConsumptionParameter(
                     snapshot.getQuotaId(),
                     null,
                     QuotaStorageConsumptionParameter.QuotaAction.RELEASE,
                     disk.getStorageIds().get(0),
                     (double) snapshot.getSizeInGigabytes()));
           } else {
             list.add(
                 new QuotaStorageConsumptionParameter(
                     snapshot.getQuotaId(),
                     null,
                     QuotaStorageConsumptionParameter.QuotaAction.RELEASE,
                     disk.getStorageIds().get(0),
                     snapshot.getActualSize()));
           }
         }
       }
     }
     return list;
   }
   return Collections.emptyList();
 }
 /**
  * Adds a disk image (Adds image, disk, and relevant entities , but not VmDevice) This may be
  * useful for Clone VMs, where besides adding images it is required to copy all vm devices
  * (VmDeviceUtils.copyVmDevices) from the source VM.
  */
 public static void addDiskImageWithNoVmDevice(DiskImage image) {
   addDiskImageWithNoVmDevice(
       image,
       image.getActive(),
       new ImageStorageDomainMap(
           image.getImageId(),
           image.getStorageIds().get(0),
           image.getQuotaId(),
           image.getDiskProfileId()));
 }
 /**
  * Adds a disk image (Adds image with active flag according to the value in image, using the first
  * storage domain in the storage id as entry to the storage domain map)
  *
  * @param image DiskImage to add
  */
 public static void addDiskImage(DiskImage image, Guid vmId) {
   addDiskImage(
       image,
       image.getActive(),
       new ImageStorageDomainMap(
           image.getImageId(),
           image.getStorageIds().get(0),
           image.getQuotaId(),
           image.getDiskProfileId()),
       vmId);
 }