コード例 #1
0
 /**
  * The following method will find all images and storages where they located for provide template
  * and will fill an diskInfoDestinationMap by imageId mapping on active storage id where image is
  * located. The second map is mapping of founded storage ids to storage object
  */
 public static void fillImagesMapBasedOnTemplate(
     VmTemplate template,
     Map<Guid, DiskImage> diskInfoDestinationMap,
     Map<Guid, StorageDomain> destStorages) {
   List<StorageDomain> domains =
       DbFacade.getInstance()
           .getStorageDomainDao()
           .getAllForStoragePool(template.getStoragePoolId());
   fillImagesMapBasedOnTemplate(template, domains, diskInfoDestinationMap, destStorages);
 }
コード例 #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;
 }