Esempio n. 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;
  }
Esempio n. 2
0
 protected boolean validate(ValidationResult validationResult, List<String> message) {
   if (!validationResult.isValid()) {
     message.add(validationResult.getMessage().name());
     if (validationResult.getVariableReplacements() != null) {
       for (String variableReplacement : validationResult.getVariableReplacements()) {
         message.add(variableReplacement);
       }
     }
   }
   return validationResult.isValid();
 }
Esempio n. 3
0
  /** @return true if all VM network interfaces are valid */
  public ValidationResult validateNetworkInterfaces() {
    ValidationResult validationResult = validateInterfacesConfigured(vm);
    if (!validationResult.isValid()) {
      return validationResult;
    }

    validationResult =
        validateInterfacesAttachedToClusterNetworks(
            vm, getClusterNetworksNames(), getInterfaceNetworkNames());
    if (!validationResult.isValid()) {
      return validationResult;
    }

    validationResult =
        validateInterfacesAttachedToVmNetworks(getClusterNetworks(), getInterfaceNetworkNames());
    if (!validationResult.isValid()) {
      return validationResult;
    }

    return ValidationResult.VALID;
  }
Esempio n. 4
0
  protected ValidationResult validateStatelessVm(VM vm, Boolean stateless) {
    // if the VM is not stateless, there is nothing to check
    if (stateless != null ? !stateless : !vm.isStateless()) {
      return ValidationResult.VALID;
    }

    ValidationResult previewValidation = getSnapshotValidator().vmNotInPreview(vm.getId());
    if (!previewValidation.isValid()) {
      return previewValidation;
    }

    // if the VM itself is stateless or run once as stateless
    if (vm.isAutoStartup()) {
      return new ValidationResult(VdcBllMessages.VM_CANNOT_RUN_STATELESS_HA);
    }

    ValidationResult hasSpaceValidation = hasSpaceForSnapshots();
    if (!hasSpaceValidation.isValid()) {
      return hasSpaceValidation;
    }

    return ValidationResult.VALID;
  }