use of org.ovirt.engine.core.common.vdscommands.GetImageInfoVDSCommandParameters in project ovirt-engine by oVirt.
the class GetUnregisteredDiskQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Guid storagePoolId = getParameters().getStoragePoolId();
Guid storageDomainId = getParameters().getStorageDomainId();
Guid diskId = getParameters().getDiskId();
StorageDomain storageDomain = storageDomainDao.get(storageDomainId);
if (storageDomain == null) {
getQueryReturnValue().setExceptionString(EngineMessage.STORAGE_DOMAIN_DOES_NOT_EXIST.toString());
getQueryReturnValue().setSucceeded(false);
return;
}
if (storageDomain.getStorageType().isCinderDomain()) {
QueryReturnValue returnValue = runInternalQuery(QueryType.GetUnregisteredCinderDiskByIdAndStorageDomainId, new GetCinderEntityByStorageDomainIdParameters(diskId, getParameters().getStorageDomainId()));
setReturnValue(returnValue.getReturnValue());
return;
}
// Now get the list of volumes for each new image.
StoragePoolDomainAndGroupIdBaseVDSCommandParameters getVolumesParameters = new StoragePoolDomainAndGroupIdBaseVDSCommandParameters(storagePoolId, storageDomainId, diskId);
VDSReturnValue volumesListReturn = runVdsCommand(VDSCommandType.GetVolumesList, getVolumesParameters);
if (!volumesListReturn.getSucceeded()) {
getQueryReturnValue().setExceptionString(volumesListReturn.getExceptionString());
getQueryReturnValue().setSucceeded(false);
return;
}
@SuppressWarnings("unchecked") List<Guid> volumesList = (List<Guid>) volumesListReturn.getReturnValue();
// image. If there are multiple volumes, skip the image and move on to the next.
if (volumesList.size() != 1) {
getQueryReturnValue().setSucceeded(false);
return;
}
Guid volumeId = volumesList.get(0);
// Get the information about the volume from VDSM.
GetImageInfoVDSCommandParameters imageInfoParameters = new GetImageInfoVDSCommandParameters(storagePoolId, storageDomainId, diskId, volumeId);
VDSReturnValue imageInfoReturn = runVdsCommand(VDSCommandType.GetImageInfo, imageInfoParameters);
if (!imageInfoReturn.getSucceeded()) {
getQueryReturnValue().setExceptionString(imageInfoReturn.getExceptionString());
getQueryReturnValue().setSucceeded(false);
return;
}
DiskImage newDiskImage = (DiskImage) imageInfoReturn.getReturnValue();
if (!fetchQcowCompat(storagePoolId, storageDomainId, diskId, volumeId, newDiskImage)) {
getQueryReturnValue().setSucceeded(false);
return;
}
if (StringUtils.isNotEmpty(newDiskImage.getDescription())) {
try {
metadataDiskDescriptionHandler.enrichDiskByJsonDescription(newDiskImage.getDescription(), newDiskImage);
} catch (IOException | DecoderException e) {
log.warn("Could not parse the description ({}) of disk ID '{}'. The description is expected to be in " + "JSON format.", newDiskImage.getDescription(), newDiskImage.getId());
log.debug("Exception while parsing JSON for disk", e);
}
}
newDiskImage.setStoragePoolId(storagePoolId);
getQueryReturnValue().setReturnValue(newDiskImage);
getQueryReturnValue().setSucceeded(true);
}
use of org.ovirt.engine.core.common.vdscommands.GetImageInfoVDSCommandParameters in project ovirt-engine by oVirt.
the class ImportVmCommand method checkImagesGUIDsLegal.
protected boolean checkImagesGUIDsLegal() {
for (DiskImage image : new ArrayList<>(getImages())) {
Guid imageGUID = image.getImageId();
Guid storagePoolId = image.getStoragePoolId() != null ? image.getStoragePoolId() : Guid.Empty;
Guid storageDomainId = getSourceDomainId(image);
Guid imageGroupId = image.getId() != null ? image.getId() : Guid.Empty;
VDSReturnValue retValue = runVdsCommand(VDSCommandType.GetImageInfo, new GetImageInfoVDSCommandParameters(storagePoolId, storageDomainId, imageGroupId, imageGUID));
if (!retValue.getSucceeded()) {
if (!getParameters().isAllowPartialImport()) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST);
}
log.warn("Disk image '{}/{}' doesn't exist on storage domain '{}'. Ignoring since force flag in on", imageGroupId, imageGUID, storageDomainId);
getVm().getImages().remove(image);
failedDisksToImportForAuditLog.putIfAbsent(image.getId(), image.getDiskAlias());
}
}
return true;
}
Aggregations