use of org.ovirt.engine.core.common.action.RemoveCinderDiskParameters in project ovirt-engine by oVirt.
the class RestoreAllCinderSnapshotsCommand method getRestoreFromSnapshotParams.
private ImagesContainterParametersBase getRestoreFromSnapshotParams(CinderDisk cinderDisk) {
RemoveCinderDiskParameters params = new RemoveCinderDiskParameters(cinderDisk.getImageId());
params.setRemovedVolume(cinderDisk);
params.setParentCommand(getActionType());
params.setStorageDomainId(cinderDisk.getStorageIds().get(0));
params.setParentParameters(getParameters());
return params;
}
use of org.ovirt.engine.core.common.action.RemoveCinderDiskParameters in project ovirt-engine by oVirt.
the class RestoreAllCinderSnapshotsCommand method executeVmCommand.
@Override
protected void executeVmCommand() {
for (CinderDisk cinderDisk : getParameters().getCinderDisksToRestore()) {
ImagesContainterParametersBase params = getRestoreFromSnapshotParams(cinderDisk);
restoreCinderDisk(cinderDisk, params);
// In case we want to undo the previewed snapshot.
if (getParameters().getSnapshot().getType() == Snapshot.SnapshotType.STATELESS) {
Guid activeSnapshotId = snapshotDao.get(getParameters().getVmId(), Snapshot.SnapshotType.ACTIVE).getId();
updateCinderDiskSnapshot(cinderDisk.getId(), activeSnapshotId, cinderDisk.getVmSnapshotId());
} else if (getParameters().getSnapshot().getType() != Snapshot.SnapshotType.REGULAR) {
updateCinderDiskSnapshot(cinderDisk.getId(), getParameters().getSnapshot().getId(), null);
}
}
List<CinderDisk> cinderDisksToRemove = getParameters().getCinderDisksToRemove();
for (CinderDisk cinderDisk : cinderDisksToRemove) {
RemoveCinderDiskParameters removeDiskParam = new RemoveCinderDiskParameters(cinderDisk.getImageId());
removeDiskParam.setRemovedVolume(cinderDisk);
removeDiskParam.setParentCommand(getActionType());
removeDiskParam.setStorageDomainId(cinderDisk.getStorageIds().get(0));
removeDiskParam.setParentParameters(getParameters());
removeDiskParam.setEndProcedure(EndProcedure.COMMAND_MANAGED);
Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveCinderDisk, removeDiskParam, cloneContextAndDetachFromParent());
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
log.error("Error removing Cinder disk", e);
}
}
List<CinderDisk> cinderVolumesToRemove = getParameters().getCinderVolumesToRemove();
for (CinderDisk cinderVolume : cinderVolumesToRemove) {
RemoveCinderDiskVolumeParameters removeDiskVolumeParam = new RemoveCinderDiskVolumeParameters(cinderVolume);
removeDiskVolumeParam.setParentCommand(getActionType());
removeDiskVolumeParam.setParentParameters(getParameters());
removeDiskVolumeParam.setEndProcedure(EndProcedure.COMMAND_MANAGED);
Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveCinderDiskVolume, removeDiskVolumeParam, cloneContextAndDetachFromParent());
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
log.error("Error removing Cinder disk", e);
}
}
setSucceeded(true);
}
use of org.ovirt.engine.core.common.action.RemoveCinderDiskParameters in project ovirt-engine by oVirt.
the class RemoveAllVmCinderDisksCommand method buildChildCommandParameters.
private RemoveCinderDiskParameters buildChildCommandParameters(CinderDisk cinderDisk) {
RemoveCinderDiskParameters removeDiskParams = new RemoveCinderDiskParameters(cinderDisk.getId());
removeDiskParams.setParentCommand(getActionType());
removeDiskParams.setParentParameters(getParameters());
removeDiskParams.setShouldBeLogged(false);
removeDiskParams.setEndProcedure(EndProcedure.COMMAND_MANAGED);
return removeDiskParams;
}
use of org.ovirt.engine.core.common.action.RemoveCinderDiskParameters in project ovirt-engine by oVirt.
the class CloneSingleCinderDiskCommand method buildRevertParameters.
private RemoveCinderDiskParameters buildRevertParameters(Guid cinderDiskId) {
RemoveCinderDiskParameters removeDiskParams = new RemoveCinderDiskParameters(cinderDiskId);
removeDiskParams.setLockVM(false);
removeDiskParams.setShouldBeLogged(false);
return removeDiskParams;
}
use of org.ovirt.engine.core.common.action.RemoveCinderDiskParameters in project ovirt-engine by oVirt.
the class RemoveDiskCommand method executeCommand.
@Override
protected void executeCommand() {
switch(getDisk().getDiskStorageType()) {
case IMAGE:
ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.RemoveImage, buildRemoveImageParameters(getDiskImage()));
if (actionReturnValue.getSucceeded()) {
if (getDisk().getContentType() == DiskContentType.MEMORY_DUMP_VOLUME || getDisk().getContentType() == DiskContentType.MEMORY_METADATA_VOLUME) {
removeMemoryDiskFromSnapshotIfNeeded();
}
incrementVmsGeneration();
getReturnValue().getVdsmTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
setSucceeded(true);
}
break;
case LUN:
removeLunDisk();
break;
case CINDER:
RemoveCinderDiskParameters params = new RemoveCinderDiskParameters(getParameters().getDiskId());
params.setEndProcedure(EndProcedure.COMMAND_MANAGED);
Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveCinderDisk, params, cloneContextAndDetachFromParent());
try {
setReturnValue(future.get());
setSucceeded(getReturnValue().getSucceeded());
} catch (InterruptedException | ExecutionException e) {
log.error("Error removing Cinder disk '{}': {}", getDiskImage().getDiskAlias(), e.getMessage());
log.debug("Exception", e);
}
break;
}
}
Aggregations