use of org.ovirt.engine.core.common.vdscommands.GetImagesListVDSCommandParameters in project ovirt-engine by oVirt.
the class DiskImagesValidator method diskImagesOnStorage.
/**
* checks that the given disks do not exist on the target storage domains
* @param imageToDestinationDomainMap map containing the destination domain for each of the disks
* @param storagePoolId the storage pool ID to check whether the disks are residing on
* @return validation result indicating whether the disks don't exist on the target storage domains
*/
public ValidationResult diskImagesOnStorage(Map<Guid, Guid> imageToDestinationDomainMap, Guid storagePoolId) {
Map<Guid, List<Guid>> domainImages = new HashMap<>();
for (DiskImage diskImage : diskImages) {
Guid targetStorageDomainId = imageToDestinationDomainMap.get(diskImage.getId());
List<Guid> imagesOnStorageDomain = domainImages.get(targetStorageDomainId);
if (imagesOnStorageDomain == null) {
VDSReturnValue returnValue = Backend.getInstance().getResourceManager().runVdsCommand(VDSCommandType.GetImagesList, new GetImagesListVDSCommandParameters(targetStorageDomainId, storagePoolId));
if (returnValue.getSucceeded()) {
imagesOnStorageDomain = (List<Guid>) returnValue.getReturnValue();
domainImages.put(targetStorageDomainId, imagesOnStorageDomain);
} else {
return new ValidationResult(EngineMessage.ERROR_GET_IMAGE_LIST, String.format("$sdName %1$s", getStorageDomainStaticDao().get(targetStorageDomainId).getName()));
}
}
if (imagesOnStorageDomain.contains(diskImage.getId())) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_ALREADY_CONTAINS_DISK);
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.vdscommands.GetImagesListVDSCommandParameters in project ovirt-engine by oVirt.
the class GetUnregisteredDisksQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
StorageDomain storageDomain = storageDomainDao.get(getStorageDomainId());
if (storageDomain == null) {
getQueryReturnValue().setExceptionString(EngineMessage.STORAGE_DOMAIN_DOES_NOT_EXIST.toString());
getQueryReturnValue().setSucceeded(false);
return;
}
if (storageDomain.getStorageType().isCinderDomain()) {
QueryReturnValue returnValue = runInternalQuery(QueryType.GetUnregisteredCinderDisksByStorageDomainId, new IdQueryParameters(getStorageDomainId()));
setReturnValue(returnValue.getReturnValue());
return;
}
// first, run getImagesList query into vdsm to get all of the images on the storage domain - then store in
// imagesList
VDSReturnValue imagesListResult = runVdsCommand(VDSCommandType.GetImagesList, new GetImagesListVDSCommandParameters(getStorageDomainId(), getStoragePoolId()));
@SuppressWarnings("unchecked") List<Guid> imagesList = (List<Guid>) imagesListResult.getReturnValue();
// fromDao is a list of all disk images on the domain from the Dao
List<DiskImage> fromDao = diskImageDao.getAllSnapshotsForStorageDomain(getStorageDomainId());
// if the ID in imagesList is recognized by oVirt, remove from list
for (DiskImage image : fromDao) {
imagesList.remove(image.getId());
}
List<Disk> unregisteredDisks = new ArrayList<>();
for (Guid unregisteredDiskId : imagesList) {
GetUnregisteredDiskQueryParameters unregQueryParams = new GetUnregisteredDiskQueryParameters(unregisteredDiskId, getStorageDomainId(), getStoragePoolId());
QueryReturnValue unregQueryReturn = runInternalQuery(QueryType.GetUnregisteredDisk, unregQueryParams);
if (unregQueryReturn.getSucceeded()) {
unregisteredDisks.add(unregQueryReturn.getReturnValue());
} else {
log.debug("Could not get populated disk: {}", unregQueryReturn.getExceptionString());
}
}
getQueryReturnValue().setReturnValue(unregisteredDisks);
}
Aggregations