Shubhendu Tripathi has uploaded a new change for review. Change subject: gluster: BLL commands for gluster volume snapshot ......................................................................
gluster: BLL commands for gluster volume snapshot Introduced BLL commands for gluster volume snapshot actions - Delete - Delete All - Activate - Deactivate - Restore Change-Id: I74fa567e0910a8f97c3d127951481448983e3fd3 Signed-off-by: Shubhendu Tripathi <shtri...@redhat.com> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ActivateGlusterVolumeSnapshotCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeactivateGlusterVolumeSnapshotCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeleteAllGlusterVolumeSnapshotsCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeleteGlusterVolumeSnapshotCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RestoreGlusterVolumeSnapshotCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterVolumeSnapshotActionParameters.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 16 files changed, 623 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/25/37325/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ActivateGlusterVolumeSnapshotCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ActivateGlusterVolumeSnapshotCommand.java new file mode 100644 index 0000000..b75fb55 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ActivateGlusterVolumeSnapshotCommand.java @@ -0,0 +1,98 @@ +package org.ovirt.engine.core.bll.gluster; + +import java.util.Collections; +import java.util.Map; + +import org.ovirt.engine.core.bll.LockMessagesMatchUtil; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.LockProperties; +import org.ovirt.engine.core.common.action.LockProperties.Scope; +import org.ovirt.engine.core.common.action.gluster.GlusterVolumeSnapshotActionParameters; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterSnapshotStatus; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity; +import org.ovirt.engine.core.common.constants.gluster.GlusterConstants; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.locks.LockingGroup; +import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; +import org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeActivateSnapshotVDSParameters; +import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDao; + +public class ActivateGlusterVolumeSnapshotCommand extends GlusterVolumeCommandBase<GlusterVolumeSnapshotActionParameters> { + GlusterVolumeSnapshotEntity snapshot; + + public ActivateGlusterVolumeSnapshotCommand(GlusterVolumeSnapshotActionParameters params) { + super(params); + setGlusterVolumeId(params.getVolumeId()); + } + + @Override + protected LockProperties applyLockProperties(LockProperties lockProperties) { + return lockProperties.withScope(Scope.Execution); + } + + @Override + protected void setActionMessageParameters() { + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE); + addCustomValue(GlusterConstants.VOLUME_SNAPSHOT_NAME, getParameters().getSnapshotName()); + } + + @Override + public void executeCommand() { + VDSReturnValue retVal = + runVdsCommand(VDSCommandType.ActivateGlusterVolumeSnapshot, + new GlusterVolumeActivateSnapshotVDSParameters(getUpServer().getId(), + getGlusterVolumeName(), + getParameters().getSnapshotName(), + getParameters().getForce())); + setSucceeded(retVal.getSucceeded()); + + if (!getSucceeded()) { + handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_ACTIVATE_FAILED, retVal.getVdsError().getMessage()); + } else { + getGlusterVolumeSnapshotDao().updateSnapshotStatus(snapshot.getId(), GlusterSnapshotStatus.STARTED); + } + } + + @Override + protected boolean canDoAction() { + if (!super.canDoAction()) { + return false; + } + + snapshot = getGlusterVolumeSnapshotDao().getByName(getGlusterVolumeId(), getParameters().getSnapshotName()); + if (snapshot == null) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_DOES_NOT_EXIST, + getParameters().getSnapshotName()); + } else if (snapshot.getStatus() == GlusterSnapshotStatus.STARTED) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_ACTIVATED, + snapshot.getSnapshotName()); + } + + return true; + } + + @Override + protected Map<String, Pair<String, String>> getExclusiveLocks() { + if (!isInternalExecution()) { + return Collections.singletonMap(getGlusterVolumeId().toString(), + LockMessagesMatchUtil.makeLockingPair(LockingGroup.GLUSTER, + VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED)); + } + return null; + } + + @Override + public AuditLogType getAuditLogTypeValue() { + if (getSucceeded()) { + return AuditLogType.GLUSTER_VOLUME_SNAPSHOT_ACTIVATED; + } else { + return AuditLogType.GLUSTER_VOLUME_SNAPSHOT_ACTIVATE_FAILED; + } + } + + protected GlusterVolumeSnapshotDao getGlusterVolumeSnapshotDao() { + return getDbFacade().getGlusterVolumeSnapshotDao(); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeactivateGlusterVolumeSnapshotCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeactivateGlusterVolumeSnapshotCommand.java new file mode 100644 index 0000000..3a5b0d4 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeactivateGlusterVolumeSnapshotCommand.java @@ -0,0 +1,97 @@ +package org.ovirt.engine.core.bll.gluster; + +import java.util.Collections; +import java.util.Map; + +import org.ovirt.engine.core.bll.LockMessagesMatchUtil; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.LockProperties; +import org.ovirt.engine.core.common.action.LockProperties.Scope; +import org.ovirt.engine.core.common.action.gluster.GlusterVolumeSnapshotActionParameters; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterSnapshotStatus; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity; +import org.ovirt.engine.core.common.constants.gluster.GlusterConstants; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.locks.LockingGroup; +import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; +import org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters; +import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDao; + +public class DeactivateGlusterVolumeSnapshotCommand extends GlusterVolumeCommandBase<GlusterVolumeSnapshotActionParameters> { + GlusterVolumeSnapshotEntity snapshot; + + public DeactivateGlusterVolumeSnapshotCommand(GlusterVolumeSnapshotActionParameters params) { + super(params); + setGlusterVolumeId(params.getVolumeId()); + } + + @Override + protected LockProperties applyLockProperties(LockProperties lockProperties) { + return lockProperties.withScope(Scope.Execution); + } + + @Override + protected void setActionMessageParameters() { + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE); + addCustomValue(GlusterConstants.VOLUME_SNAPSHOT_NAME, getParameters().getSnapshotName()); + } + + @Override + public void executeCommand() { + VDSReturnValue retVal = + runVdsCommand(VDSCommandType.DeactivateGlusterVolumeSnapshot, + new GlusterVolumeSnapshotActionVDSParameters(getUpServer().getId(), + getGlusterVolumeName(), + getParameters().getSnapshotName())); + setSucceeded(retVal.getSucceeded()); + + if (!getSucceeded()) { + handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DEACTIVATE_FAILED, retVal.getVdsError().getMessage()); + } else { + getGlusterVolumeSnapshotDao().updateSnapshotStatus(snapshot.getId(), GlusterSnapshotStatus.STOPPED); + } + } + + @Override + protected boolean canDoAction() { + if (!super.canDoAction()) { + return false; + } + + snapshot = getGlusterVolumeSnapshotDao().getByName(getGlusterVolumeId(), getParameters().getSnapshotName()); + if (snapshot == null) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_DOES_NOT_EXIST, + getParameters().getSnapshotName()); + } else if (snapshot.getStatus() == GlusterSnapshotStatus.STOPPED) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_DEACTIVATED, + snapshot.getSnapshotName()); + } + + return true; + } + + @Override + protected Map<String, Pair<String, String>> getExclusiveLocks() { + if (!isInternalExecution()) { + return Collections.singletonMap(getGlusterVolumeId().toString(), + LockMessagesMatchUtil.makeLockingPair(LockingGroup.GLUSTER, + VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED)); + } + return null; + } + + @Override + public AuditLogType getAuditLogTypeValue() { + if (getSucceeded()) { + return AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DEACTIVATED; + } else { + return AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DEACTIVATE_FAILED; + } + } + + protected GlusterVolumeSnapshotDao getGlusterVolumeSnapshotDao() { + return getDbFacade().getGlusterVolumeSnapshotDao(); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeleteAllGlusterVolumeSnapshotsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeleteAllGlusterVolumeSnapshotsCommand.java new file mode 100644 index 0000000..439d87c --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeleteAllGlusterVolumeSnapshotsCommand.java @@ -0,0 +1,95 @@ +package org.ovirt.engine.core.bll.gluster; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.ovirt.engine.core.bll.LockMessagesMatchUtil; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.LockProperties; +import org.ovirt.engine.core.common.action.LockProperties.Scope; +import org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.locks.LockingGroup; +import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; +import org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeVDSParameters; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDao; + +public class DeleteAllGlusterVolumeSnapshotsCommand extends GlusterVolumeCommandBase<GlusterVolumeParameters> { + List<GlusterVolumeSnapshotEntity> snapshots; + + public DeleteAllGlusterVolumeSnapshotsCommand(GlusterVolumeParameters params) { + super(params); + setGlusterVolumeId(params.getVolumeId()); + } + + @Override + protected LockProperties applyLockProperties(LockProperties lockProperties) { + return lockProperties.withScope(Scope.Execution); + } + + @Override + protected void setActionMessageParameters() { + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE); + } + + @Override + public void executeCommand() { + VDSReturnValue retVal = + runVdsCommand(VDSCommandType.DeleteAllGlusterVolumeSnapshots, + new GlusterVolumeVDSParameters(getUpServer().getId(), getGlusterVolumeName())); + setSucceeded(retVal.getSucceeded()); + + if (!getSucceeded()) { + handleVdsError(AuditLogType.GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETE_FAILED, retVal.getVdsError().getMessage()); + } else { + List<Guid> guids = new ArrayList<>(); + for (GlusterVolumeSnapshotEntity snapshot : snapshots) { + guids.add(snapshot.getId()); + } + getGlusterVolumeSnapshotDao().removeAll(guids); + } + } + + @Override + protected boolean canDoAction() { + if (!super.canDoAction()) { + return false; + } + + snapshots = getGlusterVolumeSnapshotDao().getAllByVolumeId(getGlusterVolumeId()); + if (snapshots == null || snapshots.size() == 0) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_NO_SNAPSHOTS_EXIST, getGlusterVolumeName()); + } + + return true; + } + + @Override + protected Map<String, Pair<String, String>> getExclusiveLocks() { + if (!isInternalExecution()) { + return Collections.singletonMap(getGlusterVolumeId().toString(), + LockMessagesMatchUtil.makeLockingPair(LockingGroup.GLUSTER, + VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED)); + } + return null; + } + + @Override + public AuditLogType getAuditLogTypeValue() { + if (getSucceeded()) { + return AuditLogType.GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETED; + } else { + return AuditLogType.GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETE_FAILED; + } + } + + protected GlusterVolumeSnapshotDao getGlusterVolumeSnapshotDao() { + return getDbFacade().getGlusterVolumeSnapshotDao(); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeleteGlusterVolumeSnapshotCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeleteGlusterVolumeSnapshotCommand.java new file mode 100644 index 0000000..72d196d --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/DeleteGlusterVolumeSnapshotCommand.java @@ -0,0 +1,97 @@ +package org.ovirt.engine.core.bll.gluster; + +import java.util.Collections; +import java.util.Map; + +import org.apache.commons.lang.StringUtils; +import org.ovirt.engine.core.bll.LockMessagesMatchUtil; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.LockProperties; +import org.ovirt.engine.core.common.action.LockProperties.Scope; +import org.ovirt.engine.core.common.action.gluster.GlusterVolumeSnapshotActionParameters; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity; +import org.ovirt.engine.core.common.constants.gluster.GlusterConstants; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.locks.LockingGroup; +import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; +import org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters; +import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDao; + +public class DeleteGlusterVolumeSnapshotCommand extends GlusterVolumeCommandBase<GlusterVolumeSnapshotActionParameters> { + GlusterVolumeSnapshotEntity snapshot; + + public DeleteGlusterVolumeSnapshotCommand(GlusterVolumeSnapshotActionParameters params) { + super(params); + setGlusterVolumeId(params.getVolumeId()); + } + + @Override + protected LockProperties applyLockProperties(LockProperties lockProperties) { + return lockProperties.withScope(Scope.Execution); + } + + @Override + protected void setActionMessageParameters() { + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE); + addCustomValue(GlusterConstants.VOLUME_SNAPSHOT_NAME, getParameters().getSnapshotName()); + } + + @Override + public void executeCommand() { + VDSReturnValue retVal = + runVdsCommand(VDSCommandType.DeleteGlusterVolume, + new GlusterVolumeSnapshotActionVDSParameters(getUpServer().getId(), + getGlusterVolumeName(), + getParameters().getSnapshotName())); + setSucceeded(retVal.getSucceeded()); + if (!getSucceeded()) { + handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DELETE_FAILED, retVal.getVdsError().getMessage()); + } else { + getGlusterVolumeSnapshotDao().remove(snapshot.getId()); + } + } + + @Override + protected boolean canDoAction() { + if (!super.canDoAction()) { + return false; + } + + if (StringUtils.isEmpty(getParameters().getSnapshotName())) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_NAME_IS_EMPTY); + } + + snapshot = getGlusterVolumeSnapshotDao().getByName(getGlusterVolumeId(), getParameters().getSnapshotName()); + if (snapshot == null) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_DOES_NOT_EXIST, + getParameters().getSnapshotName()); + } + + return true; + } + + @Override + protected Map<String, Pair<String, String>> getExclusiveLocks() { + if (!isInternalExecution()) { + return Collections.singletonMap(getGlusterVolumeId().toString(), + LockMessagesMatchUtil.makeLockingPair(LockingGroup.GLUSTER, + VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED)); + } + return null; + } + + @Override + public AuditLogType getAuditLogTypeValue() { + if (getSucceeded()) { + return AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DELETED; + } else { + return AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DELETE_FAILED; + } + } + + protected GlusterVolumeSnapshotDao getGlusterVolumeSnapshotDao() { + return getDbFacade().getGlusterVolumeSnapshotDao(); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RestoreGlusterVolumeSnapshotCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RestoreGlusterVolumeSnapshotCommand.java new file mode 100644 index 0000000..e6cc65f --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RestoreGlusterVolumeSnapshotCommand.java @@ -0,0 +1,104 @@ +package org.ovirt.engine.core.bll.gluster; + +import java.util.Collections; +import java.util.Map; + +import org.ovirt.engine.core.bll.LockMessagesMatchUtil; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.LockProperties; +import org.ovirt.engine.core.common.action.LockProperties.Scope; +import org.ovirt.engine.core.common.action.gluster.GlusterVolumeSnapshotActionParameters; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity; +import org.ovirt.engine.core.common.constants.gluster.GlusterConstants; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.job.JobExecutionStatus; +import org.ovirt.engine.core.common.locks.LockingGroup; +import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; +import org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters; +import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDao; + +public class RestoreGlusterVolumeSnapshotCommand extends GlusterVolumeCommandBase<GlusterVolumeSnapshotActionParameters> { + GlusterVolumeSnapshotEntity snapshot; + + public RestoreGlusterVolumeSnapshotCommand(GlusterVolumeSnapshotActionParameters params) { + super(params); + setGlusterVolumeId(params.getVolumeId()); + } + + @Override + protected LockProperties applyLockProperties(LockProperties lockProperties) { + return lockProperties.withScope(Scope.Execution); + } + + @Override + protected void setActionMessageParameters() { + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE); + addCustomValue(GlusterConstants.VOLUME_SNAPSHOT_NAME, getParameters().getSnapshotName()); + } + + @Override + public void executeCommand() { + VDSReturnValue retVal = + runVdsCommand(VDSCommandType.RestoreGlusterVolumeSnapshot, + new GlusterVolumeSnapshotActionVDSParameters(getUpServer().getId(), + getGlusterVolumeName(), + getParameters().getSnapshotName())); + setSucceeded(retVal.getSucceeded()); + + if (!getSucceeded()) { + handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED, retVal.getVdsError().getMessage()); + } else { + getGlusterVolumeSnapshotDao().remove(snapshot.getId()); + // TODO: Was discussed to mark the snapshot as restored and still maintain in engine + } + } + + @Override + protected boolean canDoAction() { + if (!super.canDoAction()) { + return false; + } + + snapshot = getGlusterVolumeSnapshotDao().getByName(getGlusterVolumeId(), getParameters().getSnapshotName()); + if (snapshot == null) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_DOES_NOT_EXIST, + getParameters().getSnapshotName()); + } + if (getGlusterVolume().getStatus() == GlusterStatus.DOWN) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_DOWN, getGlusterVolumeName()); + } + if (getGlusterVolume().getAsyncTask().getStatus() == JobExecutionStatus.STARTED) { + failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VOLUME_OPERATION_IN_PROGRESS, + getGlusterVolumeName(), + getVdsGroupName()); + } + + return true; + } + + @Override + protected Map<String, Pair<String, String>> getExclusiveLocks() { + if (!isInternalExecution()) { + return Collections.singletonMap(getGlusterVolumeId().toString(), + LockMessagesMatchUtil.makeLockingPair(LockingGroup.GLUSTER, + VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED)); + } + return null; + } + + @Override + public AuditLogType getAuditLogTypeValue() { + if (getSucceeded()) { + return AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORED; + } else { + return AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED; + } + } + + protected GlusterVolumeSnapshotDao getGlusterVolumeSnapshotDao() { + return getDbFacade().getGlusterVolumeSnapshotDao(); + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index 01db9e9..b944b9c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -396,6 +396,16 @@ GEOREP_SESSION_STOP_FAILED(4102, AuditLogSeverity.ERROR), GEOREP_SESSION_DELETE(4103), GEOREP_SESSION_DELETE_FAILED(4104, AuditLogSeverity.ERROR), + GLUSTER_VOLUME_SNAPSHOT_DELETED(4105), + GLUSTER_VOLUME_SNAPSHOT_DELETE_FAILED(4106, AuditLogSeverity.ERROR), + GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETED(4107), + GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETE_FAILED(4108, AuditLogSeverity.ERROR), + GLUSTER_VOLUME_SNAPSHOT_ACTIVATED(4109), + GLUSTER_VOLUME_SNAPSHOT_ACTIVATE_FAILED(4110, AuditLogSeverity.ERROR), + GLUSTER_VOLUME_SNAPSHOT_DEACTIVATED(4111), + GLUSTER_VOLUME_SNAPSHOT_DEACTIVATE_FAILED(4112, AuditLogSeverity.ERROR), + GLUSTER_VOLUME_SNAPSHOT_RESTORED(4113), + GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED(4114, AuditLogSeverity.ERROR), USER_FORCE_SELECTED_SPM(159), USER_VDS_RESTART(41), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java index f6b7155..be76f5d 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java @@ -124,6 +124,16 @@ AddEventNotificationEntry(EventNotificationEntity.GlusterService, AuditLogType.GLUSTER_SERVICE_RESTARTED); AddEventNotificationEntry(EventNotificationEntity.GlusterService, AuditLogType.GLUSTER_SERVICE_RESTART_FAILED); AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_BRICK_STATUS_CHANGED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DELETED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DELETE_FAILED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETE_FAILED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_ACTIVATED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_ACTIVATE_FAILED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DEACTIVATED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DEACTIVATE_FAILED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORED); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED); // DWH AddEventNotificationEntry(EventNotificationEntity.DWH, AuditLogType.DWH_STOPPED); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java index 06ab059..67d8471 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java @@ -311,6 +311,11 @@ StartGlusterVolumeGeoRep(1429, ActionGroup.MANIPULATE_GLUSTER_VOLUME, QuotaDependency.NONE), ResumeGeoRepSession(1430, ActionGroup.MANIPULATE_GLUSTER_VOLUME, QuotaDependency.NONE), PauseGlusterVolumeGeoRepSession(1431, ActionGroup.MANIPULATE_GLUSTER_VOLUME, QuotaDependency.NONE), + DeleteGlusterVolumeSnapshot(1432, ActionGroup.MANIPULATE_GLUSTER_VOLUME, QuotaDependency.NONE), + DeleteAllGlusterVolumeSnapshots(1433, ActionGroup.MANIPULATE_GLUSTER_VOLUME, QuotaDependency.NONE), + ActivateGlusterVolumeSnapshot(1434, ActionGroup.MANIPULATE_GLUSTER_VOLUME, QuotaDependency.NONE), + DeactivateGlusterVolumeSnapshot(1435, ActionGroup.MANIPULATE_GLUSTER_VOLUME, QuotaDependency.NONE), + RestoreGlusterVolumeSnapshot(1436, ActionGroup.MANIPULATE_GLUSTER_VOLUME, QuotaDependency.NONE), // Scheduling Policy AddClusterPolicy(1450, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, QuotaDependency.NONE), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterVolumeSnapshotActionParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterVolumeSnapshotActionParameters.java new file mode 100644 index 0000000..eb04918 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterVolumeSnapshotActionParameters.java @@ -0,0 +1,35 @@ +package org.ovirt.engine.core.common.action.gluster; + +import org.ovirt.engine.core.compat.Guid; + +public class GlusterVolumeSnapshotActionParameters extends GlusterVolumeParameters { + private static final long serialVersionUID = -5148741622108406754L; + + private String snapshotName; + private boolean force; + + public GlusterVolumeSnapshotActionParameters() { + } + + public GlusterVolumeSnapshotActionParameters(Guid volumeId, String snapshotName, boolean force) { + super(volumeId); + this.snapshotName = snapshotName; + this.force = force; + } + + public String getSnapshotName() { + return this.snapshotName; + } + + public void setSnapshotName(String name) { + this.snapshotName = name; + } + + public boolean getForce() { + return this.force; + } + + public void setForce(boolean value) { + this.force = value; + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.java index ae767d0..56d513c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/GlusterConstants.java @@ -42,4 +42,5 @@ public static final String JOB_INFO = "info"; public static final String NO_SERVER = "NO SERVER"; public static final String VOLUME_SNAPSHOT_MAX_HARD_LIMIT = "snap-max-hard-limit"; + public static final String VOLUME_SNAPSHOT_NAME = "snapname"; } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index c748e41..2a47302 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -951,6 +951,11 @@ ACTION_TYPE_FAILED_GEOREP_SESSION_LOCKED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GEOREP_SESSION_STOPPED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_RESUMED(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_NAME_IS_EMPTY(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_DOES_NOT_EXIST(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_GLUSTER_VOLUME_NO_SNAPSHOTS_EXIST(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_ACTIVATED(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_DEACTIVATED(ErrorType.CONFLICT), // OpenStack Glance ACTION_TYPE_FAILED_IMAGE_DOWNLOAD_ERROR(ErrorType.BAD_PARAMETERS), diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 5e9cddf..c0b6f6a 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -1153,6 +1153,11 @@ ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED=Cannot ${action} ${type}. Geo-replication session is already started. ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_RESUMED=Cannot ${action} ${type}. Geo-replication session is resumed. ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_PAUSED=Cannot ${action} ${type}. Geo-replication session is paused. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_NAME_IS_EMPTY=Cannot ${action} ${type}. Gluster volume snapshot name is empty. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_DOES_NOT_EXIST=Cannot ${action} ${type}. Snapshot ${snapname} does not exist. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_NO_SNAPSHOTS_EXIST=Cannot ${action} ${type}. No snapshots exist for volume ${volumeName}. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_ACTIVATED=Cannot ${action} ${type}. Snapshot ${snapname} is already activated. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_DEACTIVATED=Cannot ${action} ${type}. Snapshot ${snapname} is already de-activated. ACTION_TYPE_FAILED_TAG_ID_REQUIRED=Cannot ${action} ${type}. Tag ID is required. diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties index 79e8f53..4ba82f5 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -824,6 +824,17 @@ GEOREP_SESSION_DELETE_FAILED=Failed to delete geo-replication session on volume ${glusterVolumeName} GEOREP_SESSION_STARTED=Geo-replication session on volume ${glusterVolumeName} has been started. GEOREP_SESSION_START_FAILED=Failed to start geo-replication session on volume ${glusterVolumeName} +GLUSTER_VOLUME_SNAPSHOT_DELETED=Gluster volume snapshot ${snapname} deleted. +GLUSTER_VOLUME_SNAPSHOT_DELETE_FAILED=Failed to delete gluster volume snapshot ${snapname}. +GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETED=Deleted all the snapshots for the volume ${glusterVolumeName}. +GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETE_FAILED=Failed to delete all the snapshots of the volume ${glusterVolumeName}. +GLUSTER_VOLUME_SNAPSHOT_ACTIVATED=Activated the snapshot ${snapname} on volume ${glusterVolumeName}. +GLUSTER_VOLUME_SNAPSHOT_ACTIVATE_FAILED=Failed to activate the snapshot ${snapname} on volume ${glusterVolumeName}. +GLUSTER_VOLUME_SNAPSHOT_DEACTIVATED=De-activated the snapshot ${snapname} on volume ${glusterVolumeName}. +GLUSTER_VOLUME_SNAPSHOT_DEACTIVATE_FAILED=Failed to de-activate snapshot ${snapname} on volume ${glusterVolumeName}. +GLUSTER_VOLUME_SNAPSHOT_RESTORED=Restored the volume ${glusterVolumeName} to the state of snapshot ${snapname}. +GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED=Failed to restore the volume ${glusterVolumeName} to the state of snapshot ${snapname}. + VDS_UNTRUSTED=Host ${VdsName} was set to non-operational. Host is not trusted by the attestation service. USER_ADDED_NETWORK_QOS=Network QoS ${QosName} was added. (User: ${UserName}) USER_FAILED_TO_ADD_NETWORK_QOS=Failed to add Network QoS ${QosName}. (User: ${UserName}) diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index 01a49e9..c16f997 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -3098,6 +3098,21 @@ @DefaultStringValue("Cannot ${action} ${type}. Geo-replication session is paused.") String ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_PAUSED(); + @DefaultStringValue("Cannot ${action} ${type}. Gluster volume snapshot name is empty.") + String ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_NAME_IS_EMPTY(); + + @DefaultStringValue("Cannot ${action} ${type}. Snapshot ${snapname} does not exist.") + String ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_DOES_NOT_EXIST(); + + @DefaultStringValue("Cannot ${action} ${type}. No snapshots exist for volume ${volumeName}") + String ACTION_TYPE_FAILED_GLUSTER_VOLUME_NO_SNAPSHOTS_EXIST(); + + @DefaultStringValue("Cannot ${action} ${type}. Snapshot ${snapname} is already activated.") + String ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_ACTIVATED(); + + @DefaultStringValue("Cannot ${action} ${type}. Snapshot ${snapname} is already de-activated.") + String ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_DEACTIVATED(); + @DefaultStringValue("Cannot ${action} ${type}. All three values are needed in order to define QoS on each network directions.") String ACTION_TYPE_FAILED_NETWORK_QOS_MISSING_VALUES(); @@ -3517,5 +3532,4 @@ @DefaultStringValue("Cannot ${action} ${type}. Graphics device ID or VM/Template ID is null.") String ACTION_TYPE_REMOVE_GRAPHICS_DEV_INVALID_PARAMS(); - } diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java index f7df465..bb18bb5 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java @@ -459,6 +459,26 @@ String AuditLogType___GEOREP_SESSION_START_FAILED(); + String AuditLogType___GLUSTER_VOLUME_SNAPSHOT_DELETED(); + + String AuditLogType___GLUSTER_VOLUME_SNAPSHOT_DELETE_FAILED(); + + String AuditLogType___GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETED(); + + String AuditLogType___GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETE_FAILED(); + + String AuditLogType___GLUSTER_VOLUME_SNAPSHOT_ACTIVATED(); + + String AuditLogType___GLUSTER_VOLUME_SNAPSHOT_ACTIVATE_FAILED(); + + String AuditLogType___GLUSTER_VOLUME_SNAPSHOT_DEACTIVATED(); + + String AuditLogType___GLUSTER_VOLUME_SNAPSHOT_DEACTIVATE_FAILED(); + + String AuditLogType___GLUSTER_VOLUME_SNAPSHOT_RESTORED(); + + String AuditLogType___GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED(); + String VdcActionType___ActivateVds(); String VdcActionType___RecoveryStoragePool(); @@ -784,6 +804,16 @@ String VdcActionType___RemoveSubnetFromProvider(); + String VdcActionType___DeleteGlusterVolumeSnapshot(); + + String VdcActionType___DeleteAllGlusterVolumeSnapshots(); + + String VdcActionType___ActivateGlusterVolumeSnapshot(); + + String VdcActionType___DeactivateGlusterVolumeSnapshot(); + + String VdcActionType___RestoreGlusterVolumeSnapshot(); + String VdcObjectType___AdElements(); String VdcObjectType___System(); diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 5eb6b4c..327d0c0 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -1118,6 +1118,11 @@ ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_STARTED=Cannot ${action} ${type}. Geo-replication session is already started. ACTION_TYPE_FAILED_GEOREP_SESSION_RESUMED=Cannot ${action} ${type}. Geo-replication session is resumed. ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_PAUSED=Cannot ${action} ${type}. Geo-replication session is paused. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_NAME_IS_EMPTY=Cannot ${action} ${type}. Gluster volume snapshot name is empty. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_DOES_NOT_EXIST=Cannot ${action} ${type}. Snapshot ${snapname} does not exist. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_NO_SNAPSHOTS_EXIST=Cannot ${action} ${type}. No snapshots exist for volume ${volumeName}. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_ACTIVATED=Cannot ${action} ${type}. Snapshot ${snapname} is already activated. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_SNAPSHOT_ALREADY_DEACTIVATED=Cannot ${action} ${type}. Snapshot ${snapname} is already de-activated. ACTION_TYPE_FAILED_TAG_ID_REQUIRED=Cannot ${action} ${type}. Tag ID is required. ACTION_TYPE_FAILED_QOS_CPU_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values are out of range\n(Legal range is: 1-100). -- To view, visit http://gerrit.ovirt.org/37325 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I74fa567e0910a8f97c3d127951481448983e3fd3 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shubhendu Tripathi <shtri...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches