Search in sources :

Example 1 with GetCinderEntityByStorageDomainIdParameters

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);
    }
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) GetCinderEntityByStorageDomainIdParameters(org.ovirt.engine.core.common.action.GetCinderEntityByStorageDomainIdParameters)

Example 2 with GetCinderEntityByStorageDomainIdParameters

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);
}
Also used : GetImageInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetImageInfoVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) StoragePoolDomainAndGroupIdBaseVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.StoragePoolDomainAndGroupIdBaseVDSCommandParameters) IOException(java.io.IOException) GetCinderEntityByStorageDomainIdParameters(org.ovirt.engine.core.common.action.GetCinderEntityByStorageDomainIdParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) DecoderException(org.apache.commons.codec.DecoderException) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) List(java.util.List) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

GetCinderEntityByStorageDomainIdParameters (org.ovirt.engine.core.common.action.GetCinderEntityByStorageDomainIdParameters)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 IOException (java.io.IOException)1 List (java.util.List)1 DecoderException (org.apache.commons.codec.DecoderException)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 GetImageInfoVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.GetImageInfoVDSCommandParameters)1 StoragePoolDomainAndGroupIdBaseVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.StoragePoolDomainAndGroupIdBaseVDSCommandParameters)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 Guid (org.ovirt.engine.core.compat.Guid)1