コード例 #1
0
 @Override
 protected MapSqlParameterSource createFullParametersMapper(VmTemplate template) {
   return createBaseParametersMapper(template)
       .addValue("child_count", template.getChildCount())
       .addValue("name", template.getName())
       .addValue("status", template.getStatus())
       .addValue("is_disabled", template.isDisabled())
       .addValue("template_type", template.getTemplateType().name())
       .addValue("base_template_id", template.getBaseTemplateId())
       .addValue("template_version_name", template.getTemplateVersionName());
 }
コード例 #2
0
 public static boolean isVmTemplateImagesReady(
     VmTemplate vmTemplate,
     Guid storageDomainId,
     List<String> reasons,
     boolean checkImagesExists,
     boolean checkLocked,
     boolean checkIllegal,
     boolean checkStorageDomain,
     List<DiskImage> providedVmtImages) {
   boolean returnValue = true;
   List<DiskImage> vmtImages = providedVmtImages;
   if (checkStorageDomain) {
     StorageDomainValidator storageDomainValidator =
         new StorageDomainValidator(
             DbFacade.getInstance()
                 .getStorageDomainDao()
                 .getForStoragePool(storageDomainId, vmTemplate.getStoragePoolId()));
     ValidationResult res = storageDomainValidator.isDomainExistAndActive();
     returnValue = res.isValid();
     if (!returnValue) {
       reasons.add(res.getMessage().toString());
       reasons.addAll(res.getVariableReplacements());
     }
   }
   if (returnValue && checkImagesExists) {
     if (vmtImages == null) {
       vmtImages =
           ImagesHandler.filterImageDisks(
               DbFacade.getInstance().getDiskDao().getAllForVm(vmTemplate.getId()),
               false,
               false,
               true);
     }
     if (vmtImages.size() > 0
         && !ImagesHandler.isImagesExists(vmtImages, vmtImages.get(0).getStoragePoolId())) {
       reasons.add(EngineMessage.TEMPLATE_IMAGE_NOT_EXIST.toString());
       returnValue = false;
     }
   }
   if (returnValue && checkLocked) {
     if (vmTemplate.getStatus() == VmTemplateStatus.Locked) {
       returnValue = false;
     } else {
       if (vmtImages != null) {
         for (DiskImage image : vmtImages) {
           if (image.getImageStatus() == ImageStatus.LOCKED) {
             returnValue = false;
             break;
           }
         }
       }
     }
     if (!returnValue) {
       reasons.add(EngineMessage.VM_TEMPLATE_IMAGE_IS_LOCKED.toString());
     }
   }
   if (returnValue && checkIllegal && (vmTemplate.getStatus() == VmTemplateStatus.Illegal)) {
     returnValue = false;
     reasons.add(EngineMessage.VM_TEMPLATE_IMAGE_IS_ILLEGAL.toString());
   }
   return returnValue;
 }