Search in sources :

Example 36 with CinderDisk

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

the class AddCinderDiskCommand method createCinderDisk.

private CinderDisk createCinderDisk() {
    final CinderDisk cinderDisk = new CinderDisk();
    cinderDisk.setDiskAlias(getDiskAlias());
    cinderDisk.setSize(getParameters().getDiskInfo().getSize());
    cinderDisk.setDiskAlias(getParameters().getDiskInfo().getDiskAlias());
    cinderDisk.setDiskDescription(getParameters().getDiskInfo().getDiskDescription());
    cinderDisk.setShareable(getParameters().getDiskInfo().isShareable());
    cinderDisk.setStorageIds(new ArrayList<>(Arrays.asList(getParameters().getStorageDomainId())));
    cinderDisk.setSize(getParameters().getDiskInfo().getSize());
    cinderDisk.setVolumeType(VolumeType.Unassigned);
    cinderDisk.setVolumeFormat(VolumeFormat.RAW);
    cinderDisk.setCreationDate(new Date());
    cinderDisk.setLastModified(new Date());
    cinderDisk.setActive(true);
    cinderDisk.setImageStatus(ImageStatus.LOCKED);
    cinderDisk.setVmSnapshotId(getParameters().getVmSnapshotId());
    cinderDisk.setCinderVolumeType(getParameters().getDiskInfo().getCinderVolumeType());
    cinderDisk.setQuotaId(getParameters().getQuotaId());
    if (getVm() != null) {
        cinderDisk.setDiskVmElements(Collections.singletonList(getDiskVmElement()));
    }
    return cinderDisk;
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Date(java.util.Date)

Example 37 with CinderDisk

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

the class AddCinderDiskCommand method executeCommand.

@Override
public void executeCommand() {
    CinderDisk cinderDisk = createCinderDisk();
    String volumeId = getCinderBroker().createDisk(cinderDisk);
    Guid volumeGuid = Guid.createGuidFromString(volumeId);
    cinderDisk.setId(volumeGuid);
    cinderDisk.setImageId(volumeGuid);
    getDiskVmElement().getId().setDeviceId(volumeGuid);
    cinderDisk.setVolumeClassification(VolumeClassification.Volume);
    addCinderDiskToDB(cinderDisk);
    getParameters().setDiskInfo(cinderDisk);
    persistCommand(getParameters().getParentCommand(), true);
    getReturnValue().setActionReturnValue(cinderDisk.getId());
    setSucceeded(true);
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 38 with CinderDisk

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

the class RemoveCinderVolumeParentCommand method performNextOperation.

@Override
public boolean performNextOperation(int completedChildCount) {
    CinderDisk cinderVolume = getParameters().getChildCommandsParameters().get(completedChildCount - 1).getRemovedVolume();
    removeDiskFromDbCallBack(cinderVolume);
    if (getParameters().getChildCommandsParameters().size() == completedChildCount) {
        return false;
    }
    getParameters().setRemovedVolumeIndex(completedChildCount);
    removeCinderVolume(completedChildCount);
    return true;
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 39 with CinderDisk

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

the class RestoreAllCinderSnapshotsCommand method removeRedundantVolumesForOrphanedDisks.

private void removeRedundantVolumesForOrphanedDisks() {
    List<CinderDisk> cinderVolumesToRemove = getParameters().getCinderVolumesToRemove();
    for (CinderDisk cinderVolume : cinderVolumesToRemove) {
        imageStorageDomainMapDao.remove(cinderVolume.getImageId());
        imageDao.remove(cinderVolume.getImageId());
    }
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 40 with CinderDisk

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

the class RestoreFromCinderSnapshotCommand method removeCinderVolume.

private void removeCinderVolume() {
    CinderDisk cinderSnapshotToRemove = (CinderDisk) diskImageDao.getSnapshotById(getParameters().getImageId());
    // Update the volume with active=false, so removeDiskFromDb will not set active volume on the first volume.
    cinderSnapshotToRemove.setActive(false);
    imageDao.update(cinderSnapshotToRemove.getImage());
    removeDescendentSnapshots(cinderSnapshotToRemove);
    removeCinderVolume(0);
}
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