Search in sources :

Example 41 with CinderDisk

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

the class TryBackToCinderSnapshotCommand method executeCommand.

@Override
protected void executeCommand() {
    final CinderDisk newCinderVolume = createVolumeFromSnapshotInCinder();
    TransactionSupport.executeInNewTransaction(() -> {
        processOldImageFromDb();
        addDiskImageToDb(newCinderVolume, getCompensationContext(), Boolean.TRUE);
        return null;
    });
    getParameters().setDestinationImageId(newCinderVolume.getImageId());
    getParameters().setImageId(newCinderVolume.getImageId());
    getReturnValue().setActionReturnValue(newCinderVolume);
    persistCommand(getParameters().getParentCommand(), true);
    setSucceeded(true);
    return;
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 42 with CinderDisk

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

the class TryBackToCinderSnapshotCommand method cinderCloneDiskFromSnapshot.

private Guid cinderCloneDiskFromSnapshot() {
    CinderDisk activeCinderVolume = getOldActiveDisk();
    String newVolumeId = getCinderBroker().cloneVolumeFromSnapshot(activeCinderVolume, getImageId());
    return Guid.createGuidFromString(newVolumeId);
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 43 with CinderDisk

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

the class TryBackToCinderSnapshotCommand method initializeNewCinderVolumeDisk.

private CinderDisk initializeNewCinderVolumeDisk(Guid newVolumeId) {
    CinderDisk clonedDiskFromSnapshot = (CinderDisk) diskDao.get(getParameters().getContainerId());
    // override volume type and volume format to Unassigned and unassigned for Cinder.
    clonedDiskFromSnapshot.setVolumeType(VolumeType.Unassigned);
    clonedDiskFromSnapshot.setVolumeFormat(VolumeFormat.Unassigned);
    clonedDiskFromSnapshot.setImageStatus(ImageStatus.LOCKED);
    clonedDiskFromSnapshot.setCreationDate(new Date());
    clonedDiskFromSnapshot.setVmSnapshotId(getParameters().getVmSnapshotId());
    clonedDiskFromSnapshot.setLastModifiedDate(new Date());
    clonedDiskFromSnapshot.setQuotaId(getParameters().getQuotaId());
    clonedDiskFromSnapshot.setDiskProfileId(getParameters().getDiskProfileId());
    clonedDiskFromSnapshot.setImageId(newVolumeId);
    clonedDiskFromSnapshot.setParentId(getImageId());
    return clonedDiskFromSnapshot;
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Date(java.util.Date)

Example 44 with CinderDisk

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

the class AddCinderDiskCommandCallback method childCommandsExecutionEnded.

@Override
protected void childCommandsExecutionEnded(CommandBase<?> command, boolean anyFailed, List<Guid> childCmdIds, CommandExecutionStatus status, int completedChildren) {
    AddCinderDiskCommand<AddDiskParameters> addCinderDiskCommand = (AddCinderDiskCommand<AddDiskParameters>) command;
    Guid diskId = getDiskId(addCinderDiskCommand);
    ImageStatus imageStatus = addCinderDiskCommand.getCinderBroker().getDiskStatus(diskId);
    DiskImage disk = (CinderDisk) diskDao.get(diskId);
    if (imageStatus != null && imageStatus != disk.getImageStatus()) {
        switch(imageStatus) {
            case OK:
                setCommandEndStatus(command, false, status, childCmdIds);
                break;
            case ILLEGAL:
                setCommandEndStatus(command, true, status, childCmdIds);
                break;
        }
    }
}
Also used : ImageStatus(org.ovirt.engine.core.common.businessentities.storage.ImageStatus) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 45 with CinderDisk

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

the class CloneSingleCinderDiskCommand method executeCommand.

@Override
protected void executeCommand() {
    lockImage();
    CinderDisk cinderDisk = getDisk();
    cinderDisk.setDiskAlias(getParameters().getDiskAlias());
    String volumeId = getNewVolumeCinderDisk(cinderDisk);
    cinderDisk.setId(Guid.createGuidFromString(volumeId));
    cinderDisk.setImageId(Guid.createGuidFromString(volumeId));
    cinderDisk.setImageStatus(ImageStatus.LOCKED);
    cinderDisk.setVolumeClassification(VolumeClassification.Volume);
    cinderDisk.setVmSnapshotId(getParameters().getVmSnapshotId());
    // If we clone a disk from snapshot, update the volume with the appropriate parameters.
    if (!cinderDisk.getActive()) {
        cinderDisk.setActive(true);
        cinderDisk.setParentId(Guid.Empty);
    }
    addCinderDiskTemplateToDB(cinderDisk);
    getReturnValue().setActionReturnValue(cinderDisk.getId());
    getParameters().setDestinationImageId(Guid.createGuidFromString(volumeId));
    getParameters().setContainerId(Guid.createGuidFromString(volumeId));
    persistCommand(getParameters().getParentCommand(), true);
    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