Ramesh N has uploaded a new change for review. Change subject: <WIP> engine: BLL Command to Stop Reblance Gluster Volume task ......................................................................
<WIP> engine: BLL Command to Stop Reblance Gluster Volume task BLL Command to Stop Reblance Gluster Volume task. It will clear the task details in the Gluster Volume also set the job status to Aborted. Change-Id: I0e7cf0eb4de160dc309f2699ba0e224f48dd1f49 Signed-off-by: Ramesh Nachimuthu <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StopRebalanceGlusterVolumeCommand.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/action/VdcActionType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/StepEnum.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 9 files changed, 121 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/45/18445/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StopRebalanceGlusterVolumeCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StopRebalanceGlusterVolumeCommand.java new file mode 100644 index 0000000..70961d6 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/StopRebalanceGlusterVolumeCommand.java @@ -0,0 +1,107 @@ +package org.ovirt.engine.core.bll.gluster; + +import org.ovirt.engine.core.bll.Backend; +import org.ovirt.engine.core.bll.LockIdNameAttribute; +import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute; +import org.ovirt.engine.core.bll.job.ExecutionHandler; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.gluster.GlusterVolumeRebalanceParameters; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.job.JobExecutionStatus; +import org.ovirt.engine.core.common.job.Step; +import org.ovirt.engine.core.common.job.StepEnum; +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.DaoFactory; +import org.ovirt.engine.core.dao.JobDao; +import org.ovirt.engine.core.dao.StepDao; + +/** + * BLL command to Stop the active Rebalancing on a Gluster volume. + */ + +@NonTransactiveCommandAttribute +@LockIdNameAttribute(isReleaseAtEndOfExecute=false) +public class StopRebalanceGlusterVolumeCommand extends GlusterAsyncCommandBase<GlusterVolumeRebalanceParameters>{ + + + public StopRebalanceGlusterVolumeCommand(GlusterVolumeRebalanceParameters params) { + super(params); + } + + @Override + protected void setActionMessageParameters() { + addCanDoActionMessage(VdcBllMessages.VAR__TYPE__GLUSTER_VOLUME); + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REBALANCE_STOP); + } + + @Override + protected boolean canDoAction() { + GlusterVolumeEntity glusterVolume = getGlusterVolume(); + if (!super.canDoAction()) { + return false; + } + + if (!glusterVolume.isOnline()) { + addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_SHOULD_BE_STARTED); + return false; + } + + if (glusterVolume.getAsyncTask() == null || glusterVolume.getAsyncTask().getStatus() != JobExecutionStatus.STARTED) { + addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_REBALANCE_NOT_STARTED); + return false; + } + return true; + } + + @Override + public boolean isInternalExecution() { + return true; + } + @Override + protected StepEnum getStepType() { + return StepEnum.STOP_REBALANCING_GLUSTER_VOLUME; + } + + @Override + protected void executeCommand() { + startSubStep(); + VDSReturnValue vdsReturnaValue = Backend.getInstance().getResourceManager() + .RunVdsCommand(VDSCommandType.StopRebalanceGlusterVolume, + new GlusterVolumeVDSParameters(upServer.getId(), + getGlusterVolumeName())); + setSucceeded(vdsReturnaValue.getSucceeded()); + if (!getSucceeded()) { + handleVdsError(AuditLogType.GLUSTER_VOLUME_REBALANCE_STOP_FAILED, vdsReturnaValue.getVdsError().getMessage()); + return; + } + + Step step = DaoFactory.get(StepDao.class).get((getGlusterVolume().getAsyncTask().getStepId())); + step.setStatus(JobExecutionStatus.ABORTED); + DaoFactory.get(JobDao.class).get(step.getJobId()).setStatus(JobExecutionStatus.ABORTED); + ExecutionHandler.endTaskStep(getGlusterVolume().getAsyncTask().getStepId(), JobExecutionStatus.ABORTED); +// GlusterAsyncTask glusterTask = (GlusterAsyncTask)taskReturn.getReturnValue(); +// handleTaskReturn(glusterTask); + clearVolumeTask(); + getReturnValue().setActionReturnValue(vdsReturnaValue); +// + } + + private void clearVolumeTask() { + getGlusterVolumeDao().updateVolumeTask(getGlusterVolumeId(), Guid.Empty); + } + + + @Override + public AuditLogType getAuditLogTypeValue() { + if (getSucceeded()) { + return AuditLogType.GLUSTER_VOLUME_REBALANCE_STOP; + } else { + return errorType == null ? AuditLogType.GLUSTER_VOLUME_REBALANCE_STOP_FAILED : errorType; + } + } + +} 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 e22f1bc..e10c168 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 @@ -282,6 +282,8 @@ GLUSTER_HOST_UUID_NOT_FOUND(4075), GLUSTER_VOLUME_BRICK_ADDED(4076), GLUSTER_CLUSTER_SERVICE_STATUS_ADDED(4077), + GLUSTER_VOLUME_REBALANCE_STOP(4078), + GLUSTER_VOLUME_REBALANCE_STOP_FAILED(4079), USER_FORCE_SELECTED_SPM(159), USER_VDS_RESTART(41), 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 0eb69d1..90e3aae 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 @@ -258,6 +258,7 @@ RemoveGlusterHook(1418,ActionGroup.MANIPULATE_GLUSTER_HOOK,QuotaDependency.NONE), RefreshGlusterHooks(1419, ActionGroup.MANIPULATE_GLUSTER_HOOK, QuotaDependency.NONE), ManageGlusterService(1420, ActionGroup.MANIPULATE_GLUSTER_SERVICE, QuotaDependency.NONE), + StopRebalanceGlusterVolume(1421, ActionGroup.MANIPULATE_GLUSTER_VOLUME,false, QuotaDependency.NONE), // Cluster Policy AddClusterPolicy(1450, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, QuotaDependency.NONE), EditClusterPolicy(1451, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, QuotaDependency.NONE), 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 4237462..c940738 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 @@ -82,6 +82,7 @@ VAR__ACTION__LOGON, VAR__ACTION__LOGOFF, VAR__ACTION__REBALANCE_START, + VAR__ACTION__REBALANCE_STOP, VAR__ACTION__ASSIGN, VAR__ACTION__START_PROFILE, VAR__ACTION__STOP_PROFILE, @@ -707,6 +708,7 @@ ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_UP(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GLUSTER_VOLUME_SHOULD_BE_STARTED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GLUSTER_VOLUME_BRICKS_ARE_NOT_DISTRIBUTED(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_GLUSTER_VOLUME_REBALANCE_NOT_STARTED(ErrorType.CONFLICT), ACTION_TYPE_FAILED_GLUSTER_VOLUME_IS_DOWN(ErrorType.CONFLICT), ACTION_TYPE_FAILED_NOT_A_GLUSTER_VOLUME_BRICK(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_CAN_NOT_REMOVE_ALL_BRICKS_FROM_VOLUME(ErrorType.CONFLICT), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/StepEnum.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/StepEnum.java index 6f9a6b5..56ba39d 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/StepEnum.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/StepEnum.java @@ -19,10 +19,10 @@ CREATING_SNAPSHOTS, RUN_STATELESS_VM, TAKING_VM_FROM_POOL, - // Gluster SETTING_GLUSTER_OPTION, REBALANCING_VOLUME, + STOP_REBALANCING_GLUSTER_VOLUME, /** * Maps VDSM tasks type to {@code StepEnum} so it can be resolvable as readable description 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 426a871..8b8a182 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -293,6 +293,7 @@ VAR__ACTION__LOGOFF=$action log off VAR__ACTION__ASSIGN=$action assign VAR__ACTION__REBALANCE_START=$action rebalance +VAR__ACTION__REBALANCE_STOP=$action stop rebalance VAR__ACTION__START_PROFILE=$action start profiling VAR__ACTION__STOP_PROFILE=$action stop profiling VAR__ACTION__ENABLE=$action enable @@ -940,6 +941,7 @@ ACTION_TYPE_FAILED_SERVICE_ALREADY_RUNNING=Cannot ${action} ${type}. Service ${service} is already running on server ${server}. ACTION_TYEPE_FAILED_SERVICE_ALREADY_STOPPED=Cannot ${action} ${type}. Service ${service} already stopped on Server ${server}. ACTION_TYPE_FAILED_VOLUME_OPERATION_IN_PROGRESS=Cannot ${action} ${type}. A task is in progress on the volume ${volumeName} in cluster ${vdsGroup}. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_REBALANCE_NOT_STARTED=Cannot ${action} ${type}. Volume Rebalance is not running on the volume ${volumeName} in cluster ${vdsGroup}. ACTION_TYPE_FAILED_NETWORK_QOS_MISSING_VALUES=Cannot ${action} ${type}. All three values are needed in order to define QoS on each network directions. ACTION_TYPE_FAILED_NETWORK_QOS_NEGATIVE_VALUES=Cannot ${action} ${type}. Negative values are not allowed. ACTION_TYPE_FAILED_NETWORK_QOS_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values are out of range. diff --git a/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties b/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties index 1ebced3..ecf1b0b 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties @@ -132,7 +132,7 @@ # Gluster step types step.SETTING_GLUSTER_OPTION=Setting option ${Key}=${Value} on volume ${GlusterVolume} of cluster ${Cluster} step.REBALANCING_VOLUME=Rebalancing ${GlusterVolume} volume of ${Cluster}.( ${Status} ${info}) - +step.STOP_REBALANCING_GLUSTER_VOLUME= Stopping the Rebalancing operation on ${GlusterVolume} volume of ${Cluster}. # Non-monitored job: job.AddVmInterface=Adding Network Interface ${InterfaceName} to VM ${VM} job.RemoveVmInterface=Removing Network Interface ${InterfaceName} from VM ${VM} 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 4beb810..b6ca3ab 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 @@ -2450,6 +2450,9 @@ @DefaultStringValue("Cannot ${action} ${type}. A task is in progress on the volume ${volumeName} in cluster ${vdsGroup}.") String ACTION_TYPE_FAILED_VOLUME_OPERATION_IN_PROGRESS(); + @DefaultStringValue("Cannot ${action} ${type}. Volume Rebalance is not running on the volume ${volumeName} in cluster ${vdsGroup}.") + String ACTION_TYPE_FAILED_GLUSTER_VOLUME_REBALANCE_NOT_STARTED(); + @DefaultStringValue("Cannot ${action} ${type}. The Network Interface ${IfaceName} has an invalid MAC address ${MacAddress}. MAC address must be in format \"HH:HH:HH:HH:HH:HH\" where H is a hexadecimal character (either a digit or A-F, case is insignificant).") String ACTION_TYPE_FAILED_NETWORK_INTERFACE_MAC_INVALID(); 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 e342f9d..8c90eff 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 @@ -296,6 +296,7 @@ VAR__ACTION__LOGON=$action log on VAR__ACTION__LOGOFF=$action log off VAR__ACTION__REBALANCE_START=$action rebalance +VAR__ACTION__REBALANCE_STOP=$action stop rebalance VAR__ACTION__START_PROFILE=$action start profiling VAR__ACTION__STOP_PROFILE=$action stop profiling VAR__ACTION__ASSIGN=$action assign @@ -919,6 +920,7 @@ ACTION_TYEPE_FAILED_SERVICE_ALREADY_STOPPED=Cannot ${action} ${type}. Service ${service} already stopped on Server ${server}. CLUSTER_ALL_SERVERS_NOT_UP=One or more servers in the cluster is down ACTION_TYPE_FAILED_VOLUME_OPERATION_IN_PROGRESS=Cannot ${action} ${type}. A task is in progress on the volume ${volumeName} in cluster ${vdsGroup}. +ACTION_TYPE_FAILED_GLUSTER_VOLUME_REBALANCE_NOT_STARTED=Cannot ${action} ${type}. Volume Rebalance is not running on the volume ${volumeName} in cluster ${vdsGroup}. ACTION_TYPE_FAILED_NETWORK_QOS_MISSING_VALUES=Cannot ${action} ${type}. All three values are needed in order to define QoS on each network directions. ACTION_TYPE_FAILED_NETWORK_QOS_NEGATIVE_VALUES=Cannot ${action} ${type}. Negative values are not allowed. ACTION_TYPE_FAILED_NETWORK_QOS_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values are out of range. -- To view, visit http://gerrit.ovirt.org/18445 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0e7cf0eb4de160dc309f2699ba0e224f48dd1f49 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ramesh N <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
