Source:
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()); for (String varReplacement : res.getVariableReplacements()) { reasons.add(varReplacement); } } } 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(VdcBllMessages.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(VdcBllMessages.VM_TEMPLATE_IMAGE_IS_LOCKED.toString()); } } if (returnValue && checkIllegal && (vmTemplate.getStatus() == VmTemplateStatus.Illegal)) { returnValue = false; reasons.add(VdcBllMessages.VM_TEMPLATE_IMAGE_IS_ILLEGAL.toString()); } return returnValue; }

Target:
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(VdcBllMessages.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(VdcBllMessages.VM_TEMPLATE_IMAGE_IS_LOCKED.toString()); } } if (returnValue && checkIllegal && (vmTemplate.getStatus() == VmTemplateStatus.Illegal)) { returnValue = false; reasons.add(VdcBllMessages.VM_TEMPLATE_IMAGE_IS_ILLEGAL.toString()); } return returnValue; }