Allon Mureinik has uploaded a new change for review. Change subject: core: Removing a storage connection without a VDS ......................................................................
core: Removing a storage connection without a VDS If a VDS ID is not supplied to the RemoveStorageServerConnectionCommand, it should be possible to remove the connection from the database without disconnecting it from the (non-existent) host. Change-Id: I6ddcf6cb6cd2aed85c23f0e7565ab0b597474a81 Signed-off-by: Allon Mureinik <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommandTest.java 2 files changed, 32 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/17531/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java index 7d21756..461f08f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java @@ -17,12 +17,13 @@ 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.compat.Guid; import org.ovirt.engine.core.dao.StorageServerConnectionDAO; @NonTransactiveCommandAttribute @LockIdNameAttribute -public class RemoveStorageServerConnectionCommand<T extends StorageServerConnectionParametersBase> extends DisconnectStorageServerConnectionCommand { +public class RemoveStorageServerConnectionCommand<T extends StorageServerConnectionParametersBase> extends DisconnectStorageServerConnectionCommand<T> { public RemoveStorageServerConnectionCommand(T parameters) { super(parameters); @@ -106,8 +107,10 @@ protected void executeCommand() { String connectionId = getConnection().getid(); getStorageServerConnectionDao().remove(connectionId); - // disconnect the connection from vdsm - disconnectStorage(); + if (!Guid.isNullOrEmpty(getParameters().getVdsId())) { + // disconnect the connection from vdsm + disconnectStorage(); + } setSucceeded(true); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommandTest.java index 662f649..d904447 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommandTest.java @@ -1,5 +1,6 @@ package org.ovirt.engine.core.bll.storage; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -223,4 +224,29 @@ VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_DISKS); } + @Test + public void checkExecuteCommandWithVdsId() { + parameters.setStorageServerConnection(NFSConnection); + doNothing().when(storageServerConnectionDAO).remove(NFSConnection.getid()); + doReturn(true).when(command).disconnectStorage(); + command.executeCommand(); + } + + @Test + public void checkExecuteCommandWithEmptyVdsId() { + parameters.setStorageServerConnection(NFSConnection); + parameters.setVdsId(Guid.Empty); + doNothing().when(storageServerConnectionDAO).remove(NFSConnection.getid()); + // Test will fail if we try to disconnect + command.executeCommand(); + } + + @Test + public void checkExecuteCommandWithNullVdsId() { + parameters.setStorageServerConnection(NFSConnection); + parameters.setVdsId(null); + doNothing().when(storageServerConnectionDAO).remove(NFSConnection.getid()); + // Test will fail if we try to disconnect + command.executeCommand(); + } } -- To view, visit http://gerrit.ovirt.org/17531 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6ddcf6cb6cd2aed85c23f0e7565ab0b597474a81 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
