Alissa Bonas has uploaded a new change for review. Change subject: core: add check for iqn in addStorageServerConn ......................................................................
core: add check for iqn in addStorageServerConn Add a new validation in canDoACtion that iqn and connection (the adress field) properties are not empty in AddStorageServerConnection in case of iSCSI storage domains. Also added relevant unitests and error messages. Change-Id: Ide54ab2ec4a864dadd01cbe746df6592e32eab2f Signed-off-by: Alissa Bonas <[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/dal/src/main/java/org/ovirt/engine/core/dal/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 M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 7 files changed, 44 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/16/15516/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 b7f59e1..ef846c8 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 @@ -34,6 +34,7 @@ protected void executeCommand() { StorageServerConnections currConnection = getConnection(); boolean isValidConnection = true; + // todo what bout iscsi Pair<Boolean, Integer> result = connect(getVds().getId()); isValidConnection = result.getFirst(); @@ -80,6 +81,10 @@ && (StringUtils.isEmpty(paramConnection.getVfsType()))) { return failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE); } + if (paramConnection.getstorage_type() == StorageType.ISCSI + && (StringUtils.isEmpty(paramConnection.getconnection()) || StringUtils.isEmpty(paramConnection.getiqn()))) { + return failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_IQN_OR_CONN); + } if (getParameters().getVdsId().equals(Guid.Empty)) { if (!InitializeVds()) { 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 747e91d..0719229 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 @@ -35,15 +35,22 @@ private StorageServerConnections createPosixConnection(String connection, StorageType type, String vfsType, String mountOptions) { Guid id = Guid.NewGuid(); - StorageServerConnections connectionDetails = populateBasicConnectionDetails(id, connection, type); + StorageServerConnections connectionDetails = populateBasicConnectionDetails(connection, type); connectionDetails.setVfsType(vfsType); connectionDetails.setMountOptions(mountOptions); return connectionDetails; } - private StorageServerConnections populateBasicConnectionDetails(Guid id, String connection, StorageType type) { + private StorageServerConnections createISCSIConnection(String connection, StorageType type, String iqn, String user, String password) { + StorageServerConnections connectionDetails = populateBasicConnectionDetails(connection, type); + connectionDetails.setiqn(iqn); + connectionDetails.setuser_name(user); + connectionDetails.setpassword(password); + return connectionDetails; + } + + private StorageServerConnections populateBasicConnectionDetails(String connection, StorageType type) { StorageServerConnections connectionDetails = new StorageServerConnections(); - connectionDetails.setid(id.toString()); connectionDetails.setconnection(connection); connectionDetails.setstorage_type(type); return connectionDetails; @@ -68,5 +75,26 @@ CanDoActionTestUtils.runAndAssertCanDoActionSuccess(command); } + @Test + public void addISCSINonEmptyIqn() { + StorageServerConnections newISCSIConnection = createISCSIConnection("10.35.16.25", StorageType.ISCSI,"","user1","mypassword123"); + parameters.setStorageServerConnection(newISCSIConnection); + parameters.setVdsId(Guid.Empty); + parameters.setStoragePoolId(Guid.Empty); + doReturn(true).when(command).InitializeVds(); + CanDoActionTestUtils.runAndAssertCanDoActionFailure(command, + VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_IQN_OR_CONN); + } + + @Test + public void addISCSIEmptyIqn() { + 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); + parameters.setStoragePoolId(Guid.Empty); + doReturn(true).when(command).InitializeVds(); + CanDoActionTestUtils.runAndAssertCanDoActionSuccess(command); + } + } 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 79a8de5..fb9053e 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 @@ -677,6 +677,7 @@ NON_VM_NETWORK_NOT_SUPPORTED_FOR_POOL_LEVEL, VALIDATION_STORAGE_CONNECTION_INVALID, VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE, + VALIDATION_STORAGE_CONNECTION_EMPTY_IQN_OR_CONN, // Gluster Messages ACTION_TYPE_FAILED_CLUSTER_IS_NOT_VALID, 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 fb910b8..ab57098 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -585,6 +585,7 @@ 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_EMPTY_VFSTYPE=VFS type cannot be empty. +VALIDATION_STORAGE_CONNECTION_EMPTY_IQN_OR_CONN=Target details are empty. VALIDATION.TAGS.INVALID_TAG_NAME=Invalid tag name. Only alphanumeric chars, '-' and '_' characters are valid VALIDATION.VM_POOLS.NAME.NOT_NULL=Pool name is required VALIDATION.ROLES.NAME.NOT_NULL=Role name is required 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 a5337dd..19a7fea 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 @@ -2122,6 +2122,10 @@ @DefaultStringValue("VFS type cannot be empty") String VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE(); + @DefaultStringValue("Target details are empty.") + String VALIDATION_STORAGE_CONNECTION_EMPTY_IQN_OR_CONN(); + + @DefaultStringValue("Mount path is illegal, please use [IP:/path or FQDN:/path] convention.") String VALIDATION_STORAGE_CONNECTION_INVALID(); String VMPAYLOAD_INVALID_PAYLOAD_TYPE(); 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 c6ebb37..dba9f9f 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 @@ -584,6 +584,7 @@ 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_EMPTY_VFSTYPE=VFS type cannot be empty. +VALIDATION_STORAGE_CONNECTION_EMPTY_IQN_OR_CONN=Target details are empty. VALIDATION_TAGS_INVALID_TAG_NAME=Invalid tag name. Only alphanumeric chars, '-' and '_' characters are valid VALIDATION_VM_POOLS_NAME_NOT_NULL=Pool name is required VALIDATION_ROLES_NAME_NOT_NULL=Role name is required 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 28a13ec..e9f6b84 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 @@ -590,6 +590,7 @@ 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_EMPTY_VFSTYPE=VFS type cannot be empty. +VALIDATION_STORAGE_CONNECTION_EMPTY_IQN_OR_CONN=Target details are empty. VALIDATION_TAGS_INVALID_TAG_NAME=Invalid tag name. Only alphanumeric chars, '-' and '_' characters are valid VALIDATION_VM_POOLS_NAME_NOT_NULL=Pool name is required VALIDATION_ROLES_NAME_NOT_NULL=Role name is required -- To view, visit http://gerrit.ovirt.org/15516 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ide54ab2ec4a864dadd01cbe746df6592e32eab2f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alissa Bonas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
