private boolean isRemoveCommandAvailable(ArrayList<DiskImage> disks) { for (DiskImage disk : disks) { boolean isImageLocked = disk.getImageStatus() == ImageStatus.LOCKED; if (isImageLocked) { return false; } } return true; }
@Override public void doPolling(Guid cmdId, List<Guid> childCmdIds) { super.doPolling(cmdId, childCmdIds); ImageStatus imageStatus = getCinderBroker().getDiskStatus(getDiskId()); DiskImage disk = getDisk(); if (imageStatus != null && imageStatus != disk.getImageStatus()) { switch (imageStatus) { case OK: getCommand().setCommandStatus(CommandStatus.SUCCEEDED); break; case ILLEGAL: getCommand().setCommandStatus(CommandStatus.FAILED); break; } } }
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; }