Example #1
0
  /**
   * Check storage domains. Storage domain status and disk space are checked only for non-HA VMs.
   *
   * @param vm The VM to run
   * @param message The error messages to append to
   * @param isInternalExecution Command is internal?
   * @param vmImages The VM's image disks
   * @return <code>true</code> if the VM can be run, <code>false</code> if not
   */
  protected ValidationResult validateStorageDomains(
      VM vm, boolean isInternalExecution, List<DiskImage> vmImages) {
    if (vmImages.isEmpty()) {
      return ValidationResult.VALID;
    }

    if (!vm.isAutoStartup() || !isInternalExecution) {
      Set<Guid> storageDomainIds = ImagesHandler.getAllStorageIdsForImageIds(vmImages);
      MultipleStorageDomainsValidator storageDomainValidator =
          new MultipleStorageDomainsValidator(vm.getStoragePoolId(), storageDomainIds);

      ValidationResult result = storageDomainValidator.allDomainsExistAndActive();
      if (!result.isValid()) {
        return result;
      }

      result =
          !vm.isAutoStartup()
              ? storageDomainValidator.allDomainsWithinThresholds()
              : ValidationResult.VALID;
      if (!result.isValid()) {
        return result;
      }
    }

    return ValidationResult.VALID;
  }
Example #2
0
  /**
   * check that we can create snapshots for all disks return true if all storage domains have enough
   * space to create snapshots for this VM plugged disks
   */
  protected ValidationResult hasSpaceForSnapshots() {
    Set<Guid> sdIds = ImagesHandler.getAllStorageIdsForImageIds(getVmImageDisks());

    MultipleStorageDomainsValidator msdValidator = getStorageDomainsValidator(sdIds);
    ValidationResult retVal = msdValidator.allDomainsWithinThresholds();
    if (retVal == ValidationResult.VALID) {
      return msdValidator.allDomainsHaveSpaceForNewDisks(getVmImageDisks());
    }
    return retVal;
  }