use of org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters 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.RemoveCinderDiskVolumeParameters in project ovirt-engine by oVirt.
the class CreateCinderSnapshotCommand method revertCinderVolume.
private void revertCinderVolume(CinderDisk diskVolumeVolume) {
RemoveCinderDiskVolumeParameters removeDiskVolumeParam = new RemoveCinderDiskVolumeParameters(diskVolumeVolume);
Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveCinderDiskVolume, removeDiskVolumeParam, null);
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
log.error("Fail to revert snapshot id '{}' for disk id '{}'. Exception: {}", diskVolumeVolume.getImageId(), diskVolumeVolume.getId(), e);
}
}
use of org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters in project ovirt-engine by oVirt.
the class RemoveCinderVolumeParentCommand method createChildParams.
private RemoveCinderDiskVolumeParameters createChildParams(CinderDisk cinderDiskVolume) {
RemoveCinderDiskVolumeParameters childParam = new RemoveCinderDiskVolumeParameters(cinderDiskVolume);
childParam.setParentCommand(getActionType());
childParam.setParentParameters(getParameters());
childParam.setEndProcedure(EndProcedure.COMMAND_MANAGED);
return childParam;
}
use of org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters in project ovirt-engine by oVirt.
the class RemoveCinderDiskVolumeCommandCallback method childCommandsExecutionEnded.
@Override
protected void childCommandsExecutionEnded(CommandBase<?> command, boolean anyFailed, List<Guid> childCmdIds, CommandExecutionStatus status, int completedChildren) {
RemoveCinderDiskVolumeCommand<RemoveCinderDiskVolumeParameters> removeCinderDiskVolumeCommand = (RemoveCinderDiskVolumeCommand<RemoveCinderDiskVolumeParameters>) command;
CinderDisk removedVolume = removeCinderDiskVolumeCommand.getParameters().getRemovedVolume();
// In case the volume/snapshot has been deleted from Cinder.
if (!removeCinderDiskVolumeCommand.getCinderBroker().isVolumeExistsByClassificationType(removedVolume)) {
setCommandEndStatus(command, false, status, childCmdIds);
}
ImageStatus imageStatus = checkImageStatus(removedVolume, removeCinderDiskVolumeCommand);
if (imageStatus != null && imageStatus != removedVolume.getImageStatus()) {
switch(imageStatus) {
case ILLEGAL:
setCommandEndStatus(command, true, status, childCmdIds);
break;
}
}
}
Aggregations