Ravi Nori has uploaded a new change for review. Change subject: engine : creating storage connection with empty port, port is set to 0 ......................................................................
engine : creating storage connection with empty port, port is set to 0 When creating a storage connection if an empty port is passed the value is set to 0. A new validation has been added to canDoAction that verifies that the port is greater than zero. Change-Id: Ief68a9b65946d88e3eace6f21fc887ea373725b1 Bug-Url: https://bugzilla.redhat.com/1006449 Signed-off-by: Ravi Nori <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommandTest.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 frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 6 files changed, 39 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/02/24402/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java index 8ab799f..6d9b767 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommand.java @@ -88,6 +88,12 @@ return failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_IQN); } + if (paramConnection.getstorage_type() == StorageType.ISCSI + && (StringUtils.isEmpty(paramConnection.getport()) + || Integer.parseInt(paramConnection.getport()) <= 0)) { + return failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_INVALID_PORT); + } + if (checkIsConnectionFieldEmpty(paramConnection)) { return false; } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommandTest.java index 398a979..42609c5 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddStorageServerConnectionCommandTest.java @@ -66,10 +66,12 @@ private StorageServerConnections createISCSIConnection(String connection, StorageType type, String iqn, + String port, String user, String password) { StorageServerConnections connectionDetails = populateBasicConnectionDetails(connection, type); connectionDetails.setiqn(iqn); + connectionDetails.setport(port); connectionDetails.setuser_name(user); connectionDetails.setpassword(password); return connectionDetails; @@ -110,11 +112,31 @@ @Test public void addISCSIEmptyIqn() { StorageServerConnections newISCSIConnection = - createISCSIConnection("10.35.16.25", StorageType.ISCSI, "", "user1", "mypassword123"); + createISCSIConnection("10.35.16.25", StorageType.ISCSI, "", "3650", "user1", "mypassword123"); parameters.setStorageServerConnection(newISCSIConnection); parameters.setVdsId(Guid.Empty); CanDoActionTestUtils.runAndAssertCanDoActionFailure(command, VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_IQN); + } + + @Test + public void addISCSIEmptyPort() { + StorageServerConnections newISCSIConnection = + createISCSIConnection("10.35.16.25", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "", "user1", "mypassword123"); + parameters.setStorageServerConnection(newISCSIConnection); + parameters.setVdsId(Guid.Empty); + CanDoActionTestUtils.runAndAssertCanDoActionFailure(command, + VdcBllMessages.VALIDATION_STORAGE_CONNECTION_INVALID_PORT); + } + + @Test + public void addISCSIInvalidPort() { + StorageServerConnections newISCSIConnection = + createISCSIConnection("10.35.16.25", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "-3650", "user1", "mypassword123"); + parameters.setStorageServerConnection(newISCSIConnection); + parameters.setVdsId(Guid.Empty); + CanDoActionTestUtils.runAndAssertCanDoActionFailure(command, + VdcBllMessages.VALIDATION_STORAGE_CONNECTION_INVALID_PORT); } @Test @@ -123,6 +145,7 @@ createISCSIConnection("10.35.16.25", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", + "3650", "user1", "mypassword123"); parameters.setStorageServerConnection(newISCSIConnection); @@ -231,6 +254,7 @@ createISCSIConnection("", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", + "3650", "user1", "mypassword123"); parameters.setStorageServerConnection(newISCSIConnection); @@ -241,8 +265,8 @@ @Test public void isConnWithSameDetailsExist() { - StorageServerConnections newISCSIConnection = createISCSIConnection("1.2.3.4", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "user1", "mypassword123"); - StorageServerConnections existingConn = createISCSIConnection("1.2.3.4", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "user1", "mypassword123"); + StorageServerConnections newISCSIConnection = createISCSIConnection("1.2.3.4", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "3650", "user1", "mypassword123"); + StorageServerConnections existingConn = createISCSIConnection("1.2.3.4", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "3650", "user1", "mypassword123"); existingConn.setid(Guid.newGuid().toString()); List<StorageServerConnections> connections = new ArrayList<>(); 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 d942e50..4a72f40 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 @@ -757,6 +757,7 @@ ACTION_TYPE_FAILED_CANNOT_RESIZE_DISK_SNAPSHOT(ErrorType.CONFLICT), NON_VM_NETWORK_NOT_SUPPORTED_FOR_POOL_LEVEL(ErrorType.NOT_SUPPORTED), VALIDATION_STORAGE_CONNECTION_INVALID(ErrorType.BAD_PARAMETERS), + VALIDATION_STORAGE_CONNECTION_INVALID_PORT(ErrorType.BAD_PARAMETERS), VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE(ErrorType.BAD_PARAMETERS), VALIDATION_STORAGE_CONNECTION_EMPTY_IQN(ErrorType.BAD_PARAMETERS), VALIDATION_STORAGE_CONNECTION_EMPTY_CONNECTION(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 5ee8d23..1c14677 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -725,6 +725,7 @@ NETWORK_ILEGAL_NETWORK_NAME=Network name must be 1-15 long and can contain only 'A-Z', 'a-z', '0-9', '_' characters STORAGE_OPERATION_FAILED_SPM_NETWORK_PROBLEMS=Storage related operations can't be performed while the Storage Pool Manager is down.\nPlease make sure the Storage Pool Manager is up and running, and check network connectivity. VALIDATION_STORAGE_CONNECTION_INVALID=Mount path is illegal, please use [IP:/path or FQDN:/path] convention. +VALIDATION_STORAGE_CONNECTION_INVALID_PORT=Invalid value for port. Port should be greater than 0. VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE=VFS type cannot be empty. VALIDATION_STORAGE_CONNECTION_EMPTY_IQN=Target details cannot be empty. VALIDATION_STORAGE_CONNECTION_EMPTY_CONNECTION=${fieldName} field cannot be empty. 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 a8c0de8..5d0bcd2 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 @@ -2595,6 +2595,9 @@ @DefaultStringValue("Mount path is illegal, please use [IP:/path or FQDN:/path] convention.") String VALIDATION_STORAGE_CONNECTION_INVALID(); + @DefaultStringValue("Invalid value for port. Port should be greater than 0.") + String VALIDATION_STORAGE_CONNECTION_INVALID_PORT(); + @DefaultStringValue("NFS Retransmissions should be between 0 and 32767") String VALIDATION_STORAGE_CONNECTION_NFS_RETRANS(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 13932f1..2589577 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -706,6 +706,7 @@ NETWORK_ILEGAL_NETWORK_NAME=Network name must be 1-15 long and can contain only 'A-Z', 'a-z', '0-9', '_' characters STORAGE_OPERATION_FAILED_SPM_NETWORK_PROBLEMS=Storage related operations can't be performed while the Storage Pool Manager is down.\nPlease make sure the Storage Pool Manager is up and running, and check network connectivity. VALIDATION_STORAGE_CONNECTION_INVALID=Mount path is illegal, please use [IP:/path or FQDN:/path] convention. +VALIDATION_STORAGE_CONNECTION_INVALID_PORT=Invalid value for port. Port should be greater than 0. VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE=VFS type cannot be empty. VALIDATION_STORAGE_CONNECTION_EMPTY_IQN=Target details cannot be empty. VALIDATION_STORAGE_CONNECTION_EMPTY_CONNECTION=${fieldName} field cannot be empty. -- To view, visit http://gerrit.ovirt.org/24402 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ief68a9b65946d88e3eace6f21fc887ea373725b1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ravi Nori <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
