Search in sources :

Example 46 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class ExtendCinderDiskCommand method executeCommand.

@Override
public void executeCommand() {
    CinderDisk cinderDisk = (CinderDisk) getNewDisk();
    getCinderBroker().extendDisk(cinderDisk, (int) getNewDiskSizeInGB());
    persistCommand(getParameters().getParentCommand(), true);
    getReturnValue().setActionReturnValue(cinderDisk.getId());
    setSucceeded(true);
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 47 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class GetUnregisteredCinderDiskByIdAndStorageDomainIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    Disk diskFromDao = diskDao.get(getParameters().getEntityId());
    if (diskFromDao != null) {
        log.info("The disk already exist in the DB, hence, should not be fetched from Cinder. ID: '{}', Alias: '{}'", diskFromDao.getId(), diskFromDao.getDiskAlias());
        getQueryReturnValue().setReturnValue(null);
        return;
    }
    String volumeId = getParameters().getEntityId().toString();
    Volume volume = getVolumeProviderProxy().getVolumeById(volumeId);
    if (volume == null) {
        log.info("The volume doesn't exist in Cinder. ID: '{}'", volumeId);
        getQueryReturnValue().setReturnValue(null);
        return;
    }
    Guid storageDomainId = getParameters().getId();
    CinderDisk unregisteredDisk = CinderBroker.volumeToCinderDisk(volume, storageDomainId);
    getQueryReturnValue().setReturnValue(unregisteredDisk);
}
Also used : Volume(com.woorea.openstack.cinder.model.Volume) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 48 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class GetUnregisteredCinderDisksByStorageDomainIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    final List<Volume> allVolumes = getVolumeProviderProxy().getVolumes();
    final List<Disk> registeredDisks = diskDao.getAllFromDisksByDiskStorageType(DiskStorageType.CINDER, getUserID(), getParameters().isFiltered());
    Set<String> registeredIDs = registeredDisks.stream().map(d -> d.getId().toString()).collect(Collectors.toSet());
    List<Volume> unregisteredVolumes = allVolumes.stream().filter(v -> !registeredIDs.contains(v.getId())).collect(Collectors.toList());
    Guid storageDomainId = getParameters().getId();
    List<CinderDisk> unregisteredDisks = CinderBroker.volumesToCinderDisks(unregisteredVolumes, storageDomainId);
    getQueryReturnValue().setReturnValue(unregisteredDisks);
}
Also used : Inject(javax.inject.Inject) Volume(com.woorea.openstack.cinder.model.Volume) List(java.util.List) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) DiskDao(org.ovirt.engine.core.dao.DiskDao) Guid(org.ovirt.engine.core.compat.Guid) Set(java.util.Set) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Collectors(java.util.stream.Collectors) EngineContext(org.ovirt.engine.core.bll.context.EngineContext) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Volume(com.woorea.openstack.cinder.model.Volume) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 49 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class RemoveAllCinderSnapshotDisksCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    List<CinderDisk> cinderDisks = getParameters().getCinderDisks();
    for (final CinderDisk cinderDisk : cinderDisks) {
        Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveCinderSnapshotDisk, getCinderDiskSnapshotParameter(cinderDisk), cloneContextAndDetachFromParent());
        try {
            ActionReturnValue actionReturnValue = future.get();
            if (!actionReturnValue.getSucceeded()) {
                log.error("Error removing snapshot for Cinder disk '{}'", cinderDisk.getDiskAlias());
            }
        } catch (InterruptedException | ExecutionException e) {
            log.error("Error removing snapshot for Cinder disk '{}': {}", cinderDisk.getDiskAlias(), e.getMessage());
        }
    }
    setSucceeded(true);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) ExecutionException(java.util.concurrent.ExecutionException)

Example 50 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class RemoveCinderDiskCommand method endWithFailure.

@Override
protected void endWithFailure() {
    freeVmSnapshotsWithWait();
    int removedVolumeIndex = getParameters().getRemovedVolumeIndex();
    final CinderDisk cinderVolume = getParameters().getChildCommandsParameters().get(removedVolumeIndex).getRemovedVolume();
    imageDao.updateStatusOfImagesByImageGroupId(getDisk().getId(), ImageStatus.ILLEGAL);
    addCustomValue("imageId", cinderVolume.getImageId().toString());
    auditLogDirector.log(this, AuditLogType.USER_FINISHED_FAILED_REMOVE_CINDER_DISK);
    setSucceeded(true);
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Aggregations

CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)74 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)28 Guid (org.ovirt.engine.core.compat.Guid)19 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)15 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)14 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)13 ArrayList (java.util.ArrayList)12 ImagesContainterParametersBase (org.ovirt.engine.core.common.action.ImagesContainterParametersBase)9 ExecutionException (java.util.concurrent.ExecutionException)7 VM (org.ovirt.engine.core.common.businessentities.VM)6 HashMap (java.util.HashMap)5 List (java.util.List)5 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)5 Map (java.util.Map)4 Test (org.junit.Test)4 StoragePoolValidator (org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator)4 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3