Discussion:
[Libstoragemgmt-devel] [PATCH 0/6] Pending changes
Tony Asleson
2014-08-13 23:22:11 UTC
Permalink
Complete patch stack for Gris.

Thanks,
Tony

Tony Asleson (6):
C & PY API: Clean-up error number constants
tester.c: Fix hang and FS space exhaustion
tester.c: Add tests for initiator id verification.
C API & PY: Initiator verification.
C & PY API: Document errors codes and add more checks
Client example from wiki

.../include/libstoragemgmt/libstoragemgmt_common.h | 10 +-
.../include/libstoragemgmt/libstoragemgmt_error.h | 65 ++---
c_binding/lsm_datatypes.cpp | 228 ++++++++++++-----
c_binding/lsm_datatypes.hpp | 22 ++
c_binding/lsm_mgmt.cpp | 279 ++++++++++-----------
c_binding/lsm_plugin_ipc.cpp | 18 +-
examples/client_example.c | 76 ++++++
plugin/nstor/nstor.py | 8 +-
plugin/ontap/na.py | 4 +-
plugin/ontap/ontap.py | 30 +--
plugin/sim/simarray.py | 76 +++---
plugin/simc/simc_lsmplugin.c | 26 +-
plugin/smispy/smis.py | 59 +++--
plugin/targetd/targetd.py | 10 +-
python_binding/lsm/_client.py | 8 +-
python_binding/lsm/_common.py | 73 ++----
python_binding/lsm/_data.py | 97 ++++---
python_binding/lsm/_pluginrunner.py | 2 +-
python_binding/lsm/_transport.py | 15 +-
test/tester.c | 265 ++++++++++++++-----
tools/lsmcli/cmdline.py | 10 +-
21 files changed, 826 insertions(+), 555 deletions(-)
create mode 100644 examples/client_example.c
--
1.8.2.1
Tony Asleson
2014-08-13 23:22:15 UTC
Permalink
C additions and python changes to support initiator
validation. I changes the iqn validation to only
check the first 3 characters 'iqn|eui|naa'. The
WWPN allows the same permutations and combinations
as Gris's original patch, but allows both the command
line and the plug-ins to use any of these different formats
when supplying initiators to the library. In both cases
the library will re-format to the internal representation
which is nn:nn:nn:nn:nn:nn:nn:nn.

Plugins that take the wwpn and need it in another format will
need to convert to what ever format they require.

To ensure that this is consistently done, when creating an instance
of an access group the C and the Python code will convert the
initiator list automatically. If the list contains invalid initiator
addresses the python code will raise an exception and the C code will
return NULL on the new record create. The ambiguity in the C API
can be avoided if the caller validates their initiator id(s) before
creating a new access group record.

Both C and Python API have a single new public function added which
can be used to verify an initiator id.

Python:
def initiator_id_verify(init_id, init_type=None, raise_exception=False):
"""
Public method which can be used to verify an initiator id
:param init_id:
:param init_type:
:param raise_exception: Will throw a LsmError INVALID_ARGUMENT if
not a valid initiator address
:return:(Bool, init_type, init_id) Note: init_id will be returned in
normalized format if it's a WWPN
"""
C:
/**
* Checks to see if initiator id is valid
* @param init_id Initiator value
* @param init_type Type of initiator id, will get modified
* to determined if type passed in is UNKNOWN
* @return LSM_ERR_OK if initiator id is OK, else LSM_INVALID_ARGUMENT
*/
int LSM_DLL_EXPORT lsm_initiator_id_verify( const char *init_id,
lsm_access_group_init_type *init_type);

Signed-off-by: Tony Asleson <***@redhat.com>
---
.../include/libstoragemgmt/libstoragemgmt_common.h | 10 ++-
c_binding/lsm_datatypes.cpp | 93 ++++++++++++++++++++-
c_binding/lsm_datatypes.hpp | 22 +++++
c_binding/lsm_mgmt.cpp | 80 ++++++++++++++++--
plugin/smispy/smis.py | 3 +-
python_binding/lsm/_client.py | 8 +-
python_binding/lsm/_data.py | 95 ++++++++++------------
tools/lsmcli/cmdline.py | 10 +--
8 files changed, 253 insertions(+), 68 deletions(-)

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_common.h b/c_binding/include/libstoragemgmt/libstoragemgmt_common.h
index e2d91da..360b49a 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_common.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_common.h
@@ -111,7 +111,15 @@ int LSM_DLL_EXPORT lsm_string_list_append(lsm_string_list *sl, const char* add);
*/
int LSM_DLL_EXPORT lsm_string_list_delete(lsm_string_list *sl, uint32_t index);

-
+/**
+ * Checks to see if initiator id is valid
+ * @param init_id Initiator value
+ * @param init_type Type of initiator id, will get modified
+ * to determined if type passed in is UNKNOWN
+ * @return LSM_ERR_OK if initiator id is OK, else LSM_INVALID_ARGUMENT
+ */
+int LSM_DLL_EXPORT lsm_initiator_id_verify( const char *init_id,
+ lsm_access_group_init_type *init_type);

#ifdef __cplusplus
}
diff --git a/c_binding/lsm_datatypes.cpp b/c_binding/lsm_datatypes.cpp
index 8e53158..5839f9e 100644
--- a/c_binding/lsm_datatypes.cpp
+++ b/c_binding/lsm_datatypes.cpp
@@ -44,6 +44,7 @@
#include <unistd.h>
#include <dlfcn.h>
#include <glib.h>
+#include <regex.h>

