use of org.ovirt.engine.core.common.action.GetCinderEntityByStorageDomainIdParameters in project ovirt-engine by oVirt.
the class RegisterCinderDiskCommand method executeCommand.
@Override
public void executeCommand() {
QueryReturnValue returnValue = runInternalQuery(QueryType.GetUnregisteredCinderDiskByIdAndStorageDomainId, new GetCinderEntityByStorageDomainIdParameters(getCinderDisk().getId(), getParameters().getStorageDomainId()));
CinderDisk cinderDisk = returnValue.getReturnValue();
if (cinderDisk != null) {
addCinderDiskToDB(cinderDisk);
getReturnValue().setActionReturnValue(cinderDisk.getId());
setSucceeded(true);
}
}
use of org.ovirt.engine.core.common.action.GetCinderEntityByStorageDomainIdParameters 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);
}
Aggregations