Пример #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);
 }
 @Override
 public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
   List<QuotaConsumptionParameter> list = new ArrayList<>();
   fetchImageTemplates();
   if (imageTemplates != null) {
     for (DiskImage disk : imageTemplates) {
       if (disk.getQuotaId() != null && !Guid.Empty.equals(disk.getQuotaId())) {
         for (Guid storageId : disk.getStorageIds()) {
           list.add(
               new QuotaStorageConsumptionParameter(
                   disk.getQuotaId(),
                   null,
                   QuotaStorageConsumptionParameter.QuotaAction.RELEASE,
                   storageId,
                   (double) disk.getSizeInGigabytes()));
         }
       }
     }
   }
   return list;
 }
  @Override
  public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() {
    List<QuotaConsumptionParameter> list = new ArrayList<>();
    for (DiskImage disk : diskInfoDestinationMap.values()) {
      list.add(
          new QuotaStorageConsumptionParameter(
              disk.getQuotaId(),
              null,
              QuotaConsumptionParameter.QuotaAction.CONSUME,
              disk.getStorageIds().get(0),
              (double)
                  (disk.getSizeInGigabytes()
                      * getParameters().getVmsCount()
                      * getBlockSparseInitSizeInGB())));
    }

    return list;
  }