Dhandapani Gopal has uploaded a new change for review. Change subject: engine: Gluster Peer Detach bll command ......................................................................
engine: Gluster Peer Detach bll command Includes following related to the command for "gluster peer detach" - New Bll Command - Audit Log Messages and Severities - App Errors - VDSM Errors - Junit test class - Execution Messages Change-Id: I171f1b6eb9d01f1ffb2b4a0be52a15887f534c2d Signed-off-by: Dhandapani <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterHostRemoveCommand.java A backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterHostRemoveCommandTest.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 A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterHostRemoveParameters.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.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/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java M frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties 13 files changed, 188 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/44/9044/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterHostRemoveCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterHostRemoveCommand.java new file mode 100644 index 0000000..9db8ac0 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterHostRemoveCommand.java @@ -0,0 +1,62 @@ +package org.ovirt.engine.core.bll.gluster; + +import org.apache.commons.lang.StringUtils; +import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.gluster.GlusterHostRemoveParameters; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; +import org.ovirt.engine.core.common.vdscommands.gluster.GlusterHostRemoveVDSParameters; +import org.ovirt.engine.core.dal.VdcBllMessages; + +/** + * BLL command for gluster peer detach + */ +@NonTransactiveCommandAttribute +public class GlusterHostRemoveCommand extends GlusterCommandBase<GlusterHostRemoveParameters> { + + private static final long serialVersionUID = -3658615659129620366L; + + public GlusterHostRemoveCommand(GlusterHostRemoveParameters params) { + super(params); + } + + @Override + protected void setActionMessageParameters() { + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE); + addCanDoActionMessage(VdcBllMessages.VAR__TYPE__GLUSTER_HOST); + } + + @Override + protected boolean canDoAction() { + super.canDoAction(); + if (StringUtils.isEmpty(getParameters().getHostName())) { + addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_HOSTNAME_REQUIRED); + return false; + } + return true; + } + + @Override + protected void executeCommand() { + VDSReturnValue returnValue = + runVdsCommand(VDSCommandType.GlusterHostRemove, + new GlusterHostRemoveVDSParameters(upServer.getId(), + getParameters().getHostName(), + getParameters().isForceAction())); + setSucceeded(returnValue.getSucceeded()); + if (!getSucceeded()) { + handleVdsError(AuditLogType.GLUSTER_HOST_REMOVE_FAILED, returnValue.getVdsError().getMessage()); + } + } + + @Override + public AuditLogType getAuditLogTypeValue() { + if (getSucceeded()) { + return AuditLogType.GLUSTER_HOST_REMOVE; + } else { + return AuditLogType.GLUSTER_HOST_REMOVE_FAILED; + } + } + +} diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterHostRemoveCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterHostRemoveCommandTest.java new file mode 100644 index 0000000..911a93a --- /dev/null +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterHostRemoveCommandTest.java @@ -0,0 +1,58 @@ +package org.ovirt.engine.core.bll.gluster; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; +import org.ovirt.engine.core.common.action.gluster.GlusterHostRemoveParameters; +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSStatus; +import org.ovirt.engine.core.compat.Guid; + +@RunWith(MockitoJUnitRunner.class) +public class GlusterHostRemoveCommandTest { + + private static final Guid CLUSTER_ID = new Guid("b399944a-81ab-4ec5-8266-e19ba7c3c9d1"); + private static final String SERVER_NAME = "server1"; + + // The command under test. + private GlusterHostRemoveCommand cmd; + + private void prepareMocks(GlusterHostRemoveCommand command) { + doReturn(getVds(VDSStatus.Up)).when(command).getUpServer(); + } + + private VDS getVds(VDSStatus status) { + VDS vds = new VDS(); + vds.setId(Guid.NewGuid()); + vds.setvds_name("gfs1"); + vds.setvds_group_id(CLUSTER_ID); + vds.setstatus(status); + return vds; + } + + @Test + public void canDoActionSucceeds() { + cmd = spy(new GlusterHostRemoveCommand(new GlusterHostRemoveParameters(SERVER_NAME, false))); + prepareMocks(cmd); + assertTrue(cmd.canDoAction()); + } + + @Test + public void canDoActionSucceedsWithForceAction() { + cmd = spy(new GlusterHostRemoveCommand(new GlusterHostRemoveParameters(SERVER_NAME, true))); + prepareMocks(cmd); + assertTrue(cmd.canDoAction()); + } + + @Test + public void canDoActionFailsOnNull() { + cmd = spy(new GlusterHostRemoveCommand(new GlusterHostRemoveParameters(null, false))); + prepareMocks(cmd); + assertFalse(cmd.canDoAction()); + } +} 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 e3f23d4..9f96c3f 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 @@ -208,23 +208,24 @@ GLUSTER_VOLUME_REPLACE_BRICK_START_FAILED(4018), GLUSTER_VOLUME_ADD_BRICK(4019), GLUSTER_VOLUME_ADD_BRICK_FAILED(4020), - GLUSTER_HOST_REMOVE_FAILED(4021), - GLUSTER_VOLUME_PROFILE_START(4022), - GLUSTER_VOLUME_PROFILE_START_FAILED(4023), - GLUSTER_VOLUME_PROFILE_STOP(4024), - GLUSTER_VOLUME_PROFILE_STOP_FAILED(4025), - GLUSTER_VOLUME_CREATED_FROM_CLI(4026), - GLUSTER_VOLUME_DELETED_FROM_CLI(4027), - GLUSTER_VOLUME_OPTION_SET_FROM_CLI(4028), - GLUSTER_VOLUME_OPTION_RESET_FROM_CLI(4029), - GLUSTER_VOLUME_PROPERTIES_CHANGED_FROM_CLI(4030), - GLUSTER_VOLUME_BRICK_ADDED_FROM_CLI(4031), - GLUSTER_VOLUME_BRICK_REMOVED_FROM_CLI(4032), - GLUSTER_SERVER_REMOVED_FROM_CLI(4033), - GLUSTER_VOLUME_INFO_FAILED(4034), - GLUSTER_COMMAND_FAILED(4035), - GLUSTER_HOST_ADD_FAILED(4436), - GLUSTER_SERVERS_LIST_FAILED(4437), + GLUSTER_HOST_REMOVE(4021), + GLUSTER_HOST_REMOVE_FAILED(4022), + GLUSTER_VOLUME_PROFILE_START(4023), + GLUSTER_VOLUME_PROFILE_START_FAILED(4024), + GLUSTER_VOLUME_PROFILE_STOP(4025), + GLUSTER_VOLUME_PROFILE_STOP_FAILED(4026), + GLUSTER_VOLUME_CREATED_FROM_CLI(4027), + GLUSTER_VOLUME_DELETED_FROM_CLI(4028), + GLUSTER_VOLUME_OPTION_SET_FROM_CLI(4029), + GLUSTER_VOLUME_OPTION_RESET_FROM_CLI(4030), + GLUSTER_VOLUME_PROPERTIES_CHANGED_FROM_CLI(4031), + GLUSTER_VOLUME_BRICK_ADDED_FROM_CLI(4032), + GLUSTER_VOLUME_BRICK_REMOVED_FROM_CLI(4033), + GLUSTER_SERVER_REMOVED_FROM_CLI(4034), + GLUSTER_VOLUME_INFO_FAILED(4035), + GLUSTER_COMMAND_FAILED(4036), + GLUSTER_HOST_ADD_FAILED(4437), + GLUSTER_SERVERS_LIST_FAILED(4438), USER_VDS_RESTART(41), USER_FAILED_VDS_RESTART(107), 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 db122d0..58c250a 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 @@ -57,6 +57,7 @@ AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_REPLACE_BRICK_START); AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_REPLACE_BRICK_START_FAILED); AddEventNotificationEntry(EventNotificationEntity.Host, AuditLogType.GLUSTER_HOST_ADD_FAILED); + AddEventNotificationEntry(EventNotificationEntity.Host, AuditLogType.GLUSTER_HOST_REMOVE); AddEventNotificationEntry(EventNotificationEntity.Host, AuditLogType.GLUSTER_HOST_REMOVE_FAILED); AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_PROFILE_START); AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_PROFILE_START_FAILED); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterHostRemoveParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterHostRemoveParameters.java new file mode 100644 index 0000000..cef3e54 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/GlusterHostRemoveParameters.java @@ -0,0 +1,36 @@ +package org.ovirt.engine.core.common.action.gluster; + +import org.ovirt.engine.core.common.action.VdcActionParametersBase; + +/** + * Parameter class with hostname and forceAction as parameters. <br> + * This will be used by gluster host remove command. <br> + */ +public class GlusterHostRemoveParameters extends VdcActionParametersBase { + private static final long serialVersionUID = -1224829720081853632L; + + private String hostName; + private boolean forceAction; + + public GlusterHostRemoveParameters(String hostName, boolean forceAction) { + setHostName(hostName); + setForceAction(forceAction); + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public void setForceAction(boolean forceAction) { + this.forceAction = forceAction; + } + + public boolean isForceAction() { + return forceAction; + } + +} diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java index 4c6e7f9..9dd0b71 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java @@ -25,6 +25,7 @@ VAR__TYPE__GLUSTER_VOLUME, VAR__TYPE__GLUSTER_VOLUME_OPTION, VAR__TYPE__GLUSTER_BRICK, + VAR__TYPE__GLUSTER_HOST, VAR__ACTION__RUN, VAR__ACTION__REMOVE, @@ -663,6 +664,7 @@ VDS_CANNOT_REMOVE_HOST_HAVING_GLUSTER_VOLUME, ACTION_TYPE_FAILED_NO_GLUSTER_HOST_TO_PEER_PROBE, MIGRATE_PAUSED_VM_IS_UNSUPPORTED, + ACTION_TYPE_FAILED_HOSTNAME_REQUIRED, VM_INTERFACE_NOT_EXIST, ACTION_TYPE_FAILED_CANNOT_REMOVE_ACTIVE_DEVICE, diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java index a56cb5d..a8f001c 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java @@ -77,6 +77,7 @@ mSeverities.put(AuditLogType.GLUSTER_VOLUME_ADD_BRICK, AuditLogSeverity.NORMAL); mSeverities.put(AuditLogType.GLUSTER_VOLUME_ADD_BRICK_FAILED, AuditLogSeverity.ERROR); mSeverities.put(AuditLogType.GLUSTER_HOST_ADD_FAILED, AuditLogSeverity.ERROR); + mSeverities.put(AuditLogType.GLUSTER_HOST_REMOVE, AuditLogSeverity.NORMAL); mSeverities.put(AuditLogType.GLUSTER_HOST_REMOVE_FAILED, AuditLogSeverity.ERROR); mSeverities.put(AuditLogType.GLUSTER_VOLUME_REPLACE_BRICK_FAILED, AuditLogSeverity.ERROR); mSeverities.put(AuditLogType.GLUSTER_VOLUME_REPLACE_BRICK_START, AuditLogSeverity.NORMAL); 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 0052a4f..eaae3fa 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -741,6 +741,7 @@ VAR__TYPE__GLUSTER_VOLUME=$type Gluster Volume VAR__TYPE__GLUSTER_VOLUME_OPTION=$type Gluster Volume Option VAR__TYPE__GLUSTER_BRICK=$type Gluster Brick +VAR__TYPE__GLUSTER_HOST=$type Gluster Host VALIDATION.GLUSTER.VOLUME.ID.NOT_NULL=Volume ID is required. VALIDATION.GLUSTER.VOLUME.CLUSTER_ID.NOT_NULL=Cluster ID is required. VALIDATION.GLUSTER.VOLUME.NAME.NOT_NULL=Volume Name is required. @@ -802,3 +803,4 @@ VDS_GROUP_ENABLING_BOTH_VIRT_AND_GLUSTER_SERVICES_NOT_ALLOWED=Cannot ${action} ${type}. Enabling both Virt and Gluster services is not allowed. ENGINE_IS_RUNNING_IN_MAINTENANCE_MODE=Engine is running in Maintenance mode and is not accepting commands. ENGINE_IS_RUNNING_IN_PREPARE_MODE=This action is not allowed when Engine is preparing for maintenance. +ACTION_TYPE_FAILED_HOSTNAME_REQUIRED=Cannot ${action} ${type}. Host Name 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 7495aa9..56983da 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -554,6 +554,7 @@ GLUSTER_VOLUME_REPLACE_BRICK_START=Gluster Volume ${glusterVolumeName} Replace Brick started. GLUSTER_VOLUME_REPLACE_BRICK_START_FAILED=Could not start Gluster Volume ${glusterVolumeName} Replace Brick. GLUSTER_HOST_ADD_FAILED=Failed to add gluster server ${VdsName} into Cluster ${VdsGroupName}. +GLUSTER_HOST_REMOVE=Gluster server ${VdsName} removed from Cluster ${VdsGroupName}. GLUSTER_HOST_REMOVE_FAILED=Failed to remove gluster server ${VdsName} from Cluster ${VdsGroupName}. GLUSTER_SERVERS_LIST_FAILED=Failed to fetch gluster peer list from server ${VdsName} on Cluster ${VdsGroupName}. HA_VM_FAILED=Highly Available VM ${VmName} failed. It will be restarted automatically. 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 9385fb6..d223bf4 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties @@ -73,6 +73,7 @@ job.MoveDisk=Moving Disk from ${SourceSD} to ${TargetSD} job.StartGlusterVolumeProfile=Start Profiling on Gluster Volume ${GlusterVolume} job.StopGlusterVolumeProfile=Stop Profiling on Gluster Volume ${GlusterVolume} +job.GlusterHostRemove=Removing Gluster Server ${VDS} # Step types step.VALIDATING=Validating 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 6f8de4b..5d97f43 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 @@ -730,6 +730,9 @@ @DefaultStringValue("$type Gluster Brick") String VAR__TYPE__GLUSTER_BRICK(); + @DefaultStringValue("$type Gluster Host") + String VAR__TYPE__GLUSTER_HOST(); + @DefaultStringValue("Cannot ${action} ${type}. The chosen disk drive letter is already in use, please select a free one.") String ACTION_TYPE_FAILED_DISK_LETTER_ALREADY_IN_USE(); 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 ab177f2..a32274f 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 @@ -236,6 +236,8 @@ String AuditLogType___GLUSTER_HOST_ADD_FAILED(); + String AuditLogType___GLUSTER_HOST_REMOVE(); + String AuditLogType___GLUSTER_HOST_REMOVE_FAILED(); String AuditLogType___GLUSTER_VOLUME_PROFILE_START(); diff --git a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties index 038aafa..1af2746 100644 --- a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties +++ b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties @@ -114,6 +114,7 @@ AuditLogType___GLUSTER_VOLUME_REPLACE_BRICK_START=Gluster Volume Replace Brick Started AuditLogType___GLUSTER_VOLUME_REPLACE_BRICK_START_FAILED=Gluster Volume Replace Brick could not be started AuditLogType___GLUSTER_HOST_ADD_FAILED=Failed to Add Gluster Server +AuditLogType___GLUSTER_HOST_REMOVE=Gluster Server Removed AuditLogType___GLUSTER_HOST_REMOVE_FAILED=Failed to Remove Gluster Server AuditLogType___GLUSTER_VOLUME_PROFILE_START=Gluster Volume Profile started AuditLogType___GLUSTER_VOLUME_PROFILE_START_FAILED=Failed to start Gluster Volume Profile -- To view, visit http://gerrit.ovirt.org/9044 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I171f1b6eb9d01f1ffb2b4a0be52a15887f534c2d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Dhandapani Gopal <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