#ifdef __cplusplus
extern "C" {
@@ -994,6 +995,34 @@ const char *lsm_disk_system_id_get( lsm_disk *d)

CREATE_ALLOC_ARRAY_FUNC(lsm_access_group_record_array_alloc, lsm_access_group *)

+static lsm_string_list *standardize_init_list(lsm_string_list *initiators)
+{
+ uint32_t i = 0;
+ lsm_string_list *rc = lsm_string_list_copy(initiators);
+ char *wwpn = NULL;
+
+ if( rc ) {
+ for( i = 0; i < lsm_string_list_size(rc); ++i ) {
+ if( LSM_ERR_OK == wwpn_validate(lsm_string_list_elem_get(rc, i)) ) {
+ /* We have a wwpn, switch to internal representation */
+ wwpn = wwpn_convert(lsm_string_list_elem_get(rc, i));
+ if( !wwpn ||
+ LSM_ERR_OK != lsm_string_list_elem_set(rc, i, wwpn) ) {
+ free(wwpn);
+ lsm_string_list_free(rc);
+ rc = NULL;
+ break;
+ }
+ free(wwpn);
+ wwpn = NULL;
+ }
+ }
+ }
+
+ return rc;
+}
+
+
lsm_access_group *lsm_access_group_record_alloc(const char *id,
const char *name,
lsm_string_list *initiators,
@@ -1009,7 +1038,7 @@ lsm_access_group *lsm_access_group_record_alloc(const char *id,
rc->id = strdup(id);
rc->name = strdup(name);
rc->system_id = strdup(system_id);
- rc->initiators = lsm_string_list_copy(initiators);
+ rc->initiators = standardize_init_list(initiators);
rc->init_type = init_type;

if( plugin_data ) {
@@ -1019,7 +1048,8 @@ lsm_access_group *lsm_access_group_record_alloc(const char *id,
}

if( !rc->id || !rc->name || !rc->system_id ||
- (plugin_data && !rc->plugin_data)) {
+ (plugin_data && !rc->plugin_data) ||
+ (initiators && !rc->initiators) ) {
lsm_access_group_record_free(rc);
rc = NULL;
}
@@ -1885,8 +1915,67 @@ CREATE_FREE_ARRAY_FUNC(lsm_target_port_record_array_free,
lsm_target_port_record_free, lsm_target_port *,
LSM_ERR_INVALID_ARGUMENT)

+static int reg_ex_match(const char *pattern, const char *str)
+{
+ regex_t start_state;
+ int status = 0;
+ int rc = regcomp(&start_state, pattern, REG_EXTENDED);
+
+ if (rc) {
+ // Development only when changing regular expression
+ //fprintf(stderr, "%s: bad pattern: '%s' %d\n", str, pattern, rc);
+ return -1;
+ }
+
+ status = regexec(&start_state, str, 0, NULL, 0);
+ regfree(&start_state);
+
+ return status;
+}
+
+int iqn_validate(const char *iqn)
+{
+ if( (iqn && strlen(iqn) > 4) && ( 0 == strncmp(iqn, "iqn", 3) ||
+ 0 == strncmp(iqn, "naa", 3) || 0 == strncmp(iqn, "eui", 3)) ) {
+ return LSM_ERR_OK;
+ }
+ return LSM_ERR_INVALID_ARGUMENT;
+}
+
+int wwpn_validate(const char *wwpn)
+{
+ const char *pattern = "^(0x|0X)?([0-9A-Fa-f]{2})"
+ "(([\\.\\:\\-])?[0-9A-Fa-f]{2}){7}$";
+ if( 0 == reg_ex_match(pattern, wwpn) ) {
+ return LSM_ERR_OK;
+ }
+ return LSM_ERR_INVALID_ARGUMENT;
+}

+char *wwpn_convert(const char *wwpn)
+{
+ size_t i = 0;
+ size_t out = 0;
+ char *rc = NULL;
+
+ if( LSM_ERR_OK == wwpn_validate(wwpn) ) {
+ rc = (char*)calloc(24,1);
+ size_t len = strlen(wwpn);

+ if (wwpn[1] == 'x' || wwpn[1] == 'X') {
+ i = 2;
+ }
+
+ for( ; i < len; ++i ) {
+ if( wwpn[i] != ':' && wwpn[i] != '-' && wwpn[i] != '.') {
+ rc[out++] = tolower(wwpn[i]);
+ } else {
+ rc[out++] = ':';
+ }
+ }
+ }
+ return rc;
+}
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/lsm_datatypes.hpp b/c_binding/lsm_datatypes.hpp
index 00e2111..02f189e 100644
--- a/c_binding/lsm_datatypes.hpp
+++ b/c_binding/lsm_datatypes.hpp
@@ -350,6 +350,28 @@ LSM_DLL_LOCAL const char *uds_path(void);
int LSM_DLL_LOCAL number_convert(const char *str_num, int64_t *si, uint64_t *ui,
long double *d);

+
+/**
+ * Validates an iSCSI IQN
+ * @param iqn iSCSI iqn to check
+ * @return LSM_ERR_OK on success, else LSM_ERR_INVALID_ARGUMENT
+ */
+int LSM_DLL_LOCAL iqn_validate(const char *iqn);
+
+/**
+ * Validates an WWPN
+ * @param wwpn wwpn to check
+ * @return LSM_ERR_OK on success, else LSM_ERR_INVALID_ARGUMENT
+ */
+int LSM_DLL_LOCAL wwpn_validate(const char *wwpn);
+
+/**
+ * Given a WWPN validate it and then convert to internal representation.
+ * @param wwpn World wide port name to validate
+ * @return NULL if not patch, else string with common lsm format
+ */
+char LSM_DLL_LOCAL *wwpn_convert(const char *wwpn);
+
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/lsm_mgmt.cpp b/c_binding/lsm_mgmt.cpp
index 5805cf9..cb9c15b 100644
--- a/c_binding/lsm_mgmt.cpp
+++ b/c_binding/lsm_mgmt.cpp
@@ -76,6 +76,65 @@ static int check_search_key(const char *search_key,
return 0;
}

+int lsm_initiator_id_verify(const char *init_id,
+ lsm_access_group_init_type *init_type)
+{
+ int rc = LSM_ERR_INVALID_ARGUMENT;
+
+ if( init_id != NULL && strlen(init_id) > 3 ) {
+
+ switch( *init_type ) {
+ case( LSM_ACCESS_GROUP_INIT_TYPE_UNKNOWN ):
+ if( 0 == iqn_validate(init_id) ) {
+ *init_type = LSM_ACCESS_GROUP_INIT_TYPE_ISCSI_IQN;
+ rc = LSM_ERR_OK;
+ }
+ if( 0 == wwpn_validate(init_id) ) {
+ *init_type = LSM_ACCESS_GROUP_INIT_TYPE_WWPN;
+ rc = LSM_ERR_OK;
+ }
+ break;
+ case( LSM_ACCESS_GROUP_INIT_TYPE_ISCSI_IQN ):
+ if( 0 == iqn_validate(init_id) ) {
+ *init_type = LSM_ACCESS_GROUP_INIT_TYPE_ISCSI_IQN;
+ rc = LSM_ERR_OK;
+ }
+ break;
+ case( LSM_ACCESS_GROUP_INIT_TYPE_WWPN ):
+ if( 0 == wwpn_validate(init_id) ) {
+ *init_type = LSM_ACCESS_GROUP_INIT_TYPE_WWPN;
+ rc = LSM_ERR_OK;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return rc;
+}
+
+static int verify_initiator_id(const char *id, lsm_access_group_init_type t,
+ Value &initiator)
+{
+ initiator = Value(id);
+
+ if( t == LSM_ACCESS_GROUP_INIT_TYPE_WWPN ) {
+ char *wwpn = wwpn_convert(id);
+ if( wwpn ) {
+ initiator = Value(wwpn);
+ free(wwpn);
+ wwpn = NULL;
+ } else {
+ return LSM_ERR_INVALID_ARGUMENT;
+ }
+ } else if( t == LSM_ACCESS_GROUP_INIT_TYPE_ISCSI_IQN ) {
+ if( iqn_validate(id) ) {
+ return LSM_ERR_INVALID_ARGUMENT;
+ }
+ }
+ return LSM_ERR_OK;
+}
+
/**
* Strings are non null with a len >= 1
*/
@@ -1177,7 +1236,7 @@ int lsm_volume_replicate(lsm_connect *c, lsm_pool *pool,
{
CONN_SETUP(c);

- if( pool && !LSM_IS_POOL(pool) || !LSM_IS_VOL(volumeSrc) ) {
+ if( (pool && !LSM_IS_POOL(pool)) || !LSM_IS_VOL(volumeSrc) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1319,8 +1378,7 @@ int lsm_iscsi_chap_auth(lsm_connect *c, const char *init_id,
{
CONN_SETUP(c);

- if( NULL == init_id || strlen(init_id) == 0 ||
- LSM_FLAG_UNUSED_CHECK(flags)) {
+ if( iqn_validate(init_id) || LSM_FLAG_UNUSED_CHECK(flags)) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1411,9 +1469,15 @@ int lsm_access_group_create(lsm_connect *c, const char *name,
return LSM_ERR_INVALID_ARGUMENT;
}

+ Value id;
+
+ if( LSM_ERR_OK != verify_initiator_id(init_id, init_type, id) ) {
+ return LSM_ERR_INVALID_ARGUMENT;
+ }
+
std::map<std::string, Value> p;
p["name"] = Value(name);
- p["init_id"] = Value(init_id);
+ p["init_id"] = id;
p["init_type"] = Value((int32_t)init_type);
p["system"] = system_to_value(system);
p["flags"] = Value(flags);
@@ -1466,9 +1530,15 @@ int lsm_access_group_initiator_add(lsm_connect *c,
return LSM_ERR_INVALID_ARGUMENT;
}

+ Value id;
+
+ if( LSM_ERR_OK != verify_initiator_id(init_id, init_type, id) ) {
+ return LSM_ERR_INVALID_ARGUMENT;
+ }
+
std::map<std::string, Value> p;
p["access_group"] = access_group_to_value(access_group);
- p["init_id"] = init_id;
+ p["init_id"] = id;
p["init_type"] = Value((int32_t)init_type);
p["flags"] = Value(flags);

diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 368b606..b59b563 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -1597,8 +1597,7 @@ class Smis(IStorageAreaNetwork):
for cim_init in cim_inits:
init_type = _dmtf_init_type_to_lsm(cim_init)
if init_type == AccessGroup.INIT_TYPE_WWPN:
- init_ids.append(
- AccessGroup.wwpn_to_lsm_type(self._init_id(cim_init)))
+ init_ids.append(self._init_id(cim_init))
init_types.append(init_type)
elif init_type == AccessGroup.INIT_TYPE_ISCSI_IQN:
init_ids.append(self._init_id(cim_init))
diff --git a/python_binding/lsm/_client.py b/python_binding/lsm/_client.py
index 00b9184..820c6b8 100644
--- a/python_binding/lsm/_client.py
+++ b/python_binding/lsm/_client.py
@@ -654,7 +654,8 @@ class Client(INetworkAttachedStorage):
Creates an access group and add the specified initiator id,
init_type and desired access.
"""
- AccessGroup.init_id_validate(init_id, init_type, raise_error=True)
+ init_type, init_id = AccessGroup.initiator_id_verify(
+ init_id, init_type, raise_exception=True)[1:]
return self._tp.rpc('access_group_create', _del_self(locals()))

## Deletes an access group.
@@ -682,7 +683,8 @@ class Client(INetworkAttachedStorage):
"""
Adds an initiator to an access group
"""
- AccessGroup.init_id_validate(init_id, init_type, raise_error=True)
+ init_type, init_id = AccessGroup.initiator_id_verify(
+ init_id, init_type, raise_exception=True)[1:]
return self._tp.rpc('access_group_initiator_add', _del_self(locals()))

## Deletes an initiator from an access group
@@ -696,6 +698,8 @@ class Client(INetworkAttachedStorage):
"""
Deletes an initiator from an access group
"""
+ init_id = AccessGroup.initiator_id_verify(init_id, None,
+ raise_exception=True)[2:]
return self._tp.rpc('access_group_initiator_delete',
_del_self(locals()))

diff --git a/python_binding/lsm/_data.py b/python_binding/lsm/_data.py
index 17df3ec..fb4545a 100644
--- a/python_binding/lsm/_data.py
+++ b/python_binding/lsm/_data.py
@@ -658,66 +658,61 @@ class AccessGroup(IData):
_plugin_data=None):
self._id = _id
self._name = _name # AccessGroup name
- self._init_ids = _init_ids # A list of Initiator ID strings.
+ self._init_ids = AccessGroup._standardize_init_list(_init_ids)
+ # A list of Initiator ID strings.
self._init_type = _init_type
self._system_id = _system_id # System id this group belongs
self._plugin_data = _plugin_data

- # Regex for LSM format of WWPN, example:
- # 10:00:00:00:c9:95:2f:de
- _regex_lsm_wwpn = re.compile(r"""
- ^
- (?:[0-9a-f]{2}:){7}
- [0-9a-f]{2}
- $
- """, re.X)
-
- _regex_iscsi_iqn = re.compile(r"""
- ^
- iqn # iqn
- \. # .
- [0-9]{4}-[0-9]{2} # 1995-02
- \. # .
- [A-Za-z](?:[A-Za-z0-9\-]*[A-Za-z0-9])? # com
- \. # .
- [A-Za-z](?:[A-Za-z0-9\-]*[A-Za-z0-9])? # redhat
- : # :
- [\.A-Za-z\-0-9]+ # gris-01
- $
- """, re.X)
-
@staticmethod
- def init_id_validate(init_id, init_type, raise_error=True):
- if init_type == AccessGroup.INIT_TYPE_ISCSI_IQN:
- if AccessGroup._regex_iscsi_iqn.match(str(init_id)):
- return True
- if raise_error:
- raise LsmError(ErrorNumber.INVALID_ARGUMENT,
- "Invalid iSCSI IQN Initiator: %s" % init_id)
- return False
- elif init_type == AccessGroup.INIT_TYPE_WWPN:
- if AccessGroup._regex_lsm_wwpn.match(str(init_id)):
- return True
- if raise_error:
- raise LsmError(ErrorNumber.INVALID_ARGUMENT,
- "Invalid WWPN Initiator: %s" % init_id)
- return False
- elif raise_error:
- raise LsmError(ErrorNumber.NO_SUPPORT,
- "Initiator type %d not supported" % init_type)
- return False
+ def _standardize_init_list(init_ids):
+ rc = []
+ for i in init_ids:
+ valid, init_type, init_id = AccessGroup.initiator_id_verify(i)
+
+ if valid:
+ rc.append(init_id)
+ else:
+ raise LsmError(LsmError.ErrorNumber.INVALID_ARGUMENT,
+ "Invalid initiator ID %s" % i)
+ return rc

_regex_wwpn = re.compile(r"""
- ^
- [0x|0X]{0,1}
- (:?[0-9A-Fa-f]{2}
- [\.\-:]{0,1}){7}
- [0-9A-Fa-f]{2}
- $
+ ^(0x|0X)?([0-9A-Fa-f]{2})
+ (([\.:\-])?[0-9A-Fa-f]{2}){7}$
""", re.X)

@staticmethod
- def wwpn_to_lsm_type(wwpn, raise_error=True):
+ def initiator_id_verify(init_id, init_type=None, raise_exception=False):
+ """
+ Public method which can be used to verify an initiator id
+ :param init_id:
+ :param init_type:
+ :param raise_exception: Will throw a LsmError INVALID_ARGUMENT if
+ not a valid initiator address
+ :return:(Bool, init_type, init_id) Note: init_id will be returned in
+ normalized format if it's a WWPN
+ """
+ if init_id.startswith('iqn') or init_id.startswith('eui') or\
+ init_id.startswith('naa'):
+
+ if init_type is None or \
+ init_type == AccessGroup.INIT_TYPE_ISCSI_IQN:
+ return True, AccessGroup.INIT_TYPE_ISCSI_IQN, init_id
+ if AccessGroup._regex_wwpn.match(str(init_id)):
+ if init_type is None or \
+ init_type == AccessGroup.INIT_TYPE_WWPN:
+ return True, AccessGroup.INIT_TYPE_WWPN, \
+ AccessGroup._wwpn_to_lsm_type(init_id)
+
+ if raise_exception:
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT,
+ "Initiator id '%s' is invalid" % init_id)
+
+ return False, None, None
+
+ @staticmethod
+ def _wwpn_to_lsm_type(wwpn, raise_error=True):
"""
Conver provided WWPN string into LSM standarded one:

diff --git a/tools/lsmcli/cmdline.py b/tools/lsmcli/cmdline.py
index 8d65abf..409a3ed 100644
--- a/tools/lsmcli/cmdline.py
+++ b/tools/lsmcli/cmdline.py
@@ -77,6 +77,7 @@ def getch():
termios.tcsetattr(fd, termios.TCSADRAIN, prev)
return ch

+
def parse_convert_init(init_id):
"""
If init_id is a WWPN, convert it into LSM standard version:
@@ -84,13 +85,10 @@ def parse_convert_init(init_id):

Return (converted_init_id, lsm_init_type)
"""
- init_type = AccessGroup.INIT_TYPE_ISCSI_IQN
- if AccessGroup.init_id_validate(init_id, init_type, raise_error=False):
- return (init_id, init_type)
+ valid, init_type, init_id = AccessGroup.initiator_id_verify(init_id)

- wwpn = AccessGroup.wwpn_to_lsm_type(init_id, raise_error=False)
- if wwpn:
- return (wwpn, AccessGroup.INIT_TYPE_WWPN)
+ if valid:
+ return (init_id, init_type)

raise ArgError("--init-id %s is not a valid WWPN or iSCSI IQN" % init_id)
--
1.8.2.1
Tony Asleson
2014-08-13 23:22:17 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
examples/client_example.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
create mode 100644 examples/client_example.c

diff --git a/examples/client_example.c b/examples/client_example.c
new file mode 100644
index 0000000..cf67930
--- /dev/null
+++ b/examples/client_example.c
@@ -0,0 +1,76 @@
+ #include <stdio.h>
+ #include <libstoragemgmt/libstoragemgmt.h>
+
+ /*
+ * If you have the development library package installed
+
+ $ gcc -Wall client_example.c -lstoragemgmt -o client_example
+
+ *
+ * If building out of source tree
+ *
+ $ gcc -Wall -g -O0 client_example.c -I../c_binding/include/ \
+ -L../c_binding/.libs -lstoragemgmt -o client_example
+
+ */
+
+ void error(char *msg, int rc, lsm_error *e)
+ {
+ if( rc ) {
+ printf("%s: error: %d\n", msg, rc);
+
+ if( e && lsm_error_message_get(e) ) {
+ printf("Msg: %s\n", lsm_error_message_get(e));
+ lsm_error_free(e);
+ }
+ }
+ }
+
+ void list_pools(lsm_connect *c)
+ {
+ lsm_pool **pools = NULL;
+ int rc = 0;
+ uint32_t count = 0;
+
+ rc = lsm_pool_list(c, NULL, NULL, &pools, &count, LSM_FLAG_RSVD);
+ if( LSM_ERR_OK == rc ) {
+ uint32_t i;
+ for( i = 0; i < count; ++i) {
+ printf("pool name: %s freespace: %"PRIu64"\n",
+ lsm_pool_name_get(pools[i]),
+ lsm_pool_free_space_get(pools[i]));
+ }
+
+ lsm_pool_record_array_free(pools, count);
+ } else {
+ error("Volume list", rc, lsm_error_last_get(c));
+ }
+ }
+
+ int main()
+ {
+ lsm_connect *c = NULL;
+ lsm_error *e = NULL;
+ int rc = 0;
+
+ const char *uri = "sim://";
+
+ rc = lsm_connect_password(uri, NULL, &c, 30000, &e, LSM_FLAG_RSVD);
+
+ if( LSM_ERR_OK == rc ) {
+ printf("We connected...\n");
+
+ list_pools(c);
+
+ rc = lsm_connect_close(c, LSM_FLAG_RSVD);
+ if( LSM_ERR_OK != rc ) {
+ error("Close", rc, lsm_error_last_get(c));
+ } else {
+ printf("We closed\n");
+ }
+ } else {
+ error("Connect", rc, e);
+ }
+
+ return rc;
+ }
--
1.8.2.1
Tony Asleson
2014-08-13 23:22:14 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/tester.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 144 insertions(+), 1 deletion(-)

diff --git a/test/tester.c b/test/tester.c
index e5680bb..a877e4a 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -661,7 +661,7 @@ START_TEST(test_access_groups)
G(rc, lsm_access_group_record_array_free, groups, count);
groups = NULL;
count = 0;
- char *job = NULL;
+ //char *job = NULL;
lsm_access_group *updated = NULL;

rc = lsm_access_group_initiator_add(c, group, "iqn.1994-05.com.domain:01.89bd02",
@@ -2871,6 +2871,148 @@ START_TEST(test_target_ports)
}
END_TEST

+START_TEST(test_initiator_id_verification)
+{
+ int rc = 0;
+ lsm_access_group *group = NULL;
+ lsm_access_group *updated_group = NULL;
+ lsm_access_group **groups = NULL;
+ uint32_t count = 0;
+ lsm_system *system = get_system(c);
+
+ G(rc, lsm_access_group_list, c, NULL, NULL, &groups, &count, LSM_FLAG_RSVD);
+ fail_unless(count == 0, "Expect 0 access groups, got %"PRIu32, count);
+ fail_unless(groups == NULL);
+
+ /* Test valid iqns first, then invalid */
+
+ G(rc, lsm_access_group_create, c, "test_ag_iscsi",
+ "iqn.1994-05.com.domain.sub:whatever-the.users_wants",
+ LSM_ACCESS_GROUP_INIT_TYPE_ISCSI_IQN, system,
+ &group, LSM_FLAG_RSVD);
+
+ G(rc, lsm_access_group_initiator_add, c, group,
+ "iqn.2001-04.com.example:storage:diskarrays-sn-a8675309",
+ LSM_ACCESS_GROUP_INIT_TYPE_ISCSI_IQN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ G(rc, lsm_access_group_record_free, group);
+ group = updated_group;
+ updated_group = NULL;
+
+ G(rc, lsm_access_group_initiator_add, c, group,
+ "iqn.2001-04.com.example",
+ LSM_ACCESS_GROUP_INIT_TYPE_ISCSI_IQN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ G(rc, lsm_access_group_record_free, group);
+ group = updated_group;
+ updated_group = NULL;
+
+ G(rc, lsm_access_group_initiator_add, c, group,
+ "iqn.2001-04.com.example:storage.tape1.sys1.xyz",
+ LSM_ACCESS_GROUP_INIT_TYPE_ISCSI_IQN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ G(rc, lsm_access_group_record_free, group);
+ group = updated_group;
+ updated_group = NULL;
+
+ G(rc, lsm_access_group_initiator_add, c, group,
+ "iqn.2001-04.com.example:storage.disk2.sys1.xyz",
+ LSM_ACCESS_GROUP_INIT_TYPE_ISCSI_IQN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ G(rc, lsm_access_group_record_free, group);
+ group = updated_group;
+ updated_group = NULL;
+
+ G(rc, lsm_access_group_initiator_add, c, group,
+ "0x0011223344556677",
+ LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ G(rc, lsm_access_group_record_free, group);
+ group = updated_group;
+ updated_group = NULL;
+
+ G(rc, lsm_access_group_initiator_add, c, group,
+ "00:11:22:33:44:55:66:77",
+ LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ G(rc, lsm_access_group_record_free, group);
+ group = updated_group;
+ updated_group = NULL;
+
+ G(rc, lsm_access_group_initiator_add, c, group,
+ "00-11-22-33-44-55-66-77",
+ LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ G(rc, lsm_access_group_record_free, group);
+ group = updated_group;
+ updated_group = NULL;
+
+ G(rc, lsm_access_group_initiator_add, c, group,
+ "0x00-11-22-33-44-55-66-77",
+ LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ G(rc, lsm_access_group_record_free, group);
+ group = updated_group;
+ updated_group = NULL;
+
+ /* Test invalid */
+ rc = lsm_access_group_initiator_add(c, group, "0x:0011223344556677",
+ LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT,
+ "Expected initiator id with invalid form to fail! %d", rc);
+
+ /* Test invalid iqn */
+ rc = lsm_access_group_initiator_add(c, group, "0011223344556677:",
+ LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT,
+ "Expected initiator id with invalid form to fail! %d", rc);
+
+ /* Test invalid iqn */
+ rc = lsm_access_group_initiator_add(c, group, "001122334455667788",
+ LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT,
+ "Expected initiator id with invalid form to fail! %d", rc);
+
+ /* Test invalid iqn */
+ rc = lsm_access_group_initiator_add(c, group, "0x001122334455",
+ LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT,
+ "Expected initiator id with invalid form to fail! %d", rc);
+
+ /* Test invalid iqn */
+ rc = lsm_access_group_initiator_add(c, group, "0x00+11:22:33:44:55:66:77",
+ LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
+ LSM_FLAG_RSVD);
+
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT,
+ "Expected initiator id with invalid form to fail! %d", rc);
+
+ /* Delete group */
+ G(rc, lsm_access_group_delete, c, group, LSM_FLAG_RSVD);
+ G(rc, lsm_access_group_record_free, group);
+ group = NULL;
+
+ G(rc, lsm_system_record_free, system);
+ system = NULL;
+}
+END_TEST
+
Suite * lsm_suite(void)
{
Suite *s = suite_create("libStorageMgmt");
@@ -2878,6 +3020,7 @@ Suite * lsm_suite(void)
TCase *basic = tcase_create("Basic");
tcase_add_checked_fixture (basic, setup, teardown);

+ tcase_add_test(basic, test_initiator_id_verification);
tcase_add_test(basic, test_target_ports);
tcase_add_test(basic, test_search_fs);
tcase_add_test(basic, test_search_access_groups);
--
1.8.2.1
Tony Asleson
2014-08-13 23:22:16 UTC
Permalink
The error codes existed for reason. Unfortunately some of the
checks weren't being done in code. These are mainly useful in
a badly configed or installed library setup. However, it should
be useful if any of these errors are encountered.

Signed-off-by: Tony Asleson <***@redhat.com>
---
.../include/libstoragemgmt/libstoragemgmt_error.h | 7 ++--
c_binding/lsm_datatypes.cpp | 44 ++++++++++++----------
python_binding/lsm/_common.py | 9 +++--
python_binding/lsm/_transport.py | 15 +++++++-
4 files changed, 47 insertions(+), 28 deletions(-)

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
index 5ce1d2c..818eb94 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
@@ -88,10 +88,11 @@ typedef enum {
LSM_ERR_NO_SUPPORT_OFFLINE_CHANGE = 251, /**< Needs to be online to perform operation */

LSM_ERR_PLUGIN_AUTH_FAILED = 300, /**< Authorization failed */
- LSM_ERR_PLUGIN_IPC_FAIL = 301, /**< dlopen on plugin failed */
+ LSM_ERR_PLUGIN_IPC_FAIL = 301, /**< Inter-process communication between client &
+ out of process plug-in encountered connection
+ errors.**/

- LSM_ERR_PLUGIN_SOCKET_PERMISSION = 307, /**< Unable to access plugin */
- LSM_ERR_PLUGIN_REGISTRATION = 308, /**< Error during plug-in registration */
+ LSM_ERR_PLUGIN_SOCKET_PERMISSION = 307, /**< Incorrect permission on UNIX domain socket used for IPC */
LSM_ERR_PLUGIN_NOT_EXIST = 311, /**< Plug-in does not appear to exist */

LSM_ERR_NOT_ENOUGH_SPACE = 350, /**< Insufficient space */
diff --git a/c_binding/lsm_datatypes.cpp b/c_binding/lsm_datatypes.cpp
index 5839f9e..adb10dc 100644
--- a/c_binding/lsm_datatypes.cpp
+++ b/c_binding/lsm_datatypes.cpp
@@ -302,32 +302,36 @@ int driver_load(lsm_connect *c, const char *plugin_name, const char *password,
return LSM_ERR_NO_MEMORY;
}

- if (access(plugin_file, R_OK) == 0) {
- int ec;
- int sd = Transport::socket_get(std::string(plugin_file), ec);
-
- if( sd >= 0 ) {
- c->tp = new Ipc(sd);
- if( startup ) {
- if( connection_establish(c, password, timeout, e, flags)) {
- rc = LSM_ERR_PLUGIN_IPC_FAIL;
+ if (access(plugin_file, F_OK) != 0) {
+ rc = LSM_ERR_PLUGIN_NOT_EXIST;
+ } else {
+ if (access(plugin_file, R_OK|W_OK) == 0) {
+ int ec;
+ int sd = Transport::socket_get(std::string(plugin_file), ec);
+
+ if( sd >= 0 ) {
+ c->tp = new Ipc(sd);
+ if( startup ) {
+ if( connection_establish(c, password, timeout, e, flags)) {
+ rc = LSM_ERR_PLUGIN_IPC_FAIL;
+ }
}
+ } else {
+ *e = lsm_error_create(LSM_ERR_PLUGIN_IPC_FAIL,
+ LSM_ERR_DOMAIN_FRAME_WORK,
+ LSM_ERR_LEVEL_ERROR, "Unable to connect to plugin",
+ NULL, dlerror(), NULL, 0 );
+
+ rc = LSM_ERR_PLUGIN_IPC_FAIL;
}
} else {
- *e = lsm_error_create(LSM_ERR_PLUGIN_IPC_FAIL,
+ *e = lsm_error_create(LSM_ERR_PLUGIN_SOCKET_PERMISSION,
LSM_ERR_DOMAIN_FRAME_WORK,
- LSM_ERR_LEVEL_ERROR, "Unable to connect to plugin",
- NULL, dlerror(), NULL, 0 );
+ LSM_ERR_LEVEL_ERROR, "Unable to access plugin",
+ NULL, NULL, NULL, 0 );

- rc = LSM_ERR_PLUGIN_IPC_FAIL;
+ rc = LSM_ERR_PLUGIN_SOCKET_PERMISSION;
}
- } else {
- *e = lsm_error_create(LSM_ERR_PLUGIN_SOCKET_PERMISSION,
- LSM_ERR_DOMAIN_FRAME_WORK,
- LSM_ERR_LEVEL_ERROR, "Unable to access plugin",
- NULL, NULL, NULL, 0 );
-
- rc = LSM_ERR_PLUGIN_SOCKET_PERMISSION;
}

free(plugin_file);
diff --git a/python_binding/lsm/_common.py b/python_binding/lsm/_common.py
index d11c170..8100509 100644
--- a/python_binding/lsm/_common.py
+++ b/python_binding/lsm/_common.py
@@ -464,10 +464,13 @@ class ErrorNumber(object):
NO_SUPPORT_ONLINE_CHANGE = 250
NO_SUPPORT_OFFLINE_CHANGE = 251

- PLUGIN_AUTH_FAILED = 300
- PLUGIN_IPC_FAIL = 301
+ PLUGIN_AUTH_FAILED = 300 # Client supplied credential are incorrect
+ PLUGIN_IPC_FAIL = 301 # Inter-process communication between client &
+ # out of process plug-in encountered connection
+ # errors.

- PLUGIN_SOCKET_PERMISSION = 307
+ PLUGIN_SOCKET_PERMISSION = 307 # Incorrect permission on UNIX domain
+ # socket used for IPC
PLUGIN_REGISTRATION = 308
PLUGIN_NOT_EXIST = 311

diff --git a/python_binding/lsm/_transport.py b/python_binding/lsm/_transport.py
index 4498be2..5d6a6ec 100644
--- a/python_binding/lsm/_transport.py
+++ b/python_binding/lsm/_transport.py
@@ -18,6 +18,7 @@
import json
import socket
import string
+import os
from _common import SocketEOF as _SocketEOF
from _common import LsmError, ErrorNumber
from _data import DataDecoder as _DataDecoder, DataEncoder as _DataEncoder
@@ -98,10 +99,20 @@ class TransPort(object):
"""
try:
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s.connect(path)
+
+ if os.path.exists(path):
+ if os.access(path, os.R_OK | os.W_OK):
+ s.connect(path)
+ else:
+ raise LsmError(ErrorNumber.PLUGIN_SOCKET_PERMISSION,
+ "Permissions are incorrect for IPC "
+ "socket file")
+ else:
+ raise LsmError(ErrorNumber.PLUGIN_NOT_EXIST,
+ "Plug-in appears to not exist")
except socket.error:
#self, code, message, data=None, *args, **kwargs
- raise LsmError(ErrorNumber.NETWORK_ERROR,
+ raise LsmError(ErrorNumber.PLUGIN_IPC_FAIL,
"Unable to connect to lsmd, daemon started?")
return s
--
1.8.2.1
Tony Asleson
2014-08-13 23:22:12 UTC
Permalink
See email from Gris subject: "Error number review"

Signed-off-by: Tony Asleson <***@redhat.com>
---
.../include/libstoragemgmt/libstoragemgmt_error.h | 62 ++----
c_binding/lsm_datatypes.cpp | 101 +++++-----
c_binding/lsm_mgmt.cpp | 209 ++++++---------------
c_binding/lsm_plugin_ipc.cpp | 18 +-
plugin/nstor/nstor.py | 8 +-
plugin/ontap/na.py | 4 +-
plugin/ontap/ontap.py | 30 +--
plugin/sim/simarray.py | 76 ++++----
plugin/simc/simc_lsmplugin.c | 26 +--
plugin/smispy/smis.py | 56 +++---
plugin/targetd/targetd.py | 10 +-
python_binding/lsm/_common.py | 66 ++-----
python_binding/lsm/_data.py | 6 +-
python_binding/lsm/_pluginrunner.py | 2 +-
python_binding/lsm/_transport.py | 2 +-
test/tester.c | 100 +++++-----
16 files changed, 308 insertions(+), 468 deletions(-)

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
index 60f2362..5ce1d2c 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
@@ -48,7 +48,6 @@ typedef enum {
LSM_ERR_PLUGIN_BUG = 2, /**< Plugin BUG */
LSM_ERR_STORAGE_SDK_BUG = 3, /**< Storage SDK BUG */
LSM_ERR_JOB_STARTED = 7, /**< Operation has started */
- LSM_ERR_INDEX_BOUNDS = 10, /**< Out of bounds on string index */
LSM_ERR_TIMEOUT = 11, /**< Plug-in is un-responsive */
LSM_ERR_DAEMON_NOT_RUNNING = 12, /**< Daemon is not running */

@@ -57,35 +56,17 @@ typedef enum {
LSM_ERR_EXISTS_INITIATOR = 52, /**< Initiator exists */
LSM_ERR_EXISTS_NAME = 53, /**< Named item already exists */
LSM_ERR_FS_NOT_EXPORTED = 54, /**< FS not nfs exported */
- LSM_ERR_INITIATOR_NOT_IN_ACCESS_GROUP = 55, /**< Initiator not in access group */
LSM_ERR_EXISTS_POOL = 56, /**< Pool exists */
LSM_ERR_EXISTS_VOLUME = 57, /**< Volume exists */

- LSM_ERR_INVALID_ACCESS_GROUP = 100, /**< Invalid access group */
LSM_ERR_INVALID_ARGUMENT = 101, /**< Precondition checks failed */
- LSM_ERR_INVALID_CONN = 102, /**< Connection structure is invalid */
- LSM_ERR_INVALID_ERR = 103, /**< Invalid error structure */
- LSM_ERR_INVALID_FS = 104, /**< invalid fs */
- LSM_ERR_INVALID_JOB = 106, /**< Invalid job number */
- LSM_ERR_INVALID_NAME = 107, /**< Name specified is invalid */
- LSM_ERR_INVALID_NFS = 108, /**< invalid nfs export record */
- LSM_ERR_INVALID_PLUGIN = 109, /**< Invalid plugin structure */
- LSM_ERR_INVALID_POOL = 110, /**< Invalid pool pointer */
- LSM_ERR_INVALID_SL = 111, /**< Invalid string list */
- LSM_ERR_INVALID_SS = 112, /**< Invalid snapshot */
- LSM_ERR_INVALID_URI = 113, /**< Invalid uri */
- LSM_ERR_INVALID_VAL = 114, /**< Invalid value */
- LSM_ERR_INVALID_VOL = 115, /**< Invalid volume pointer */
- LSM_ERR_INVALID_CAPABILITY = 116, /**< Invalid capability pointer */
- LSM_ERR_INVALID_SYSTEM = 117, /**< Invalid system pointer */
- LSM_ERR_INVALID_INIT = 118, /**< Invalid Initiator ID */
- LSM_ERR_INVALID_DISK = 119, /**< Invalid disk */
- LSM_ERR_INVALID_HASH = 120, /**< Invalid optional data */
- LSM_ERR_INVALID_BLOCK_RANGE = 121, /**< Invalud block range */

LSM_ERR_IS_MAPPED = 125, /**< Mapping already exists */

- LSM_ERR_NO_CONNECT = 150, /**< Unable to connect to host */
+ LSM_ERR_CONNREFUSED = 140, /**< Host on network, but not allowing connection */
+ LSM_ERR_HOSTDOWN = 141, /**< Host unreachable on network */
+ LSM_ERR_NETWORK_ERROR = 142, /**< Generic network error */
+
LSM_ERR_NO_MAPPING = 151, /**< There is no access for initiator and volume */
LSM_ERR_NO_MEMORY = 152, /**< Memory allocation failure */
LSM_ERR_NO_SUPPORT = 153, /**< Feature not supported */
@@ -94,51 +75,42 @@ typedef enum {
LSM_ERR_NOT_FOUND_FS = 201, /**< Specified FS not found */
LSM_ERR_NOT_FOUND_JOB = 202, /**< Specified JOB not found */
LSM_ERR_NOT_FOUND_POOL = 203, /**< Specified POOL not found */
- LSM_ERR_NOT_FOUND_SS = 204, /**< Specified snap shot not found */
+ LSM_ERR_NOT_FOUND_FS_SS = 204, /**< Specified snap shot not found */
LSM_ERR_NOT_FOUND_VOLUME = 205, /**< Specified volume not found */
LSM_ERR_NOT_FOUND_NFS_EXPORT = 206, /**< NFS export not found */
LSM_ERR_NOT_FOUND_INITIATOR = 207, /**< Initiator not found */
LSM_ERR_NOT_FOUND_SYSTEM = 208, /**< System not found */
LSM_ERR_NOT_FOUND_DISK = 209, /**< Disk not found */

- LSM_ERR_NOT_IMPLEMENTED = 225, /**< Feature not implemented */
LSM_ERR_NOT_LICENSED = 226, /**< Need license for feature */

- LSM_ERR_OFF_LINE = 250, /**< Specified element is off line */
- LSM_ERR_ON_LINE = 251, /**< Specified element is on line */
+ LSM_ERR_NO_SUPPORT_ONLINE_CHANGE = 250, /**< Take offline before performing operation */
+ LSM_ERR_NO_SUPPORT_OFFLINE_CHANGE = 251, /**< Needs to be online to perform operation */

LSM_ERR_PLUGIN_AUTH_FAILED = 300, /**< Authorization failed */
- LSM_ERR_PLUGIN_DLOPEN = 301, /**< dlopen on plugin failed */
- LSM_ERR_PLUGIN_DLSYM = 302, /**< Required symbols in plugin missing */
- LSM_ERR_PLUGIN_ERROR = 303, /**< Non-descript plugin error */
- LSM_ERR_PLUGIN_MISSING_HOST = 304, /**< Missing or invalid hostname */
- LSM_ERR_PLUGIN_MISSING_NS = 305, /**< Missing namespace */
- LSM_ERR_PLUGIN_MISSING_PORT = 306, /**< Missing port */
- LSM_ERR_PLUGIN_PERMISSIONS = 307, /**< Unable to access plugin */
+ LSM_ERR_PLUGIN_IPC_FAIL = 301, /**< dlopen on plugin failed */
+
+ LSM_ERR_PLUGIN_SOCKET_PERMISSION = 307, /**< Unable to access plugin */
LSM_ERR_PLUGIN_REGISTRATION = 308, /**< Error during plug-in registration */
- LSM_ERR_PLUGIN_UNKNOWN_HOST = 309, /**< Name resolution failed */
- LSM_ERR_PLUGIN_TIMEOUT = 310, /**< Plug-in timed out talking to array */
LSM_ERR_PLUGIN_NOT_EXIST = 311, /**< Plug-in does not appear to exist */

- LSM_ERR_SIZE_INSUFFICIENT_SPACE = 350, /**< Insufficient space */
+ LSM_ERR_NOT_ENOUGH_SPACE = 350, /**< Insufficient space */
LSM_ERR_VOLUME_SAME_SIZE = 351, /**< Trying to resize to same size */
- LSM_ERR_SIZE_TOO_LARGE = 352, /**< Size specified is too large */
LSM_ERR_SIZE_TOO_SMALL = 353, /**< Size specified is too small */
LSM_ERR_SIZE_LIMIT_REACHED = 354, /**< Limit has been reached */

- LSM_ERR_TRANSPORT_COMMUNICATION = 400, /**< Error comunicating with plug-in */
- LSM_ERR_TRANSPORT_SERIALIZATION = 401, /**< Transport serialization error */
+ LSM_ERR_TRANSPORT_COMMUNICATION = 400, /**< Error comunicating with plug-in */
+ LSM_ERR_TRANSPORT_SERIALIZATION = 401, /**< Transport serialization error */
LSM_ERR_TRANSPORT_INVALID_ARG = 402, /**< Parameter transported over IPC is invalid */

- LSM_ERR_UNSUPPORTED_INITIATOR_TYPE = 450, /**< Unsupported initiator type */
- LSM_ERR_UNSUPPORTED_PROVISIONING = 451, /**< Unsupported provisioning */
- LSM_ERR_UNSUPPORTED_REPLICATION_TYPE = 452, /**< Unsupported replication type */
-
LSM_ERR_DISK_BUSY = 500, /* Disk already in use */
LSM_ERR_VOLUME_BUSY = 501, /* Volume already in use */
+ ACCESS_GROUP_MASKED = 502,
+

+ LSM_ERR_UNSUPPORTED_SEARCH_KEY = 510, /**< Unsupport search key */

- LSM_ERR_UNSUPPORTED_SEARCH_KEY = 510 /**< Unsupport search key */
+ EMPTY_ACCESS_GROUP = 511

} lsm_error_number;

diff --git a/c_binding/lsm_datatypes.cpp b/c_binding/lsm_datatypes.cpp
index fa2adab..8e53158 100644
--- a/c_binding/lsm_datatypes.cpp
+++ b/c_binding/lsm_datatypes.cpp
@@ -61,7 +61,7 @@ extern "C" {

int lsm_string_list_append(lsm_string_list *sl, const char *value)
{
- int rc = LSM_ERR_INVALID_SL;
+ int rc = LSM_ERR_INVALID_ARGUMENT;

if( LSM_IS_STRING_LIST(sl) ) {
char *d = strdup(value);
@@ -77,14 +77,12 @@ int lsm_string_list_append(lsm_string_list *sl, const char *value)

int lsm_string_list_delete(lsm_string_list *sl, uint32_t index)
{
- int rc = LSM_ERR_INVALID_SL;
+ int rc = LSM_ERR_INVALID_ARGUMENT;

if( LSM_IS_STRING_LIST(sl) ) {
if( index < sl->values->len ) {
g_ptr_array_remove_index(sl->values, index);
rc = LSM_ERR_OK;
- } else {
- rc = LSM_ERR_INDEX_BOUNDS;
}
}
return rc;
@@ -118,7 +116,7 @@ int lsm_string_list_elem_set(lsm_string_list *sl, uint32_t index,
}
}
} else {
- rc = LSM_ERR_INVALID_SL;
+ rc = LSM_ERR_INVALID_ARGUMENT;
}
return rc;
}
@@ -163,7 +161,7 @@ int lsm_string_list_free(lsm_string_list *sl)
free(sl);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_SL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

uint32_t lsm_string_list_size(lsm_string_list *sl)
@@ -311,24 +309,24 @@ int driver_load(lsm_connect *c, const char *plugin_name, const char *password,
c->tp = new Ipc(sd);
if( startup ) {
if( connection_establish(c, password, timeout, e, flags)) {
- rc = LSM_ERR_PLUGIN_DLOPEN;
+ rc = LSM_ERR_PLUGIN_IPC_FAIL;
}
}
} else {
- *e = lsm_error_create(LSM_ERR_PLUGIN_DLOPEN,
+ *e = lsm_error_create(LSM_ERR_PLUGIN_IPC_FAIL,
LSM_ERR_DOMAIN_FRAME_WORK,
LSM_ERR_LEVEL_ERROR, "Unable to connect to plugin",
NULL, dlerror(), NULL, 0 );

- rc = LSM_ERR_PLUGIN_DLOPEN;
+ rc = LSM_ERR_PLUGIN_IPC_FAIL;
}
} else {
- *e = lsm_error_create(LSM_ERR_PLUGIN_PERMISSIONS,
+ *e = lsm_error_create(LSM_ERR_PLUGIN_SOCKET_PERMISSION,
LSM_ERR_DOMAIN_FRAME_WORK,
LSM_ERR_LEVEL_ERROR, "Unable to access plugin",
NULL, NULL, NULL, 0 );

- rc = LSM_ERR_PLUGIN_PERMISSIONS;
+ rc = LSM_ERR_PLUGIN_SOCKET_PERMISSION;
}

free(plugin_file);
@@ -379,7 +377,7 @@ lsm_error_ptr lsm_error_create(lsm_error_number code, lsm_error_domain domain,
int lsm_error_free(lsm_error_ptr e)
{
if (!LSM_IS_ERROR(e)) {
- return LSM_ERR_INVALID_ERR;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if (e->debug_data) {
@@ -585,11 +583,11 @@ int lsm_pool_record_free(lsm_pool *p)
free(p);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_POOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

CREATE_FREE_ARRAY_FUNC(lsm_pool_record_array_free, lsm_pool_record_free, lsm_pool *,
- LSM_ERR_INVALID_POOL)
+ LSM_ERR_INVALID_ARGUMENT)

char *lsm_pool_name_get(lsm_pool *p)
{
@@ -763,11 +761,11 @@ int lsm_system_record_free(lsm_system *s)
free(s);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_SYSTEM;
+ return LSM_ERR_INVALID_ARGUMENT;
}

CREATE_FREE_ARRAY_FUNC(lsm_system_record_array_free, lsm_system_record_free,
- lsm_system *, LSM_ERR_INVALID_SYSTEM)
+ lsm_system *, LSM_ERR_INVALID_ARGUMENT)

lsm_system *lsm_system_record_copy(lsm_system *s)
{
@@ -852,11 +850,11 @@ int lsm_volume_record_free(lsm_volume *v)
free(v);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_VOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

CREATE_FREE_ARRAY_FUNC( lsm_volume_record_array_free, lsm_volume_record_free,
- lsm_volume *, LSM_ERR_INVALID_VOL)
+ lsm_volume *, LSM_ERR_INVALID_ARGUMENT)

lsm_disk *lsm_disk_record_copy(lsm_disk *disk)
{
@@ -884,11 +882,11 @@ int lsm_disk_record_free(lsm_disk *d)
free(d);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_DISK;
+ return LSM_ERR_INVALID_ARGUMENT;
}

CREATE_FREE_ARRAY_FUNC( lsm_disk_record_array_free, lsm_disk_record_free,
- lsm_disk *, LSM_ERR_INVALID_DISK)
+ lsm_disk *, LSM_ERR_INVALID_ARGUMENT)

/* We would certainly expand this to encompass the entire function */
#define MEMBER_SET_REF(x, validation, member, value, alloc_func, free_func, error) \
@@ -1053,11 +1051,11 @@ int lsm_access_group_record_free(lsm_access_group *ag)
free(ag);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_ACCESS_GROUP;
+ return LSM_ERR_INVALID_ARGUMENT;
}

CREATE_FREE_ARRAY_FUNC(lsm_access_group_record_array_free, lsm_access_group_record_free,
- lsm_access_group *, LSM_ERR_INVALID_ACCESS_GROUP)
+ lsm_access_group *, LSM_ERR_INVALID_ARGUMENT)

const char *lsm_access_group_id_get( lsm_access_group *group )
{
@@ -1133,7 +1131,7 @@ int lsm_block_range_record_free( lsm_block_range *br )
free(br);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_BLOCK_RANGE;
+ return LSM_ERR_INVALID_ARGUMENT;
}

lsm_block_range *lsm_block_range_record_copy( lsm_block_range *source )
@@ -1150,7 +1148,7 @@ lsm_block_range *lsm_block_range_record_copy( lsm_block_range *source )

CREATE_ALLOC_ARRAY_FUNC(lsm_block_range_record_array_alloc, lsm_block_range *)
CREATE_FREE_ARRAY_FUNC(lsm_block_range_record_array_free, lsm_block_range_record_free,
- lsm_block_range *, LSM_ERR_INVALID_BLOCK_RANGE)
+ lsm_block_range *, LSM_ERR_INVALID_ARGUMENT)


uint64_t lsm_block_range_source_start_get(lsm_block_range *br)
@@ -1211,7 +1209,7 @@ int lsm_fs_record_free( lsm_fs *fs)
free(fs);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_FS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

lsm_fs *lsm_fs_record_copy(lsm_fs *source)
@@ -1230,7 +1228,7 @@ lsm_fs *lsm_fs_record_copy(lsm_fs *source)

CREATE_ALLOC_ARRAY_FUNC(lsm_fs_record_array_alloc, lsm_fs *)
CREATE_FREE_ARRAY_FUNC(lsm_fs_record_array_free, lsm_fs_record_free, lsm_fs *,
- LSM_ERR_INVALID_FS)
+ LSM_ERR_INVALID_ARGUMENT)

const char *lsm_fs_id_get(lsm_fs *fs)
{
@@ -1309,12 +1307,12 @@ int lsm_fs_ss_record_free( lsm_fs_ss *ss)
free(ss);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_SS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

CREATE_ALLOC_ARRAY_FUNC(lsm_fs_ss_record_array_alloc, lsm_fs_ss *)
CREATE_FREE_ARRAY_FUNC(lsm_fs_ss_record_array_free, lsm_fs_ss_record_free, lsm_fs_ss *,
- LSM_ERR_INVALID_SS)
+ LSM_ERR_INVALID_ARGUMENT)

const char *lsm_fs_ss_id_get(lsm_fs_ss *ss)
{
@@ -1403,7 +1401,7 @@ int lsm_nfs_export_record_free( lsm_nfs_export *exp )
free(exp);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_NFS;
+ return LSM_ERR_INVALID_ARGUMENT;
}


@@ -1419,7 +1417,7 @@ lsm_nfs_export *lsm_nfs_export_record_copy( lsm_nfs_export *s )

CREATE_ALLOC_ARRAY_FUNC(lsm_nfs_export_record_array_alloc, lsm_nfs_export *)
CREATE_FREE_ARRAY_FUNC(lsm_nfs_export_record_array_free, lsm_nfs_export_record_free,
- lsm_nfs_export *, LSM_ERR_INVALID_NFS)
+ lsm_nfs_export *, LSM_ERR_INVALID_ARGUMENT)

const char *lsm_nfs_export_id_get( lsm_nfs_export *exp )
{
@@ -1429,7 +1427,7 @@ const char *lsm_nfs_export_id_get( lsm_nfs_export *exp )
int lsm_nfs_export_id_set(lsm_nfs_export *exp, const char *ep )
{
MEMBER_SET_REF(exp, LSM_IS_NFS_EXPORT, id, ep, strdup, free,
- LSM_ERR_INVALID_NFS);
+ LSM_ERR_INVALID_ARGUMENT);
}

const char *lsm_nfs_export_fs_id_get( lsm_nfs_export *exp )
@@ -1440,7 +1438,7 @@ const char *lsm_nfs_export_fs_id_get( lsm_nfs_export *exp )
int lsm_nfs_export_fs_id_set( lsm_nfs_export *exp, const char *fs_id)
{
MEMBER_SET_REF(exp, LSM_IS_NFS_EXPORT, fs_id, fs_id, strdup, free,
- LSM_ERR_INVALID_NFS);
+ LSM_ERR_INVALID_ARGUMENT);
}

const char *lsm_nfs_export_export_path_get( lsm_nfs_export *exp )
@@ -1451,7 +1449,7 @@ const char *lsm_nfs_export_export_path_get( lsm_nfs_export *exp )
int lsm_nfs_export_export_path_set( lsm_nfs_export *exp, const char *ep )
{
MEMBER_SET_REF(exp, LSM_IS_NFS_EXPORT, export_path, ep, strdup, free,
- LSM_ERR_INVALID_NFS);
+ LSM_ERR_INVALID_ARGUMENT);
}

const char *lsm_nfs_export_auth_type_get( lsm_nfs_export *exp )
@@ -1462,7 +1460,7 @@ const char *lsm_nfs_export_auth_type_get( lsm_nfs_export *exp )
int lsm_nfs_export_auth_type_set( lsm_nfs_export *exp, const char *auth )
{
MEMBER_SET_REF(exp, LSM_IS_NFS_EXPORT, auth_type, auth, strdup, free,
- LSM_ERR_INVALID_NFS);
+ LSM_ERR_INVALID_ARGUMENT);
}

lsm_string_list * lsm_nfs_export_root_get( lsm_nfs_export *exp)
@@ -1473,7 +1471,7 @@ lsm_string_list * lsm_nfs_export_root_get( lsm_nfs_export *exp)
int lsm_nfs_export_root_set( lsm_nfs_export *exp, lsm_string_list *root)
{
MEMBER_SET_REF(exp, LSM_IS_NFS_EXPORT, root, root, lsm_string_list_copy,
- lsm_string_list_free, LSM_ERR_INVALID_NFS);
+ lsm_string_list_free, LSM_ERR_INVALID_ARGUMENT);
}

lsm_string_list * lsm_nfs_export_read_write_get( lsm_nfs_export *exp)
@@ -1484,7 +1482,7 @@ lsm_string_list * lsm_nfs_export_read_write_get( lsm_nfs_export *exp)
int lsm_nfs_export_read_write_set( lsm_nfs_export *exp, lsm_string_list *rw)
{
MEMBER_SET_REF(exp, LSM_IS_NFS_EXPORT, rw, rw, lsm_string_list_copy,
- lsm_string_list_free, LSM_ERR_INVALID_NFS);
+ lsm_string_list_free, LSM_ERR_INVALID_ARGUMENT);
}

lsm_string_list * lsm_nfs_export_read_only_get( lsm_nfs_export *exp)
@@ -1495,7 +1493,7 @@ lsm_string_list * lsm_nfs_export_read_only_get( lsm_nfs_export *exp)
int lsm_nfs_export_read_only_set(lsm_nfs_export *exp, lsm_string_list *ro)
{
MEMBER_SET_REF(exp, LSM_IS_NFS_EXPORT, ro, ro, lsm_string_list_copy,
- lsm_string_list_free, LSM_ERR_INVALID_NFS);
+ lsm_string_list_free, LSM_ERR_INVALID_ARGUMENT);
}

uint64_t lsm_nfs_export_anon_uid_get( lsm_nfs_export *exp )
@@ -1506,7 +1504,7 @@ uint64_t lsm_nfs_export_anon_uid_get( lsm_nfs_export *exp )
int lsm_nfs_export_anon_uid_set( lsm_nfs_export *exp, uint64_t value)
{
MEMBER_SET_VAL(exp, LSM_IS_NFS_EXPORT, anonuid, value,
- LSM_ERR_INVALID_NFS);
+ LSM_ERR_INVALID_ARGUMENT);
}

uint64_t lsm_nfs_export_anon_gid_get( lsm_nfs_export *exp )
@@ -1517,7 +1515,7 @@ uint64_t lsm_nfs_export_anon_gid_get( lsm_nfs_export *exp )
int lsm_nfs_export_anon_gid_set( lsm_nfs_export *exp, uint64_t value )
{
MEMBER_SET_VAL(exp, LSM_IS_NFS_EXPORT, anongid, value,
- LSM_ERR_INVALID_NFS);
+ LSM_ERR_INVALID_ARGUMENT);
}

const char *lsm_nfs_export_options_get( lsm_nfs_export *exp)
@@ -1528,7 +1526,7 @@ const char *lsm_nfs_export_options_get( lsm_nfs_export *exp)
int lsm_nfs_export_options_set( lsm_nfs_export *exp, const char *value )
{
MEMBER_SET_REF(exp, LSM_IS_NFS_EXPORT, options, value, strdup, free,
- LSM_ERR_INVALID_NFS);
+ LSM_ERR_INVALID_ARGUMENT);
}

MEMBER_FUNC_GET(const char *, lsm_nfs_export_plugin_data_get,
@@ -1559,14 +1557,13 @@ int lsm_capability_set(lsm_storage_capabilities *cap, lsm_capability_type t,
{
int rc = LSM_ERR_INVALID_ARGUMENT;

- if( !LSM_IS_CAPABILITIY(cap) ) {
- return LSM_ERR_INVALID_CAPABILITY;
+ if( LSM_IS_CAPABILITIY(cap) ) {
+ if( (uint32_t)t < cap->len) {
+ cap->cap[t] = v;
+ rc = LSM_ERR_OK;
+ }
}

- if( (uint32_t)t < cap->len) {
- cap->cap[t] = v;
- rc = LSM_ERR_OK;
- }
return rc;
}

@@ -1578,7 +1575,7 @@ int lsm_capability_set_n( lsm_storage_capabilities *cap,
int index = 0;

if( !LSM_IS_CAPABILITIY(cap) ) {
- return LSM_ERR_INVALID_CAPABILITY;
+ return LSM_ERR_INVALID_ARGUMENT;
}

va_list var_arg;
@@ -1680,7 +1677,7 @@ int lsm_capability_record_free(lsm_storage_capabilities *cap)
free(cap);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_CAPABILITY;
+ return LSM_ERR_INVALID_ARGUMENT;
}

char* capability_string(lsm_storage_capabilities *c)
@@ -1745,7 +1742,7 @@ int lsm_hash_free(lsm_hash *op)
free(op);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_HASH;
+ return LSM_ERR_INVALID_ARGUMENT;
}

int lsm_hash_keys(lsm_hash *op, lsm_string_list **l)
@@ -1771,7 +1768,7 @@ int lsm_hash_keys(lsm_hash *op, lsm_string_list **l)
}
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_HASH;
+ return LSM_ERR_INVALID_ARGUMENT;
}

const char *lsm_hash_string_get(lsm_hash *op,
@@ -1801,7 +1798,7 @@ int lsm_hash_string_set(lsm_hash *op,
return LSM_ERR_NO_MEMORY;
}
}
- return LSM_ERR_INVALID_HASH;
+ return LSM_ERR_INVALID_ARGUMENT;
}

lsm_target_port *lsm_target_port_record_alloc( const char *id,
@@ -1886,7 +1883,7 @@ MEMBER_FUNC_GET(const char *, lsm_target_port_system_id_get, lsm_target_port *tp
CREATE_ALLOC_ARRAY_FUNC(lsm_target_port_record_array_alloc, lsm_target_port *)
CREATE_FREE_ARRAY_FUNC(lsm_target_port_record_array_free,
lsm_target_port_record_free, lsm_target_port *,
- LSM_ERR_INVALID_SS)
+ LSM_ERR_INVALID_ARGUMENT)



diff --git a/c_binding/lsm_mgmt.cpp b/c_binding/lsm_mgmt.cpp
index 7ca71c0..5805cf9 100644
--- a/c_binding/lsm_mgmt.cpp
+++ b/c_binding/lsm_mgmt.cpp
@@ -57,9 +57,9 @@ static const char * const TARGET_PORT_SEARCH_KEYS[] = {"id", "system_id"};
*/
#define CONN_SETUP(c) do { \
if(!LSM_IS_CONNECT(c)) { \
- return LSM_ERR_INVALID_CONN; \
+ return LSM_ERR_INVALID_ARGUMENT;\
} \
- lsm_error_free(c->error); \
+ lsm_error_free(c->error); \
c->error = NULL; \
} while (0)

@@ -116,7 +116,7 @@ int lsm_connect_password(const char *uri, const char *password,
rc = LSM_ERR_NO_MEMORY;
}
} else {
- rc = LSM_ERR_INVALID_URI;
+ rc = LSM_ERR_INVALID_ARGUMENT;
}

/*If we fail for any reason free resources associated with connection*/
@@ -131,12 +131,8 @@ int lsm_connect_password(const char *uri, const char *password,

static int lsmErrorLog(lsm_connect *c, lsm_error_ptr error)
{
- if (!LSM_IS_CONNECT(c)) {
- return LSM_ERR_INVALID_CONN;
- }
-
- if (!LSM_IS_ERROR(error)) {
- return LSM_ERR_INVALID_ERR;
+ if ( !LSM_IS_CONNECT(c) || !LSM_IS_ERROR(error) ) {
+ return LSM_ERR_INVALID_ARGUMENT;
}

if (c->error) {
@@ -649,11 +645,8 @@ int lsm_capabilities(lsm_connect *c, lsm_system *system,
int rc = LSM_ERR_OK;
CONN_SETUP(c);

- if( !LSM_IS_SYSTEM(system) ) {
- return LSM_ERR_INVALID_SYSTEM;
- }
-
- if( CHECK_RP(cap) || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_SYSTEM(system) || CHECK_RP(cap) ||
+ LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -954,11 +947,7 @@ int lsm_pool_create(lsm_connect *c, lsm_system *system,
{
CONN_SETUP(c);

- if( !LSM_IS_SYSTEM(system) ) {
- return LSM_ERR_INVALID_SYSTEM;
- }
-
- if( CHECK_STR(pool_name) || !size_bytes ||
+ if( !LSM_IS_SYSTEM(system) || CHECK_STR(pool_name) || !size_bytes ||
CHECK_RP(pool)|| CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ||
!valid_pool_raid_type(raid_type) ||
!valid_pool_member_type(member_type)) {
@@ -993,17 +982,12 @@ static int lsm_pool_create_from(lsm_connect *c,
{
CONN_SETUP(c);

- if( !LSM_IS_SYSTEM(system) ) {
- return LSM_ERR_INVALID_SYSTEM;
- }
-
- if( CHECK_STR(pool_name) ||
+ if( !LSM_IS_SYSTEM(system) || CHECK_STR(pool_name) ||
CHECK_RP(pool)|| CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ||
!valid_pool_raid_type(raid_type) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

-
std::map<std::string, Value> p;
p["system"] = system_to_value(system);
p["pool_name"] = Value(pool_name);
@@ -1055,15 +1039,7 @@ int LSM_DLL_EXPORT lsm_pool_create_from_disks(lsm_connect *c,
{
CONN_SETUP(c);

- if( !LSM_IS_SYSTEM(system) ) {
- return LSM_ERR_INVALID_SYSTEM;
- }
-
- if( !LSM_IS_POOL(pool) ) {
- return LSM_ERR_INVALID_POOL;
- }
-
- if( CHECK_STR(pool_name) ||
+ if( !LSM_IS_SYSTEM(system) || !LSM_IS_POOL(pool) || CHECK_STR(pool_name) ||
!size_bytes || CHECK_RP(created_pool)|| CHECK_RP(job) ||
LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
@@ -1093,7 +1069,7 @@ int lsm_pool_delete(lsm_connect *c, lsm_pool *pool, char **job, lsm_flag flags)
CONN_SETUP(c);

if( !LSM_IS_POOL(pool) ) {
- return LSM_ERR_INVALID_POOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if (CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
@@ -1136,7 +1112,7 @@ int lsm_volume_create(lsm_connect *c, lsm_pool *pool, const char *volumeName,
CONN_SETUP(c);

if( !LSM_IS_POOL(pool)) {
- return LSM_ERR_INVALID_POOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( CHECK_STR(volumeName) || !size || CHECK_RP(newVolume) ||
@@ -1168,12 +1144,8 @@ int lsm_volume_resize(lsm_connect *c, lsm_volume *volume,
{
CONN_SETUP(c);

- if( !LSM_IS_VOL(volume)) {
- return LSM_ERR_INVALID_VOL;
- }
-
- if( !newSize || CHECK_RP(resizedVolume) || CHECK_RP(job)
- || newSize == 0 || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_VOL(volume) || !newSize || CHECK_RP(resizedVolume) ||
+ CHECK_RP(job) || newSize == 0 || LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1205,12 +1177,8 @@ int lsm_volume_replicate(lsm_connect *c, lsm_pool *pool,
{
CONN_SETUP(c);

- if( pool && !LSM_IS_POOL(pool) ) {
- return LSM_ERR_INVALID_POOL;
- }
-
- if( !LSM_IS_VOL(volumeSrc) ) {
- return LSM_ERR_INVALID_VOL;
+ if( pool && !LSM_IS_POOL(pool) || !LSM_IS_VOL(volumeSrc) ) {
+ return LSM_ERR_INVALID_ARGUMENT;
}

if(CHECK_STR(name) || CHECK_RP(newReplicant) || CHECK_RP(job) ||
@@ -1243,14 +1211,10 @@ int lsm_volume_replicate_range_block_size(lsm_connect *c, lsm_system *system,
int rc = LSM_ERR_OK;
CONN_SETUP(c);

- if( !bs || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !bs || LSM_FLAG_UNUSED_CHECK(flags) || !LSM_IS_SYSTEM(system) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

- if( !LSM_IS_SYSTEM(system) ) {
- return LSM_ERR_INVALID_SYSTEM;
- }
-
try {
std::map<std::string, Value> p;
p["system"] = system_to_value(system);
@@ -1283,7 +1247,7 @@ int lsm_volume_replicate_range(lsm_connect *c,
CONN_SETUP(c);

if( !LSM_IS_VOL(source) || !LSM_IS_VOL(dest) ) {
- return LSM_ERR_INVALID_VOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( !ranges || !num_ranges || CHECK_RP(job) ||
@@ -1312,7 +1276,7 @@ int lsm_volume_delete(lsm_connect *c, lsm_volume *volume, char **job,
CONN_SETUP(c);

if( !LSM_IS_VOL(volume) ) {
- return LSM_ERR_INVALID_VOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
@@ -1381,7 +1345,7 @@ static int online_offline(lsm_connect *c, lsm_volume *v,
CONN_SETUP(c);

if( !LSM_IS_VOL(v)) {
- return LSM_ERR_INVALID_VOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if ( LSM_FLAG_UNUSED_CHECK(flags) ) {
@@ -1442,12 +1406,8 @@ int lsm_access_group_create(lsm_connect *c, const char *name,
{
CONN_SETUP(c);

- if( !LSM_IS_SYSTEM(system) ) {
- return LSM_ERR_INVALID_SYSTEM;
- }
-
- if( CHECK_STR(name) || CHECK_STR(init_id) || CHECK_RP(access_group) ||
- LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_SYSTEM(system) || CHECK_STR(name) || CHECK_STR(init_id) ||
+ CHECK_RP(access_group) || LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1478,11 +1438,7 @@ int lsm_access_group_delete(lsm_connect *c, lsm_access_group *access_group,
{
CONN_SETUP(c);

- if( !LSM_IS_ACCESS_GROUP(access_group) ){
- return LSM_ERR_INVALID_ACCESS_GROUP;
- }
-
- if( LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_ACCESS_GROUP(access_group) || LSM_FLAG_UNUSED_CHECK(flags) ){
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1505,12 +1461,8 @@ int lsm_access_group_initiator_add(lsm_connect *c,
{
CONN_SETUP(c);

- if( !LSM_IS_ACCESS_GROUP(access_group) ) {
- return LSM_ERR_INVALID_ACCESS_GROUP;
- }
-
- if( CHECK_STR(init_id) || LSM_FLAG_UNUSED_CHECK(flags) ||
- CHECK_RP(updated_access_group)) {
+ if( !LSM_IS_ACCESS_GROUP(access_group) || CHECK_STR(init_id) ||
+ LSM_FLAG_UNUSED_CHECK(flags) || CHECK_RP(updated_access_group)) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1542,12 +1494,8 @@ int lsm_access_group_initiator_delete(lsm_connect *c,
{
CONN_SETUP(c);

- if( !LSM_IS_ACCESS_GROUP(access_group)) {
- return LSM_ERR_INVALID_ACCESS_GROUP;
- }
-
- if( CHECK_STR(initiator_id) || LSM_FLAG_UNUSED_CHECK(flags) ||
- CHECK_RP(updated_access_group)) {
+ if( !LSM_IS_ACCESS_GROUP(access_group) || CHECK_STR(initiator_id) ||
+ LSM_FLAG_UNUSED_CHECK(flags) || CHECK_RP(updated_access_group)) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1576,15 +1524,8 @@ int lsm_volume_mask(lsm_connect *c, lsm_access_group *access_group,
{
CONN_SETUP(c);

- if( !LSM_IS_ACCESS_GROUP(access_group)) {
- return LSM_ERR_INVALID_ACCESS_GROUP;
- }
-
- if( !LSM_IS_VOL(volume) ) {
- return LSM_ERR_INVALID_VOL;
- }
-
- if( LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_ACCESS_GROUP(access_group) || !LSM_IS_VOL(volume) ||
+ LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1606,15 +1547,8 @@ int lsm_volume_unmask(lsm_connect *c, lsm_access_group *group,
{
CONN_SETUP(c);

- if( !LSM_IS_ACCESS_GROUP(group)) {
- return LSM_ERR_INVALID_ACCESS_GROUP;
- }
-
- if( !LSM_IS_VOL(volume)) {
- return LSM_ERR_INVALID_VOL;
- }
-
- if( LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_ACCESS_GROUP(group) || !LSM_IS_VOL(volume) ||
+ LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1637,11 +1571,8 @@ int lsm_volumes_accessible_by_access_group(lsm_connect *c,
int rc = LSM_ERR_OK;
CONN_SETUP(c);

- if( !LSM_IS_ACCESS_GROUP(group)) {
- return LSM_ERR_INVALID_ACCESS_GROUP;
- }
-
- if( !volumes || !count || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_ACCESS_GROUP(group) ||
+ !volumes || !count || LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1687,7 +1618,7 @@ int lsm_access_groups_granted_to_volume(lsm_connect *c,
CONN_SETUP(c);

if( !LSM_IS_VOL(volume)) {
- return LSM_ERR_INVALID_VOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( !groups || !groupCount || LSM_FLAG_UNUSED_CHECK(flags) ) {
@@ -1712,7 +1643,7 @@ int lsm_volume_child_dependency(lsm_connect *c, lsm_volume *volume,
CONN_SETUP(c);

if( !LSM_IS_VOL(volume)) {
- return LSM_ERR_INVALID_VOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( !yes || LSM_FLAG_UNUSED_CHECK(flags) ) {
@@ -1752,11 +1683,7 @@ int lsm_volume_child_dependency_delete(lsm_connect *c, lsm_volume *volume,
{
CONN_SETUP(c);

- if( !LSM_IS_VOL(volume)) {
- return LSM_ERR_INVALID_VOL;
- }
-
- if( CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_VOL(volume) || CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1884,7 +1811,7 @@ int lsm_fs_create(lsm_connect *c, lsm_pool *pool, const char *name,
CONN_SETUP(c);

if( !LSM_IS_POOL(pool)) {
- return LSM_ERR_INVALID_POOL;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( CHECK_STR(name) || !size_bytes || CHECK_RP(fs) || CHECK_RP(job)
@@ -1913,11 +1840,7 @@ int lsm_fs_delete(lsm_connect *c, lsm_fs *fs, char **job, lsm_flag flags)
{
CONN_SETUP(c);

- if( !LSM_IS_FS(fs) ) {
- return LSM_ERR_INVALID_FS;
- }
-
- if( CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_FS(fs) || CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1939,11 +1862,8 @@ int lsm_fs_resize(lsm_connect *c, lsm_fs *fs,
{
CONN_SETUP(c);

- if( !LSM_IS_FS(fs)) {
- return LSM_ERR_INVALID_FS;
- }
-
- if( !new_size_bytes || CHECK_RP(rfs) || CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_FS(fs) || !new_size_bytes || CHECK_RP(rfs) || CHECK_RP(job) ||
+ LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -1970,11 +1890,8 @@ int lsm_fs_clone(lsm_connect *c, lsm_fs *src_fs,
{
CONN_SETUP(c);

- if( !LSM_IS_FS(src_fs)) {
- return LSM_ERR_INVALID_FS;
- }
-
- if( CHECK_STR(name) || CHECK_RP(cloned_fs) || CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_FS(src_fs) || CHECK_STR(name) || CHECK_RP(cloned_fs) ||
+ CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

@@ -2001,11 +1918,7 @@ int lsm_fs_file_clone(lsm_connect *c, lsm_fs *fs, const char *src_file_name,
{
CONN_SETUP(c);

- if( !LSM_IS_FS(fs)) {
- return LSM_ERR_INVALID_FS;
- }
-
- if( CHECK_STR(src_file_name) || CHECK_STR(dest_file_name)
+ if( !LSM_IS_FS(fs) || CHECK_STR(src_file_name) || CHECK_STR(dest_file_name)
|| CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}
@@ -2031,12 +1944,12 @@ int lsm_fs_child_dependency( lsm_connect *c, lsm_fs *fs, lsm_string_list *files,
CONN_SETUP(c);

if( !LSM_IS_FS(fs) ) {
- return LSM_ERR_INVALID_FS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( files ) {
if( !LSM_IS_STRING_LIST(files) ) {
- return LSM_ERR_INVALID_SL;
+ return LSM_ERR_INVALID_ARGUMENT;
}
}

@@ -2079,12 +1992,12 @@ int lsm_fs_child_dependency_delete( lsm_connect *c, lsm_fs *fs, lsm_string_list
CONN_SETUP(c);

if( !LSM_IS_FS(fs)) {
- return LSM_ERR_INVALID_FS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( files ) {
if( !LSM_IS_STRING_LIST(files) ) {
- return LSM_ERR_INVALID_SL;
+ return LSM_ERR_INVALID_ARGUMENT;
}
}

@@ -2111,7 +2024,7 @@ int lsm_fs_ss_list(lsm_connect *c, lsm_fs *fs, lsm_fs_ss **ss[],
CONN_SETUP(c);

if( !LSM_IS_FS(fs) ) {
- return LSM_ERR_INVALID_FS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( CHECK_RP(ss) || !ssCount ) {
@@ -2163,7 +2076,7 @@ int lsm_fs_ss_create(lsm_connect *c, lsm_fs *fs, const char *name, lsm_fs_ss **s
CONN_SETUP(c);

if( !LSM_IS_FS(fs)) {
- return LSM_ERR_INVALID_FS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( CHECK_STR(name) || CHECK_RP(snapshot) || CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
@@ -2192,11 +2105,11 @@ int lsm_fs_ss_delete(lsm_connect *c, lsm_fs *fs, lsm_fs_ss *ss, char **job,
CONN_SETUP(c);

if( !LSM_IS_FS(fs) ) {
- return LSM_ERR_INVALID_FS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( !LSM_IS_SS(ss) ) {
- return LSM_ERR_INVALID_SS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ) {
@@ -2223,22 +2136,22 @@ int lsm_fs_ss_restore(lsm_connect *c, lsm_fs *fs, lsm_fs_ss *ss,
CONN_SETUP(c);

if( !LSM_IS_FS(fs) ) {
- return LSM_ERR_INVALID_FS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( !LSM_IS_SS(ss) ) {
- return LSM_ERR_INVALID_SS;
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( files ) {
if( !LSM_IS_STRING_LIST(files) ) {
- return LSM_ERR_INVALID_SL;
+ return LSM_ERR_INVALID_ARGUMENT;
}
}

if( restore_files ) {
if( !LSM_IS_STRING_LIST(restore_files) ) {
- return LSM_ERR_INVALID_SL;
+ return LSM_ERR_INVALID_ARGUMENT;
}
}

@@ -2335,19 +2248,19 @@ int lsm_nfs_export_fs( lsm_connect *c,

if( root_list ) {
if( !LSM_IS_STRING_LIST(root_list) ) {
- return LSM_ERR_INVALID_SL;
+ return LSM_ERR_INVALID_ARGUMENT;
}
}

if( rw_list ) {
if( !LSM_IS_STRING_LIST(rw_list) ) {
- return LSM_ERR_INVALID_SL;
+ return LSM_ERR_INVALID_ARGUMENT;
}
}

if( ro_list ) {
if( !LSM_IS_STRING_LIST(ro_list) ) {
- return LSM_ERR_INVALID_SL;
+ return LSM_ERR_INVALID_ARGUMENT;
}
}

@@ -2383,11 +2296,7 @@ int lsm_nfs_export_delete( lsm_connect *c, lsm_nfs_export *e, lsm_flag flags)
{
CONN_SETUP(c);

- if( !LSM_IS_NFS_EXPORT(e) ) {
- return LSM_ERR_INVALID_NFS;
- }
-
- if( LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !LSM_IS_NFS_EXPORT(e) || LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}

diff --git a/c_binding/lsm_plugin_ipc.cpp b/c_binding/lsm_plugin_ipc.cpp
index 68cbf44..b174d09 100644
--- a/c_binding/lsm_plugin_ipc.cpp
+++ b/c_binding/lsm_plugin_ipc.cpp
@@ -110,7 +110,7 @@ int lsm_register_plugin_v1(lsm_plugin_ptr plug,
struct lsm_san_ops_v1 *san_op, struct lsm_fs_ops_v1 *fs_op,
struct lsm_nas_ops_v1 *nas_op)
{
- int rc = LSM_ERR_INVALID_PLUGIN;
+ int rc = LSM_ERR_INVALID_ARGUMENT;

if(LSM_IS_PLUGIN(plug)) {
plug->private_data = private_data;
@@ -402,7 +402,7 @@ static int handle_job_status( lsm_plugin_ptr p, Value &params, Value &response)
result.push_back(pool_to_value((lsm_pool *)value));
lsm_pool_record_free((lsm_pool *)value);
} else {
- rc = LSM_ERR_PLUGIN_ERROR;
+ rc = LSM_ERR_PLUGIN_BUG;
}
}
response = Value(result);
@@ -2382,7 +2382,7 @@ static int lsm_plugin_run(lsm_plugin_ptr p)
lsm_plugin_free(p, flags);
p = NULL;
} else {
- rc = LSM_ERR_INVALID_PLUGIN;
+ rc = LSM_ERR_INVALID_ARGUMENT;
}

return rc;
@@ -2391,7 +2391,7 @@ static int lsm_plugin_run(lsm_plugin_ptr p)
int lsm_log_error_basic( lsm_plugin_ptr plug, lsm_error_number code, const char* msg )
{
if( !LSM_IS_PLUGIN(plug) ) {
- return LSM_ERR_INVALID_PLUGIN;
+ return LSM_ERR_INVALID_ARGUMENT;
}

lsm_error_ptr e = LSM_ERROR_CREATE_PLUGIN_MSG(code, msg);
@@ -2409,12 +2409,8 @@ int lsm_log_error_basic( lsm_plugin_ptr plug, lsm_error_number code, const char*

int lsm_plugin_error_log( lsm_plugin_ptr plug, lsm_error_ptr error)
{
- if( !LSM_IS_PLUGIN(plug) ) {
- return LSM_ERR_INVALID_PLUGIN;
- }
-
- if(!LSM_IS_ERROR(error) ) {
- return LSM_ERR_INVALID_ERR;
+ if( !LSM_IS_PLUGIN(plug) || !LSM_IS_ERROR(error) ) {
+ return LSM_ERR_INVALID_ARGUMENT;
}

if( plug->error ) {
@@ -2442,7 +2438,7 @@ int LSM_DLL_EXPORT lsm_uri_parse(const char *uri, char **scheme, char **user,
char **server, int *port, char **path,
lsm_hash **query_params)
{
- int rc = LSM_ERR_INVALID_URI;
+ int rc = LSM_ERR_INVALID_ARGUMENT;
xmlURIPtr u = NULL;

if( uri && strlen(uri) > 0 ) {
diff --git a/plugin/nstor/nstor.py b/plugin/nstor/nstor.py
index c29c712..b47b8b6 100644
--- a/plugin/nstor/nstor.py
+++ b/plugin/nstor/nstor.py
@@ -44,7 +44,7 @@ def handle_nstor_errors(method):
raise
except Exception as e:
error("Unexpected exception:\n" + traceback.format_exc())
- raise LsmError(ErrorNumber.PLUGIN_ERROR, str(e),
+ raise LsmError(ErrorNumber.PLUGIN_BUG, str(e),
traceback.format_exc())
return nstor_wrapper

@@ -83,7 +83,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
resp_json = response.read()
resp = json.loads(resp_json)
if resp['error']:
- raise LsmError(ErrorNumber.PLUGIN_ERROR, resp['error'])
+ raise LsmError(ErrorNumber.PLUGIN_BUG, resp['error'])
return resp['result']

def _request(self, method, obj, params):
@@ -297,7 +297,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):

@handle_nstor_errors
def fs_resize(self, fs, new_size_bytes, flags=0):
- raise LsmError(ErrorNumber.NOT_IMPLEMENTED, "Not implemented")
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not implemented")

@staticmethod
def _get_pool_id(fs_name):
@@ -563,7 +563,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
Note: Tuple return values are mutually exclusive, when one
is None the other must be valid.
"""
- raise LsmError(ErrorNumber.NOT_IMPLEMENTED,
+ raise LsmError(ErrorNumber.NO_SUPPORT,
"volume_replicate not implemented")

# if rep_type == Volume.REPLICATE_SNAPSHOT:
diff --git a/plugin/ontap/na.py b/plugin/ontap/na.py
index cd015a5..3890361 100644
--- a/plugin/ontap/na.py
+++ b/plugin/ontap/na.py
@@ -420,7 +420,7 @@ class Filer(object):
params['destination-path'] = dest_path

if backing_snapshot:
- raise FilerError(ErrorNumber.NOT_IMPLEMENTED,
+ raise FilerError(ErrorNumber.NO_SUPPORT,
"Support for backing luns not implemented "
"for this API version")
#params['snapshot-name']= backing_snapshot
@@ -460,7 +460,7 @@ class Filer(object):
elif progress['clone-state'] == 'completed':
return
else:
- raise FilerError(ErrorNumber.NOT_IMPLEMENTED,
+ raise FilerError(ErrorNumber.NO_SUPPORT,
'Unexpected state=' +
progress['clone-state'])
else:
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 6cf7ec0..067fc3f 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -32,21 +32,21 @@ from lsm import (Volume, FileSystem, FsSnapshot, NfsExport,

#Maps na to lsm, this is expected to expand over time.
e_map = {
- na.Filer.ENOSPC: ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ na.Filer.ENOSPC: ErrorNumber.NOT_ENOUGH_SPACE,
na.Filer.ENO_SUCH_VOLUME: ErrorNumber.NOT_FOUND_VOLUME,
- na.Filer.ESIZE_TOO_LARGE: ErrorNumber.SIZE_TOO_LARGE,
+ na.Filer.ESIZE_TOO_LARGE: ErrorNumber.NOT_ENOUGH_SPACE,
na.Filer.ENO_SUCH_FS: ErrorNumber.NOT_FOUND_FS,
na.Filer.EVOLUME_TOO_SMALL: ErrorNumber.SIZE_TOO_SMALL,
na.Filer.EAPILICENSE: ErrorNumber.NOT_LICENSED,
na.Filer.EFSDOESNOTEXIST: ErrorNumber.NOT_FOUND_FS,
- na.Filer.EFSOFFLINE: ErrorNumber.OFF_LINE,
- na.Filer.EFSNAMEINVALID: ErrorNumber.INVALID_NAME,
+ na.Filer.EFSOFFLINE: ErrorNumber.NO_SUPPORT_ONLINE_CHANGE,
+ na.Filer.EFSNAMEINVALID: ErrorNumber.INVALID_ARGUMENT,
na.Filer.ESERVICENOTLICENSED: ErrorNumber.NOT_LICENSED,
na.Filer.ECLONE_LICENSE_EXPIRED: ErrorNumber.NOT_LICENSED,
na.Filer.ECLONE_NOT_LICENSED: ErrorNumber.NOT_LICENSED,
- na.Filer.EINVALID_ISCSI_NAME: ErrorNumber.INVALID_INIT,
- na.Filer.ETIMEOUT: ErrorNumber.PLUGIN_TIMEOUT,
- na.Filer.EUNKNOWN: ErrorNumber.PLUGIN_ERROR
+ na.Filer.EINVALID_ISCSI_NAME: ErrorNumber.INVALID_ARGUMENT,
+ na.Filer.ETIMEOUT: ErrorNumber.TIMEOUT,
+ na.Filer.EUNKNOWN: ErrorNumber.PLUGIN_BUG
}


@@ -58,7 +58,7 @@ def error_map(oe):
if oe.errno in e_map:
return e_map[oe.errno], oe.reason
else:
- return ErrorNumber.PLUGIN_ERROR, \
+ return ErrorNumber.PLUGIN_BUG, \
oe.reason + " (vendor error code= " + str(oe.errno) + ")"


@@ -519,7 +519,7 @@ class Ontap(IStorageAreaNetwork, INfs):
def volume_create(self, pool, volume_name, size_bytes, provisioning,
flags=0):
if provisioning != Volume.PROVISION_DEFAULT:
- raise LsmError(ErrorNumber.UNSUPPORTED_PROVISIONING,
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"Unsupported provisioning")
na_aggrs = self.f.aggregates()
na_aggr_names = [x['name'] for x in na_aggrs]
@@ -732,7 +732,7 @@ class Ontap(IStorageAreaNetwork, INfs):
if g.name == name:
return g

- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
"access_group_create(): Unable to find access group "
"%s just created!" % name)

@@ -756,7 +756,7 @@ class Ontap(IStorageAreaNetwork, INfs):
raise
na_ags = self.f.igroups(access_group.name)
if len(na_ags) != 1:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"access_group_initiator_add(): Got unexpected"
"(not 1) count of na_ag: %s" % na_ags)

@@ -778,7 +778,7 @@ class Ontap(IStorageAreaNetwork, INfs):
raise
na_ags = self.f.igroups(access_group.name)
if len(na_ags) != 1:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"access_group_initiator_add(): Got unexpected"
"(not 1) count of na_ag: %s" % na_ags)

@@ -848,7 +848,7 @@ class Ontap(IStorageAreaNetwork, INfs):
@handle_ontap_errors
def job_status(self, job_id, flags=0):
if job_id is None and '@' not in job_id:
- raise LsmError(ErrorNumber.INVALID_JOB, "Invalid job, missing @")
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT, "Invalid job, missing @")

job = job_id.split('@', 2)

@@ -857,7 +857,7 @@ class Ontap(IStorageAreaNetwork, INfs):
elif job[0] == Ontap.SPLIT_JOB:
return self._clone_split_status(job[1])

- raise LsmError(ErrorNumber.INVALID_JOB, "Invalid job")
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT, "Invalid job")

@handle_ontap_errors
def job_free(self, job_id, flags=0):
@@ -1073,7 +1073,7 @@ class Ontap(IStorageAreaNetwork, INfs):
if e.fs_id == fs_id and e.export_path == export_path:
return e

- raise LsmError(ErrorNumber.PLUGIN_ERROR,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"export not created successfully!")

@handle_ontap_errors
diff --git a/plugin/sim/simarray.py b/plugin/sim/simarray.py
index d59a1b1..c81c851 100644
--- a/plugin/sim/simarray.py
+++ b/plugin/sim/simarray.py
@@ -759,7 +759,7 @@ class SimData(object):
member_sizes.extend([pool_each_size])

else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Got unsupported member_type in _size_of_raid()" +
": %d" % member_type)
all_size = 0
@@ -805,7 +805,7 @@ class SimData(object):
print "%s" % size_bytes_2_size_human(all_size)
print "%s" % size_bytes_2_size_human(member_size)
return int(all_size / 2 - member_size * 2)
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_size_of_raid() got invalid raid type: " +
"%s(%d)" % (Pool.raid_type_to_str(raid_type),
raid_type))
@@ -881,7 +881,7 @@ class SimData(object):
# check free size
free_space = self.pool_free_space(pool_id)
if (free_space < size_bytes):
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Insufficient space in pool")
sim_vol = dict()
sim_vol['vol_id'] = self._next_vol_id()
@@ -899,7 +899,7 @@ class SimData(object):
if vol_id in self.vol_dict.keys():
del(self.vol_dict[vol_id])
return
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such volume: %s" % vol_id)

def volume_resize(self, vol_id, new_size_bytes, flags=0):
@@ -908,26 +908,26 @@ class SimData(object):
pool_id = self.vol_dict[vol_id]['pool_id']
free_space = self.pool_free_space(pool_id)
if (free_space < new_size_bytes):
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Insufficient space in pool")

self.vol_dict[vol_id]['total_space'] = new_size_bytes
self.vol_dict[vol_id]['consume_size'] = new_size_bytes
return self.vol_dict[vol_id]
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"No such volume: %s" % vol_id)

def volume_replicate(self, dst_pool_id, rep_type, src_vol_id, new_vol_name,
flags=0):
if src_vol_id not in self.vol_dict.keys():
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such volume: %s" % src_vol_id)
size_bytes = self.vol_dict[src_vol_id]['total_space']
size_bytes = SimData._block_rounding(size_bytes)
# check free size
free_space = self.pool_free_space(dst_pool_id)
if (free_space < size_bytes):
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Insufficient space in pool")
sim_vol = dict()
sim_vol['vol_id'] = self._next_vol_id()
@@ -963,11 +963,11 @@ class SimData(object):
def volume_replicate_range(self, rep_type, src_vol_id, dst_vol_id, ranges,
flags=0):
if src_vol_id not in self.vol_dict.keys():
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such Volume: %s" % src_vol_id)

if dst_vol_id not in self.vol_dict.keys():
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such Volume: %s" % dst_vol_id)

sim_reps = []
@@ -992,7 +992,7 @@ class SimData(object):

def volume_online(self, vol_id, flags=0):
if vol_id not in self.vol_dict.keys():
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such Volume: %s" % vol_id)
# TODO: Volume.STATUS_XXX does have indication about volume offline
# or online, meanwhile, cmdline does not support volume_online()
@@ -1001,7 +1001,7 @@ class SimData(object):

def volume_offline(self, vol_id, flags=0):
if vol_id not in self.vol_dict.keys():
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such Volume: %s" % vol_id)
# TODO: Volume.STATUS_XXX does have indication about volume offline
# or online, meanwhile, cmdline does not support volume_online()
@@ -1013,7 +1013,7 @@ class SimData(object):
If volume is a src or dst of a replication, we return True.
"""
if vol_id not in self.vol_dict.keys():
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such Volume: %s" % vol_id)
if 'replicate' in self.vol_dict[vol_id].keys() and \
self.vol_dict[vol_id]['replicate']:
@@ -1026,7 +1026,7 @@ class SimData(object):

def volume_child_dependency_rm(self, vol_id, flags=0):
if vol_id not in self.vol_dict.keys():
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such Volume: %s" % vol_id)
if 'replicate' in self.vol_dict[vol_id].keys() and \
self.vol_dict[vol_id]['replicate']:
@@ -1131,7 +1131,7 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
"Access group not found: %s" % ag_id)
if vol_id not in self.vol_dict.keys():
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such Volume: %s" % vol_id)
if 'mask' not in self.vol_dict[vol_id].keys():
self.vol_dict[vol_id]['mask'] = dict()
@@ -1144,7 +1144,7 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
"Access group not found: %s" % ag_id)
if vol_id not in self.vol_dict.keys():
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such Volume: %s" % vol_id)
if 'mask' not in self.vol_dict[vol_id].keys():
return None
@@ -1198,7 +1198,7 @@ class SimData(object):
# check free size
free_space = self.pool_free_space(pool_id)
if (free_space < size_bytes):
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Insufficient space in pool")
sim_fs = dict()
fs_id = self._next_fs_id()
@@ -1216,7 +1216,7 @@ class SimData(object):
if fs_id in self.fs_dict.keys():
del(self.fs_dict[fs_id])
return
- raise LsmError(ErrorNumber.INVALID_FS,
+ raise LsmError(ErrorNumber.NOT_FOUND_FS,
"No such File System: %s" % fs_id)

def fs_resize(self, fs_id, new_size_bytes, flags=0):
@@ -1225,14 +1225,14 @@ class SimData(object):
pool_id = self.fs_dict[fs_id]['pool_id']
free_space = self.pool_free_space(pool_id)
if (free_space < new_size_bytes):
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Insufficient space in pool")

self.fs_dict[fs_id]['total_space'] = new_size_bytes
self.fs_dict[fs_id]['free_space'] = new_size_bytes
self.fs_dict[fs_id]['consume_size'] = new_size_bytes
return self.fs_dict[fs_id]
- raise LsmError(ErrorNumber.INVALID_VOLUME,
+ raise LsmError(ErrorNumber.NOT_FOUND_FS,
"No such File System: %s" % fs_id)

def fs_clone(self, src_fs_id, dst_fs_name, snap_id, flags=0):
@@ -1240,7 +1240,7 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_FOUND_FS,
"File System: %s not found" % src_fs_id)
if snap_id and snap_id not in self.snap_dict.keys():
- raise LsmError(ErrorNumber.INVALID_SS,
+ raise LsmError(ErrorNumber.NOT_FOUND_FS_SS,
"No such Snapshot: %s" % snap_id)
src_sim_fs = self.fs_dict[src_fs_id]
dst_sim_fs = self.fs_create(
@@ -1257,7 +1257,7 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_FOUND_FS,
"File System: %s not found" % fs_id)
if snap_id and snap_id not in self.snap_dict.keys():
- raise LsmError(ErrorNumber.INVALID_SS,
+ raise LsmError(ErrorNumber.NOT_FOUND_FS_SS,
"No such Snapshot: %s" % snap_id)
# TODO: No file clone query API yet, no need to do anything internally
return None
@@ -1295,7 +1295,7 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_FOUND_FS,
"File System: %s not found" % fs_id)
if snap_id not in self.snap_dict.keys():
- raise LsmError(ErrorNumber.INVALID_SS,
+ raise LsmError(ErrorNumber.NOT_FOUND_FS_SS,
"No such Snapshot: %s" % snap_id)
del self.snap_dict[snap_id]
new_snap_ids = []
@@ -1311,7 +1311,7 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_FOUND_FS,
"File System: %s not found" % fs_id)
if snap_id not in self.snap_dict.keys():
- raise LsmError(ErrorNumber.INVALID_SS,
+ raise LsmError(ErrorNumber.NOT_FOUND_FS_SS,
"No such Snapshot: %s" % snap_id)
# Nothing need to done internally for restore.
return None
@@ -1407,7 +1407,7 @@ class SimData(object):

def fs_unexport(self, exp_id, flags=0):
if exp_id not in self.exp_dict.keys():
- raise LsmError(ErrorNumber.INVALID_NFS,
+ raise LsmError(ErrorNumber.NOT_FOUND_NFS_EXPORT,
"No such NFS Export: %s" % exp_id)
del self.exp_dict[exp_id]
return None
@@ -1487,7 +1487,7 @@ class SimData(object):
# 4. All disks' total space is the same.
if len(member_ids) <= 0:
if raise_error:
- raise LsmError(ErrorNumber.INVALID_DISK,
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"No disk ID defined")
else:
return None
@@ -1507,7 +1507,7 @@ class SimData(object):
for disk_id in member_ids:
if disk_id not in self.disk_dict.keys():
if raise_error:
- raise LsmError(ErrorNumber.INVALID_DISK,
+ raise LsmError(ErrorNumber.NOT_FOUND_DISK,
"The disk ID %s does not exist" % disk_id)
else:
return None
@@ -1586,7 +1586,7 @@ class SimData(object):
return newly create sim_pool or None.
"""
if sys_id != SimData.SIM_DATA_SYS_ID:
- raise LsmError(ErrorNumber.INVALID_SYSTEM,
+ raise LsmError(ErrorNumber.NOT_FOUND_SYSTEM,
"No such system: %s" % sys_id)

return self._pool_create_from_disks(pool_name, member_ids, raid_type,
@@ -1601,7 +1601,7 @@ class SimData(object):
if len(free_sim_pool_ids) == 0 or \
member_id not in free_sim_pool_ids:
if raise_error:
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Pool %s " % member_id +
"is full, no space to create new pool")
else:
@@ -1609,7 +1609,7 @@ class SimData(object):

free_size = self.pool_free_space(member_id)
if free_size < size_bytes:
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Pool %s does not have requested free" %
member_id + "to create new pool")

@@ -1633,7 +1633,7 @@ class SimData(object):
def pool_create_from_pool(self, sys_id, pool_name, member_id, size_bytes,
flags=0):
if sys_id != SimData.SIM_DATA_SYS_ID:
- raise LsmError(ErrorNumber.INVALID_SYSTEM,
+ raise LsmError(ErrorNumber.NOT_FOUND_SYSTEM,
"No such system: %s" % sys_id)
return self._pool_create_from_pool(pool_name, member_id, size_bytes,
raise_error=True)
@@ -1664,7 +1664,7 @@ class SimData(object):
if sim_disk['total_space'] >= size_bytes:
return [sim_disk]
if raise_error:
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"No %s is bigger than " % disk_type_str +
"expected size: %s(%d)" %
(size_bytes_2_size_human(size_bytes),
@@ -1690,7 +1690,7 @@ class SimData(object):
if all_free_size >= size_bytes:
return chose_sim_disks
if raise_error:
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"No enough %s to provide size %s(%d)" %
(disk_type_str,
size_bytes_2_size_human(size_bytes),
@@ -1716,7 +1716,7 @@ class SimData(object):
return cur_sim_disks[0:member_count]

if raise_error:
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"No enough %s " % disk_type_str +
"to create %s providing size: %s(%d)" %
(Pool.raid_type_to_str(raid_type),
@@ -1739,7 +1739,7 @@ class SimData(object):
return sim_pool

if raise_error:
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"No pool is bigger than expected size: " +
"%s(%d)" %
(size_bytes_2_size_human(size_bytes),
@@ -1751,7 +1751,7 @@ class SimData(object):
raid_type=Pool.RAID_TYPE_UNKNOWN,
member_type=Pool.MEMBER_TYPE_UNKNOWN, flags=0):
if sys_id != SimData.SIM_DATA_SYS_ID:
- raise LsmError(ErrorNumber.INVALID_SYSTEM,
+ raise LsmError(ErrorNumber.NOT_FOUND_SYSTEM,
"No such system: %s" % sys_id)

size_bytes = SimData._block_rounding(size_bytes)
@@ -1806,12 +1806,12 @@ class SimData(object):
return sim_pool

# only member_type == Pool.MEMBER_TYPE_UNKNOWN can reach here.
- raise LsmError(ErrorNumber.SIZE_INSUFFICIENT_SPACE,
+ raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"No enough free spaces to create new pool")

def pool_delete(self, pool_id, flags=0):
if pool_id not in self.pool_dict.keys():
- raise LsmError(ErrorNumber.INVALID_POOL,
+ raise LsmError(ErrorNumber.NOT_FOUND_POOL,
"Pool not found: %s" % pool_id)

volumes = self.volumes()
diff --git a/plugin/simc/simc_lsmplugin.c b/plugin/simc/simc_lsmplugin.c
index 496b8ed..cb2b7dd 100644
--- a/plugin/simc/simc_lsmplugin.c
+++ b/plugin/simc/simc_lsmplugin.c
@@ -313,7 +313,7 @@ static int tmo_set(lsm_plugin_ptr c, uint32_t timeout, lsm_flag flags )
pd->tmo = timeout;
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_PLUGIN;
+ return LSM_ERR_INVALID_ARGUMENT;
}

static int tmo_get(lsm_plugin_ptr c, uint32_t *timeout, lsm_flag flags)
@@ -324,7 +324,7 @@ static int tmo_get(lsm_plugin_ptr c, uint32_t *timeout, lsm_flag flags)
*timeout = pd->tmo;
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_PLUGIN;
+ return LSM_ERR_INVALID_ARGUMENT;
}

static int cap(lsm_plugin_ptr c, lsm_system *system,
@@ -419,7 +419,7 @@ static int job_status(lsm_plugin_ptr c, const char *job_id,
rc = LSM_ERR_NOT_FOUND_JOB;
}
} else {
- rc = LSM_ERR_INVALID_PLUGIN;
+ rc = LSM_ERR_INVALID_ARGUMENT;
}

return rc;
@@ -484,7 +484,7 @@ static int list_systems(lsm_plugin_ptr c, lsm_system **systems[],
}
return LSM_ERR_NO_MEMORY;
} else {
- return LSM_ERR_INVALID_PLUGIN;
+ return LSM_ERR_INVALID_ARGUMENT;
}
}

@@ -498,7 +498,7 @@ static int job_free(lsm_plugin_ptr c, char *job_id, lsm_flag flags)
rc = LSM_ERR_NOT_FOUND_JOB;
}
} else {
- rc = LSM_ERR_INVALID_PLUGIN;
+ rc = LSM_ERR_INVALID_ARGUMENT;
}

return rc;
@@ -776,7 +776,7 @@ static int volume_create(lsm_plugin_ptr c, lsm_pool *pool,
}

} else {
- rc = lsm_log_error_basic(c, LSM_ERR_SIZE_INSUFFICIENT_SPACE,
+ rc = lsm_log_error_basic(c, LSM_ERR_NOT_ENOUGH_SPACE,
"Insufficient space in pool");
}

@@ -892,7 +892,7 @@ static int volume_resize(lsm_plugin_ptr c, lsm_volume *volume,
} else {
/*Could not accommodate re-sized, go back */
pool_allocate(p, curr_size);
- rc = lsm_log_error_basic(c, LSM_ERR_SIZE_INSUFFICIENT_SPACE,
+ rc = lsm_log_error_basic(c, LSM_ERR_NOT_ENOUGH_SPACE,
"Insufficient space in pool");
}

@@ -1262,7 +1262,7 @@ static int access_group_initiator_delete( lsm_plugin_ptr c,
lsm_access_group **updated_access_group,
lsm_flag flags)
{
- int rc = LSM_ERR_INITIATOR_NOT_IN_ACCESS_GROUP;
+ int rc = LSM_ERR_INVALID_ARGUMENT;
struct plugin_data *pd = (struct plugin_data*)lsm_private_data_get(c);

struct allocated_ag *find = (struct allocated_ag *)
@@ -1681,7 +1681,7 @@ static int fs_create(lsm_plugin_ptr c, lsm_pool *pool, const char *name,
rc = lsm_log_error_basic(c, LSM_ERR_NO_MEMORY, "ENOMEM");
}
} else {
- rc = lsm_log_error_basic(c, LSM_ERR_SIZE_INSUFFICIENT_SPACE,
+ rc = lsm_log_error_basic(c, LSM_ERR_NOT_ENOUGH_SPACE,
"Insufficient space in pool");
}
} else {
@@ -1756,7 +1756,7 @@ static int fs_resize(lsm_plugin_ptr c, lsm_fs *fs,
} else {
/*Could not accommodate re-sized, go back */
pool_allocate(p, lsm_fs_total_space_get(tfs));
- rc = lsm_log_error_basic(c, LSM_ERR_SIZE_INSUFFICIENT_SPACE,
+ rc = lsm_log_error_basic(c, LSM_ERR_NOT_ENOUGH_SPACE,
"Insufficient space in pool");
}

@@ -1931,7 +1931,7 @@ static int ss_delete(lsm_plugin_ptr c, lsm_fs *fs, lsm_fs_ss *ss,

if( find ) {
if( !g_hash_table_remove(find->ss, lsm_fs_ss_id_get(ss)) ) {
- rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_SS,
+ rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_FS_SS,
"snapshot not found");
} else {
rc = create_job(pd, job, LSM_DATA_TYPE_NONE, NULL, NULL);
@@ -1955,7 +1955,7 @@ static int ss_restore(lsm_plugin_ptr c, lsm_fs *fs, lsm_fs_ss *ss,

if( find ) {
if(!g_hash_table_lookup(find->ss, lsm_fs_ss_id_get(ss))) {
- rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_SS,
+ rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_FS_SS,
"snapshot not found");
} else {
rc = create_job(pd, job, LSM_DATA_TYPE_NONE, NULL, NULL);
@@ -2327,7 +2327,7 @@ int unload( lsm_plugin_ptr c, lsm_flag flags)
_unload(pd);
return LSM_ERR_OK;
} else {
- return LSM_ERR_INVALID_PLUGIN;
+ return LSM_ERR_INVALID_ARGUMENT;
}
}

diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 024a613..368b606 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -99,14 +99,14 @@ def handle_cim_errors(method):
elif 'HTTP error' in desc:
raise LsmError(ErrorNumber.TRANSPORT_COMMUNICATION,
desc)
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG, desc)
+ raise LsmError(ErrorNumber.PLUGIN_BUG, desc)
except pywbem.cim_http.AuthError as ae:
raise LsmError(ErrorNumber.PLUGIN_AUTH_FAILED, "Unauthorized user")
except pywbem.cim_http.Error as te:
raise LsmError(ErrorNumber.NETWORK_ERROR, str(te))
except Exception as e:
error("Unexpected exception:\n" + traceback.format_exc())
- raise LsmError(ErrorNumber.PLUGIN_ERROR, str(e),
+ raise LsmError(ErrorNumber.PLUGIN_BUG, str(e),
traceback.format_exc())
return cim_wrapper

@@ -608,7 +608,7 @@ class Smis(IStorageAreaNetwork):
return cim_xxx

if raise_error:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Unable to find class instance %s " % class_name +
"with property %s " % prop_name +
"with value %s" % prop_value)
@@ -655,11 +655,11 @@ class Smis(IStorageAreaNetwork):

except Exception:
tb = traceback.format_exc()
- raise LsmError(ErrorNumber.PLUGIN_ERROR,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
'Error: ' + msg + " rc= " + str(rc) +
' Debug data exception: ' + str(tb))

- raise LsmError(ErrorNumber.PLUGIN_ERROR,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
'Error: ' + msg + " rc= " + str(rc))

@handle_cim_errors
@@ -1185,7 +1185,7 @@ class Smis(IStorageAreaNetwork):
status = JobStatus.ERROR

else:
- raise LsmError(ErrorNumber.PLUGIN_ERROR,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
str(cim_job['ErrorDescription']))

return status, percent_complete, completed_item
@@ -1206,7 +1206,7 @@ class Smis(IStorageAreaNetwork):
return 'CIM_SCSIProtocolController'
if class_type == 'Initiator':
return 'CIM_StorageHardwareID'
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Smis._cim_class_name_of() got unknown " +
"class_type %s" % class_type)

@@ -1226,7 +1226,7 @@ class Smis(IStorageAreaNetwork):
return ErrorNumber.NOT_FOUND_ACCESS_GROUP
if class_type == 'Initiator':
return ErrorNumber.INVALID_ARGUMENT
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Smis._cim_class_name_of() got unknown " +
"class_type %s" % class_type)

@@ -1251,7 +1251,7 @@ class Smis(IStorageAreaNetwork):
elif class_type == 'Initiator':
rc = ['StorageID']
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Smis._property_list_of_id() got unknown " +
"class_type %s" % class_type)

@@ -1571,7 +1571,7 @@ class Smis(IStorageAreaNetwork):
PropertyList=pool_pros, LocalOnly=False)
return self._new_pool(cim_new_pool)
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Got not new Pool from out of InvokeMethod" +
"when CreateOrModifyElementFromStoragePool")

@@ -1773,7 +1773,7 @@ class Smis(IStorageAreaNetwork):
if pool:
rc.extend([pool])
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Failed to retrieve pool information " +
"from CIM_StoragePool: %s" % cim_pool.path)
return search_property(rc, search_key, search_value)
@@ -1873,7 +1873,7 @@ class Smis(IStorageAreaNetwork):
Create a volume.
"""
if provisioning != Volume.PROVISION_DEFAULT:
- raise LsmError(ErrorNumber.UNSUPPORTED_PROVISIONING,
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"Unsupported provisioning")

# Get the Configuration service for the system we are interested in.
@@ -1903,7 +1903,7 @@ class Smis(IStorageAreaNetwork):
return i
else:
raise LsmError(
- ErrorNumber.PLUGIN_ERROR,
+ ErrorNumber.PLUGIN_BUG,
msg + ", job error code= " + str(s))

def _detach(self, vol, sync):
@@ -2162,7 +2162,7 @@ class Smis(IStorageAreaNetwork):
elif len(cim_srvs) == 0:
return None
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_get_cim_service_path(): Got unexpected(not 1) "
"count of %s from cim_sys %s: %s" %
(class_name, cim_sys_path, cim_srvs))
@@ -2606,7 +2606,7 @@ class Smis(IStorageAreaNetwork):
raise LsmError(ErrorNumber.NO_SUPPORT,
'AccessGroup is not supported by this array')
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Got %d instance of " % len(cim_ccss_path) +
"ControllerConfigurationService from %s" %
cim_sys_path + " in _cim_spc_of()")
@@ -2885,7 +2885,7 @@ class Smis(IStorageAreaNetwork):
list(self._cim_spc_to_lsm(cim_spc, system_id)
for cim_spc in cim_spcs))
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_get_cim_spc_by_id(): Got invalid mask_type: "
"%s" % mask_type)

@@ -3086,7 +3086,7 @@ class Smis(IStorageAreaNetwork):
cim_spc_path,
AssocClass='CIM_ProtocolControllerForUnit',
ResultClass='CIM_StorageVolume')) >= 1:
- raise LsmError(ErrorNumber.ACCESS_GROUP_BUSY,
+ raise LsmError(ErrorNumber.ACCESS_GROUP_MASKED,
"Refuse to remove last initiator member "
"from access group which have volume "
"masked to")
@@ -3338,7 +3338,7 @@ class Smis(IStorageAreaNetwork):
# each CIM_DiskDrive
return cim_exts[0]
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Failed to find out Primordial " +
"CIM_StorageExtent for CIM_DiskDrive %s " %
cim_disk_path)
@@ -3555,7 +3555,7 @@ class Smis(IStorageAreaNetwork):
elif len(cim_disks) == 2:
return None
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"Found two or more CIM_DiskDrive associated to " +
"requested CIM_StorageExtent %s" %
cim_pri_ext_path)
@@ -4437,12 +4437,12 @@ class Smis(IStorageAreaNetwork):
cim_iscsi_nodes.extend([cim_spc])

if len(cim_iscsi_nodes) == 0:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_iscsi_node_of(): No iSCSI node "
"CIM_SCSIProtocolController associated to %s"
% cim_iscsi_pg_path)
if len(cim_iscsi_nodes) > 1:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_iscsi_node_of(): Got two or more iSCSI node "
"CIM_SCSIProtocolController associated to %s: %s"
% (cim_iscsi_pg_path, cim_iscsi_nodes))
@@ -4507,7 +4507,7 @@ class Smis(IStorageAreaNetwork):
AssocClass='CIM_BindsTo',
PropertyList=['PortNumber'])
if len(cim_tcps) == 0:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_cim_iscsi_pg_to_lsm(): "
"No CIM_TCPProtocolEndpoint associated to %s"
% cim_iscsi_pg.path)
@@ -4728,13 +4728,13 @@ class Smis(IStorageAreaNetwork):
if out_key in out:
if flag_out_array:
if len(out[out_key]) != 1:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_wait_invoke(), %s is not length 1: %s"
% (out_key, out.items()))
return out[out_key][0]
return out[out_key]
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_wait_invoke(), %s not exist in out %s" %
(out_key, out.items()))
elif rc == Smis.INVOKE_ASYNC:
@@ -4761,11 +4761,11 @@ class Smis(IStorageAreaNetwork):
AssocClass='CIM_AffectedJobElement',
ResultClass=expect_class)
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_wait_invoke(): Got unknown job state "
"%d: %s" % (job_state, cim_job.items()))
if len(cim_xxxs_path) != 1:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_wait_invoke(): got unexpect(not 1) "
"return from CIM_AffectedJobElement: "
"%s, out: %s, job: %s" %
@@ -4773,7 +4773,7 @@ class Smis(IStorageAreaNetwork):
cim_job.items()))
return cim_xxxs_path[0]
else:
- raise LsmError(ErrorNumber.LSM_PLUGIN_BUG,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
"_wait_invoke(): Got unexpected rc code "
"%d, out: %s" % (rc, out.items()))

@@ -4988,7 +4988,7 @@ class Smis(IStorageAreaNetwork):
cim_spc_path,
AssocClass='CIM_ProtocolControllerForUnit',
ResultClass='CIM_StorageVolume')) >= 1:
- raise LsmError(ErrorNumber.MASKED_ACCESS_GROUP,
+ raise LsmError(ErrorNumber.ACCESS_GROUP_MASKED,
"Access Group %s has volume masked" %
access_group.id)

diff --git a/plugin/targetd/targetd.py b/plugin/targetd/targetd.py
index 597ee7d..9cf763e 100644
--- a/plugin/targetd/targetd.py
+++ b/plugin/targetd/targetd.py
@@ -290,7 +290,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
def volume_create(self, pool, volume_name, size_bytes, provisioning,
flags=0):
if provisioning != Volume.PROVISION_DEFAULT:
- raise LsmError(ErrorNumber.UNSUPPORTED_PROVISIONING,
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"Unsupported provisioning")

self._jsonrequest("vol_create", dict(pool=pool.id,
@@ -537,7 +537,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):

fs_path = self._get_fs_path(fs_id)
if fs_path is None:
- raise LsmError(ErrorNumber.INVALID_FS, "File system not found")
+ raise LsmError(ErrorNumber.NOT_FOUND_FS, "File system not found")

for host in rw_list:
tmp_opts = copy.copy(base_opts)
@@ -578,7 +578,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
if host_entry in l:
return host

- raise LsmError(ErrorNumber.PLUGIN_ERROR, "Failed to create export")
+ raise LsmError(ErrorNumber.PLUGIN_BUG, "Failed to create export")

@handle_errors
def export_remove(self, export, flags=0):
@@ -600,7 +600,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
request = urllib2.Request(self.url, data, self.headers)
response_obj = urllib2.urlopen(request)
except socket.error:
- raise LsmError(ErrorNumber.NO_CONNECT,
+ raise LsmError(ErrorNumber.NETWORK_ERROR,
"Unable to connect to targetd, uri right?")

response_data = response_obj.read()
@@ -624,5 +624,5 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
if status:
if status[0]:
raise LsmError(
- ErrorNumber.LSM_PLUGIN_BUG,
+ ErrorNumber.PLUGIN_BUG,
"%d has error %d" % (async_code, status[0]))
diff --git a/python_binding/lsm/_common.py b/python_binding/lsm/_common.py
index 386d9a9..d11c170 100644
--- a/python_binding/lsm/_common.py
+++ b/python_binding/lsm/_common.py
@@ -73,7 +73,7 @@ def common_urllib2_error_handler(exp):

stack_trace = traceback.format_exc()
error("Unexpected exception:\n" + stack_trace)
- raise LsmError(ErrorNumber.PLUGIN_ERROR, "Unexpected exception",
+ raise LsmError(ErrorNumber.PLUGIN_BUG, "Unexpected exception",
stack_trace)


@@ -275,13 +275,13 @@ def uri_parse(uri, requires=None, required_params=None):
if requires:
for r in requires:
if r not in rc:
- raise LsmError(ErrorNumber.PLUGIN_ERROR,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
'uri missing \"%s\" or is in invalid form' % r)

if required_params:
for r in required_params:
if r not in rc['parameters']:
- raise LsmError(ErrorNumber.PLUGIN_ERROR,
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
'uri missing query parameter %s' % r)
return rc

@@ -422,11 +422,10 @@ class ErrorLevel(object):
#using them.
class ErrorNumber(object):
OK = 0
- LSM_LIB_BUG = 1
- LSM_PLUGIN_BUG = 2
- LSM_STORAGE_SDK_BUG = 3
+ LIB_BUG = 1
+ PLUGIN_BUG = 2
+ STORAGE_SDK_BUG = 3
JOB_STARTED = 7
- INDEX_BOUNDS = 10
TIMEOUT = 11
DAEMON_NOT_RUNNING = 12

@@ -438,26 +437,7 @@ class ErrorNumber(object):
EXISTS_POOL = 56
EXISTS_VOLUME = 57

- INVALID_ACCESS_GROUP = 100
INVALID_ARGUMENT = 101
- INVALID_CONN = 102
- INVALID_ERR = 103
- INVALID_FS = 104
- INVALID_JOB = 106
- INVALID_NAME = 107
- INVALID_NFS = 108
- INVALID_PLUGIN = 109
- INVALID_POOL = 110
- INVALID_SL = 111
- INVALID_SS = 112
- INVALID_URI = 113
- INVALID_VALUE = 114
- INVALID_VOLUME = 115
- INVALID_CAPABILITY = 116
- INVALID_SYSTEM = 117
- INVALID_INIT = 118
- INVALID_DISK = 119
- INVALID_BLOCK_RANGE = 121

IS_MAPPED = 125

@@ -465,7 +445,6 @@ class ErrorNumber(object):
NETWORK_HOSTDOWN = 141 # Host unreachable on network
NETWORK_ERROR = 142 # Generic network error

- NO_CONNECT = 150
NO_MAPPING = 151
NO_MEMORY = 152
NO_SUPPORT = 153
@@ -474,34 +453,26 @@ class ErrorNumber(object):
NOT_FOUND_FS = 201
NOT_FOUND_JOB = 202
NOT_FOUND_POOL = 203
- NOT_FOUND_SS = 204
+ NOT_FOUND_FS_SS = 204
NOT_FOUND_VOLUME = 205
NOT_FOUND_NFS_EXPORT = 206
NOT_FOUND_SYSTEM = 208
NOT_FOUND_DISK = 209

- NOT_IMPLEMENTED = 225
NOT_LICENSED = 226

- OFF_LINE = 250
- ON_LINE = 251
+ NO_SUPPORT_ONLINE_CHANGE = 250
+ NO_SUPPORT_OFFLINE_CHANGE = 251

PLUGIN_AUTH_FAILED = 300
- PLUGIN_DLOPEN = 301
- PLUGIN_DLSYM = 302
- PLUGIN_ERROR = 303
- PLUGIN_MISSING_HOST = 304
- PLUGIN_MISSING_NS = 305
- PLUGIN_MISSING_PORT = 306
- PLUGIN_PERMISSION = 307
+ PLUGIN_IPC_FAIL = 301
+
+ PLUGIN_SOCKET_PERMISSION = 307
PLUGIN_REGISTRATION = 308
- PLUGIN_UNKNOWN_HOST = 309
- PLUGIN_TIMEOUT = 310
PLUGIN_NOT_EXIST = 311

- SIZE_INSUFFICIENT_SPACE = 350
+ NOT_ENOUGH_SPACE = 350
SIZE_SAME = 351
- SIZE_TOO_LARGE = 352
SIZE_TOO_SMALL = 353
SIZE_LIMIT_REACHED = 354

@@ -509,22 +480,17 @@ class ErrorNumber(object):
TRANSPORT_SERIALIZATION = 401
TRANSPORT_INVALID_ARG = 402

- UNSUPPORTED_PROVISIONING = 451
- UNSUPPORTED_REPLICATION_TYPE = 452
-
DISK_BUSY = 500
VOLUME_BUSY = 501
- ACCESS_GROUP_BUSY = 502 # refuse to remove the last initiator from
- # access group which have volume masked.
+ ACCESS_GROUP_MASKED = 502 # refuse to remove the last initiator from
+ # access group which have volume masked or
+ # allow an access group to be deleted

UNSUPPORTED_SEARCH_KEY = 510

EMPTY_ACCESS_GROUP = 511 # volume_mask() will fail if access group
# has no member/initiator.

- MASKED_ACCESS_GROUP = 512 # access_group_delete() will fail if
- # have volume masked.
-
_LOCALS = locals()

@staticmethod
diff --git a/python_binding/lsm/_data.py b/python_binding/lsm/_data.py
index d6feed8..17df3ec 100644
--- a/python_binding/lsm/_data.py
+++ b/python_binding/lsm/_data.py
@@ -692,14 +692,14 @@ class AccessGroup(IData):
if AccessGroup._regex_iscsi_iqn.match(str(init_id)):
return True
if raise_error:
- raise LsmError(ErrorNumber.INVALID_INIT,
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"Invalid iSCSI IQN Initiator: %s" % init_id)
return False
elif init_type == AccessGroup.INIT_TYPE_WWPN:
if AccessGroup._regex_lsm_wwpn.match(str(init_id)):
return True
if raise_error:
- raise LsmError(ErrorNumber.INVALID_INIT,
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"Invalid WWPN Initiator: %s" % init_id)
return False
elif raise_error:
@@ -750,7 +750,7 @@ class AccessGroup(IData):
s = ":".join(re.findall(r'..', s))
return s
if raise_error:
- raise LsmError(ErrorNumber.INVALID_INIT,
+ raise LsmError(ErrorNumber.INVALID_ARGUMENT,
"Invalid WWPN Initiator: %s" % wwpn)
return None

diff --git a/python_binding/lsm/_pluginrunner.py b/python_binding/lsm/_pluginrunner.py
index 024fc0d..49f7a96 100644
--- a/python_binding/lsm/_pluginrunner.py
+++ b/python_binding/lsm/_pluginrunner.py
@@ -138,7 +138,7 @@ class PluginRunner(object):
error("Unhandled exception in plug-in!\n" + traceback.format_exc())

try:
- self.tp.send_error(msg_id, ErrorNumber.PLUGIN_ERROR,
+ self.tp.send_error(msg_id, ErrorNumber.PLUGIN_BUG,
"Unhandled exception in plug-in",
str(traceback.format_exc()))
except Exception:
diff --git a/python_binding/lsm/_transport.py b/python_binding/lsm/_transport.py
index 9a4f00e..4498be2 100644
--- a/python_binding/lsm/_transport.py
+++ b/python_binding/lsm/_transport.py
@@ -101,7 +101,7 @@ class TransPort(object):
s.connect(path)
except socket.error:
#self, code, message, data=None, *args, **kwargs
- raise LsmError(ErrorNumber.NO_CONNECT,
+ raise LsmError(ErrorNumber.NETWORK_ERROR,
"Unable to connect to lsmd, daemon started?")
return s

diff --git a/test/tester.c b/test/tester.c
index 535a1a5..5ce641f 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -1228,14 +1228,14 @@ START_TEST(test_invalid_input)

rc = lsm_connect_password("INVALID_URI:\\yep", NULL, &test_connect, 20000,
&test_error, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_URI, "rc %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc %d", rc);


rc = lsm_connect_close((lsm_connect *)&bad, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_INVALID_CONN == rc, "rc %d", rc);
+ fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc %d", rc);

rc = lsm_connect_close((lsm_connect *)NULL, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_INVALID_CONN == rc, "rc %d", rc);
+ fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc %d", rc);



@@ -1386,11 +1386,11 @@ START_TEST(test_invalid_input)
job = NULL;

rc = lsm_volume_create(c, NULL, NULL, 0, 0, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_INVALID_POOL == rc, "rc %d", rc);
+ fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc %d", rc);

rc = lsm_volume_create(c, (lsm_pool *)&bad, "BAD_POOL", 10000000,
LSM_PROVISION_DEFAULT, &new_vol, &job, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_INVALID_POOL == rc, "rc %d", rc);
+ fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc %d", rc);

rc = lsm_volume_create(c, test_pool, "", 10000000, LSM_PROVISION_DEFAULT,
&new_vol, &job, LSM_FLAG_RSVD);
@@ -1421,7 +1421,7 @@ START_TEST(test_invalid_input)

/* lsmVolumeResize */
rc = lsm_volume_resize(c, NULL, 0, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_INVALID_VOL == rc, "rc %d", rc);
+ fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc %d", rc);


lsm_volume *resized = (lsm_volume *)&bad;
@@ -1447,7 +1447,7 @@ START_TEST(test_invalid_input)

/* lsmVolumeDelete */
rc = lsm_volume_delete(c, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_INVALID_VOL == rc, "rc %d", rc);
+ fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc %d", rc);

rc = lsm_volume_delete(c, resized, NULL, LSM_FLAG_RSVD);
fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc %d", rc);
@@ -1470,7 +1470,7 @@ START_TEST(test_invalid_input)


rc = lsm_capabilities(c, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_INVALID_SYSTEM, "rc %d", rc);
+ fail_unless(LSM_ERR_INVALID_ARGUMENT, "rc %d", rc);

if( num_systems ) {
rc = lsm_capabilities(c, sys[0], NULL, LSM_FLAG_RSVD);
@@ -1480,11 +1480,11 @@ START_TEST(test_invalid_input)
/* lsmVolumeReplicate */
lsm_volume *cloned = NULL;
rc = lsm_volume_replicate(c, (lsm_pool *)&bad, 0, NULL, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_POOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_replicate(c, test_pool, LSM_VOLUME_REPLICATE_CLONE, NULL,
"cloned", &cloned, &job, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_replicate(c, test_pool, LSM_VOLUME_REPLICATE_CLONE, new_vol,
"", &cloned, &job, LSM_FLAG_RSVD);
@@ -1506,11 +1506,11 @@ START_TEST(test_invalid_input)
/* lsmVolumeReplicateRange */
rc = lsm_volume_replicate_range(c, LSM_VOLUME_REPLICATE_CLONE, NULL, NULL,
NULL, 0, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_replicate_range(c, LSM_VOLUME_REPLICATE_CLONE, new_vol,
NULL, NULL, 0, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_replicate_range(c, LSM_VOLUME_REPLICATE_CLONE, new_vol, new_vol,
NULL, 1, &job, LSM_FLAG_RSVD);
@@ -1518,10 +1518,10 @@ START_TEST(test_invalid_input)


rc = lsm_volume_online(c, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_offline(c, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


/* lsmAccessGroupCreate */
@@ -1534,7 +1534,7 @@ START_TEST(test_invalid_input)

rc = lsm_access_group_create(c, "my_group", ISCSI_HOST[0], LSM_ACCESS_GROUP_INIT_TYPE_OTHER,
NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SYSTEM, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


rc = lsm_access_group_create(c, "my_group", ISCSI_HOST[0], LSM_ACCESS_GROUP_INIT_TYPE_OTHER,
@@ -1545,15 +1545,15 @@ START_TEST(test_invalid_input)

/* lsmAccessGroupDel */
rc = lsm_access_group_delete(c, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_ACCESS_GROUP, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

/* lsmAccessGroupInitiatorAdd */
rc = lsm_access_group_initiator_add(c, NULL, NULL, 0, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_ACCESS_GROUP, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


rc = lsm_access_group_initiator_delete(c, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_ACCESS_GROUP, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_access_group_initiator_delete(c, ag, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -1561,42 +1561,42 @@ START_TEST(test_invalid_input)


rc = lsm_volume_mask(c, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_ACCESS_GROUP, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_mask(c, ag, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_unmask(c, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_ACCESS_GROUP, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_unmask(c, ag, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


/* lsmVolumesAccessibleByAccessGroup */
rc = lsm_volumes_accessible_by_access_group(c, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_ACCESS_GROUP, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volumes_accessible_by_access_group(c, ag, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

/* lsmAccessGroupsGrantedToVolume */
rc = lsm_access_groups_granted_to_volume(c, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_access_groups_granted_to_volume(c, new_vol, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

/* lsmVolumeChildDependency */
rc = lsm_volume_child_dependency(c, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_child_dependency(c, new_vol, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

/*lsmVolumeChildDependencyDelete*/
rc = lsm_volume_child_dependency_delete(c, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_VOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_volume_child_dependency_delete(c, new_vol, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -1623,7 +1623,7 @@ START_TEST(test_invalid_input)

/*lsmFsCreate*/
rc = lsm_fs_create(c, NULL, NULL, 0, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_POOL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_create(c, test_pool, NULL, 0, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -1640,21 +1640,21 @@ START_TEST(test_invalid_input)

/* lsmFsDelete */
rc = lsm_fs_delete(c, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_delete(c, arg_fs, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

/* lsmFsResize */
rc = lsm_fs_resize(c, NULL, 0, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_resize(c, arg_fs, 0, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

/* lsmFsClone */
rc = lsm_fs_clone(c, NULL, NULL, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_clone(c, arg_fs, NULL, NULL, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -1662,18 +1662,18 @@ START_TEST(test_invalid_input)

/*lsmFsFileClone*/
rc = lsm_fs_file_clone(c, NULL, NULL, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_file_clone(c, arg_fs, NULL, NULL, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


rc = lsm_fs_child_dependency(c, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

lsm_string_list *badf = (lsm_string_list *)&bad;
rc = lsm_fs_child_dependency(c, arg_fs, badf, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

lsm_string_list *f = lsm_string_list_alloc(1);
rc = lsm_fs_child_dependency(c, arg_fs, f, NULL, LSM_FLAG_RSVD);
@@ -1681,10 +1681,10 @@ START_TEST(test_invalid_input)

/*lsmFsChildDependencyDelete*/
rc = lsm_fs_child_dependency_delete(c, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_child_dependency_delete(c, arg_fs, badf, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_child_dependency_delete(c, arg_fs, f, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -1692,7 +1692,7 @@ START_TEST(test_invalid_input)


rc = lsm_fs_ss_list(c, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


rc = lsm_fs_ss_list(c, arg_fs, NULL, NULL, LSM_FLAG_RSVD);
@@ -1700,7 +1700,7 @@ START_TEST(test_invalid_input)


rc = lsm_fs_ss_create(c, NULL, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_ss_create(c, arg_fs, NULL, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -1717,26 +1717,26 @@ START_TEST(test_invalid_input)
}

rc = lsm_fs_ss_delete(c, NULL, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_ss_delete(c, arg_fs, NULL, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_ss_delete(c, arg_fs, arg_ss, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


rc = lsm_fs_ss_restore(c, NULL, NULL, NULL, NULL, 0, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_FS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_ss_restore(c, arg_fs, NULL, NULL, NULL, 0, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_ss_restore(c, arg_fs, arg_ss, badf, NULL, 0, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_ss_restore(c, arg_fs, arg_ss, badf, badf, 0, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_fs_ss_restore(c, arg_fs, arg_ss, f, f, 0, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -1763,15 +1763,15 @@ START_TEST(test_invalid_input)

rc = lsm_nfs_export_fs(c, NULL, NULL, badf, NULL, NULL, 0,0,NULL, NULL, NULL,
LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_nfs_export_fs(c, NULL, NULL, f, badf, NULL, 0,0,NULL, NULL, NULL,
LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_nfs_export_fs(c, NULL, NULL, f, f, badf, 0,0,NULL, NULL, NULL,
LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_SL, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


rc = lsm_nfs_export_fs(c, NULL, NULL, f, f, f, 0,0, NULL, NULL, NULL,
@@ -1779,7 +1779,7 @@ START_TEST(test_invalid_input)
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_nfs_export_delete(c, NULL, LSM_FLAG_RSVD);
- fail_unless(rc == LSM_ERR_INVALID_NFS, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


rc = lsm_volume_record_free(new_vol);
@@ -1798,10 +1798,10 @@ START_TEST(test_invalid_input)
int flags = 10;

rc = lsm_pool_create(NULL, NULL, NULL, size, raid_type, member_type, NULL, NULL, flags);
- fail_unless(rc == LSM_ERR_INVALID_CONN, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_pool_create(c, NULL, NULL, size, raid_type, member_type, NULL, NULL, flags);
- fail_unless(rc == LSM_ERR_INVALID_SYSTEM, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

rc = lsm_pool_create(c, system, NULL, size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -1977,7 +1977,7 @@ START_TEST(test_plugin_info)
}

rc = lsm_plugin_info_get(NULL, &desc, &version, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_INVALID_CONN == rc, "rc = %d", rc);
+ fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc = %d", rc);

rc = lsm_plugin_info_get(c, NULL, &version, LSM_FLAG_RSVD);
fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc = %d", rc);
--
1.8.2.1
Tony Asleson
2014-08-13 23:22:13 UTC
Permalink
The issue is that when you go through teardown, if you use
fail_unless in it if you actuall fail you end up calling
teardown again and you get stuck in a loop until you exhaust
the fs with a tmpfile.

For this particular issue to show up you just need to cause an error
when closing the connection which is what happens when you close the
connection on a plug-in that exited already.

Gris, please verify it works for you too.

Signed-off-by: Tony Asleson <***@redhat.com>
---
test/tester.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/test/tester.c b/test/tester.c
index 5ce641f..e5680bb 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -161,11 +161,14 @@ void dump_error(lsm_error_ptr e)

void setup(void)
{
- lsm_error_ptr e = NULL;
+ /*
+ * Note: Do not use any error reporting functions in this function
+ */

- int rc = 0;
+ lsm_error_ptr e = NULL;

- G(rc, lsm_connect_password, plugin_to_use(), NULL, &c, 30000, &e, LSM_FLAG_RSVD);
+ int rc = lsm_connect_password(plugin_to_use(), NULL, &c, 30000, &e,
+ LSM_FLAG_RSVD);

if( LSM_ERR_OK == rc ) {
if( getenv("LSM_DEBUG_PLUGIN") ) {
@@ -177,9 +180,14 @@ void setup(void)

void teardown(void)
{
- int rc = 0;
- G(rc, lsm_connect_close, c, LSM_FLAG_RSVD);
- c = NULL;
+ /*
+ * Note: Do not use any error reporting functions in this function
+ */
+
+ if( c ) {
+ lsm_connect_close(c, LSM_FLAG_RSVD);
+ c = NULL;
+ }
}

void wait_for_job(lsm_connect *c, char **job_id)
--
1.8.2.1
Loading...