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;
}
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);
}
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;
}
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;
}
}
}
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);
}
Aggregations