Tony Asleson
2014-08-19 23:29:00 UTC
Reduced the number of return codes and replaced with
NAME_CONFLICT == item with name already exists
NO_STATE_CHANGE == requested operation did nothing
This patch is incomplete as I want to introduce unit tests in the
plug_test.py which exercise all these error paths to ensure that
each of the plug-ins are working as expected.
make check runs clean, but NetApp, Nstor and SMI-S will need
improvements.
Signed-off-by: Tony Asleson <***@redhat.com>
---
.../include/libstoragemgmt/libstoragemgmt_error.h | 13 ++---
c_binding/lsm_mgmt.cpp | 2 +-
plugin/ontap/na.py | 4 ++
plugin/ontap/ontap.py | 8 ++-
plugin/sim/simarray.py | 58 ++++++++++++++++---
plugin/simc/simc_lsmplugin.c | 12 ++--
plugin/smispy/smis.py | 2 +-
python_binding/lsm/_client.py | 2 +-
python_binding/lsm/_common.py | 10 +---
test/plugin_test.py | 65 +++++++++++++++++++---
test/tester.c | 8 +--
11 files changed, 136 insertions(+), 48 deletions(-)
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
index 00a3ff9..fdb6ffa 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
@@ -51,17 +51,12 @@ typedef enum {
LSM_ERR_TIMEOUT = 11, /**< Plug-in is un-responsive */
LSM_ERR_DAEMON_NOT_RUNNING = 12, /**< Daemon is not running */
- LSM_ERR_EXISTS_ACCESS_GROUP = 50, /**< Access group exists */
- LSM_ERR_EXISTS_FS = 51, /**< FS exists */
- 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_EXISTS_POOL = 56, /**< Pool exists */
- LSM_ERR_EXISTS_VOLUME = 57, /**< Volume exists */
+ LSM_ERR_NAME_CONFLICT = 50, /**< Name exists */
+ LSM_ERR_EXISTS_INITIATOR = 52, /**< Initiator exists in another access group */
LSM_ERR_INVALID_ARGUMENT = 101, /**< Precondition checks failed */
- LSM_ERR_IS_MAPPED = 125, /**< Mapping already exists */
+ LSM_ERR_NO_STATE_CHANGE = 125, /**< Operation completed with no change in array state */
LSM_ERR_CONNREFUSED = 140, /**< Host on network, but not allowing connection */
LSM_ERR_HOSTDOWN = 141, /**< Host unreachable on network */
@@ -95,7 +90,7 @@ typedef enum {
LSM_ERR_PLUGIN_NOT_EXIST = 311, /**< Plug-in does not appear to exist */
LSM_ERR_NOT_ENOUGH_SPACE = 350, /**< Insufficient space */
- LSM_ERR_VOLUME_SAME_SIZE = 351, /**< Trying to resize to same size */
+
LSM_ERR_SIZE_TOO_SMALL = 353, /**< Size specified is too small */
LSM_ERR_SIZE_LIMIT_REACHED = 354, /**< Limit has been reached */
diff --git a/c_binding/lsm_mgmt.cpp b/c_binding/lsm_mgmt.cpp
index d48802d..b236549 100644
--- a/c_binding/lsm_mgmt.cpp
+++ b/c_binding/lsm_mgmt.cpp
@@ -993,7 +993,7 @@ int lsm_volume_resize(lsm_connect *c, lsm_volume *volume,
//If you try to resize to same size, we will return error.
if( ( newSize/volume->block_size) == volume->number_of_blocks ) {
- return LSM_ERR_VOLUME_SAME_SIZE;
+ return LSM_ERR_NO_STATE_CHANGE;
}
std::map<std::string, Value> p;
diff --git a/plugin/ontap/na.py b/plugin/ontap/na.py
index 25831e5..7803c65 100644
--- a/plugin/ontap/na.py
+++ b/plugin/ontap/na.py
@@ -164,9 +164,11 @@ class Filer(object):
Note: These are using lsm terminology.
"""
EUNKNOWN = 10 # Non-specific error
+ ENAVOL_NAME_DUPE = 17 # Volume name collision
ENOSPC = 28 # Out of space
ETIMEOUT = 60 # Time-out
EINVALID_ISCSI_NAME = 9006 # Invalid ISCSI IQN
+ EDUPE_VOLUME_PATH = 9012 # Duplicate volume name
ENO_SUCH_VOLUME = 9017 # lun not found
ESIZE_TOO_LARGE = 9034 # Specified too large a size
ENO_SUCH_FS = 9036 # FS not found
@@ -175,7 +177,9 @@ class Filer(object):
EFSDOESNOTEXIST = 13040 # FS does not exist
EFSOFFLINE = 13042 # FS is offline.
EFSNAMEINVALID = 13044 # FS Name invalid
+ ENOSPACE = 13062 # Not enough space
ESERVICENOTLICENSED = 13902 # Not licensed
+ ECLONE_NAME_EXISTS = 14952 # Clone with same name exists
ECLONE_LICENSE_EXPIRED = 14955 # Not licensed
ECLONE_NOT_LICENSED = 14956 # Not licensed
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 09dd942..1a0b851 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -35,6 +35,7 @@ e_map = {
na.Filer.ENOSPC: ErrorNumber.NOT_ENOUGH_SPACE,
na.Filer.ENO_SUCH_VOLUME: ErrorNumber.NOT_FOUND_VOLUME,
na.Filer.ESIZE_TOO_LARGE: ErrorNumber.NOT_ENOUGH_SPACE,
+ na.Filer.ENOSPACE: 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,
@@ -46,7 +47,10 @@ e_map = {
na.Filer.ECLONE_NOT_LICENSED: ErrorNumber.NOT_LICENSED,
na.Filer.EINVALID_ISCSI_NAME: ErrorNumber.INVALID_ARGUMENT,
na.Filer.ETIMEOUT: ErrorNumber.TIMEOUT,
- na.Filer.EUNKNOWN: ErrorNumber.PLUGIN_BUG
+ na.Filer.EUNKNOWN: ErrorNumber.PLUGIN_BUG,
+ na.Filer.EDUPE_VOLUME_PATH: ErrorNumber.NAME_CONFLICT,
+ na.Filer.ENAVOL_NAME_DUPE: ErrorNumber.NAME_CONFLICT,
+ na.Filer.ECLONE_NAME_EXISTS: ErrorNumber.NAME_CONFLICT
}
@@ -717,7 +721,7 @@ class Ontap(IStorageAreaNetwork, INfs):
cur_groups = self.access_groups()
for cg in cur_groups:
if cg.name == name:
- raise LsmError(ErrorNumber.EXISTS_ACCESS_GROUP,
+ raise LsmError(ErrorNumber.NAME_CONFLICT,
"Access group with the same name exists!")
if init_type == AccessGroup.INIT_TYPE_ISCSI_IQN:
diff --git a/plugin/sim/simarray.py b/plugin/sim/simarray.py
index d0519ea..9c22546 100644
--- a/plugin/sim/simarray.py
+++ b/plugin/sim/simarray.py
@@ -914,7 +914,7 @@ class SimData(object):
def volume_create(self, pool_id, vol_name, size_bytes, thinp, flags=0):
self._check_dup_name(
- self.vol_dict.values(), vol_name, ErrorNumber.EXISTS_VOLUME)
+ self.vol_dict.values(), vol_name, ErrorNumber.NAME_CONFLICT)
size_bytes = SimData._block_rounding(size_bytes)
# check free size
free_space = self.pool_free_space(pool_id)
@@ -949,10 +949,14 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Insufficient space in pool")
+ if self.vol_dict[vol_id]['total_space'] == new_size_bytes:
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE, "New size same "
+ "as current")
+
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_ARGUMENT,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such volume: %s" % vol_id)
def volume_replicate(self, dst_pool_id, rep_type, src_vol_id, new_vol_name,
@@ -960,6 +964,10 @@ class SimData(object):
if src_vol_id not in self.vol_dict.keys():
raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such volume: %s" % src_vol_id)
+
+ self._check_dup_name(self.vol_dict.values(), new_vol_name,
+ ErrorNumber.NAME_CONFLICT)
+
size_bytes = self.vol_dict[src_vol_id]['total_space']
size_bytes = SimData._block_rounding(size_bytes)
# check free size
@@ -1101,6 +1109,11 @@ class SimData(object):
raise LsmError(error_num, "Name '%s' already in use" % name)
def access_group_create(self, name, init_id, init_type, sys_id, flags=0):
+
+ # Check to see if we have an access group with this name
+ self._check_dup_name(self.ag_dict.values(), name,
+ ErrorNumber.NAME_CONFLICT)
+
exist_sim_ag = self._sim_ag_of_init(init_id)
if exist_sim_ag:
if exist_sim_ag['name'] == name:
@@ -1116,7 +1129,7 @@ class SimData(object):
if init_id in exist_sim_ag['init_ids']:
return exist_sim_ag
else:
- raise LsmError(ErrorNumber.EXISTS_ACCESS_GROUP,
+ raise LsmError(ErrorNumber.NAME_CONFLICT,
"Another access group %s(%s) is using " %
(exist_sim_ag['name'], exist_sim_ag['ag_id']) +
"requested name %s but not contain init_id %s" %
@@ -1143,7 +1156,8 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
"Access group not found")
if init_id in self.ag_dict[ag_id]['init_ids']:
- return self.ag_dict[ag_id]
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE, "Initiator already "
+ "in access group")
self._sim_ag_of_init(init_id)
@@ -1163,6 +1177,11 @@ class SimData(object):
new_init_ids.extend([cur_init_id])
del(self.ag_dict[ag_id]['init_ids'])
self.ag_dict[ag_id]['init_ids'] = new_init_ids
+ else:
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE,
+ "Initiator %s type %s not in access group %s"
+ % (init_id, str(type(init_id)),
+ str(self.ag_dict[ag_id]['init_ids'])))
return self.ag_dict[ag_id]
def volume_mask(self, ag_id, vol_id, flags=0):
@@ -1175,6 +1194,11 @@ class SimData(object):
if 'mask' not in self.vol_dict[vol_id].keys():
self.vol_dict[vol_id]['mask'] = dict()
+ if ag_id in self.vol_dict[vol_id]['mask']:
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE, "Volume already "
+ "masked to access "
+ "group")
+
self.vol_dict[vol_id]['mask'][ag_id] = 2
return None
@@ -1189,7 +1213,9 @@ class SimData(object):
return None
if ag_id not in self.vol_dict[vol_id]['mask'].keys():
- return None
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE, "Volume not "
+ "masked to access "
+ "group")
del(self.vol_dict[vol_id]['mask'][ag_id])
return None
@@ -1233,6 +1259,10 @@ class SimData(object):
return self.fs_dict.values()
def fs_create(self, pool_id, fs_name, size_bytes, flags=0):
+
+ self._check_dup_name(self.fs_dict.values(), fs_name,
+ ErrorNumber.NAME_CONFLICT)
+
size_bytes = SimData._block_rounding(size_bytes)
# check free size
free_space = self.pool_free_space(pool_id)
@@ -1267,6 +1297,10 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Insufficient space in pool")
+ if self.fs_dict[fs_id]['total_space'] == new_size_bytes:
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE,
+ "New size same as current")
+
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
@@ -1281,11 +1315,18 @@ class SimData(object):
if snap_id and snap_id not in self.snap_dict.keys():
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(
- src_sim_fs['pool_id'], dst_fs_name, src_sim_fs['total_space'], 0)
if 'clone' not in src_sim_fs.keys():
src_sim_fs['clone'] = dict()
+
+ # Make sure we don't have a duplicate name
+ self._check_dup_name(self.fs_dict.values(), dst_fs_name,
+ ErrorNumber.NAME_CONFLICT)
+
+ dst_sim_fs = self.fs_create(
+ src_sim_fs['pool_id'], dst_fs_name, src_sim_fs['total_space'], 0)
+
src_sim_fs['clone'][dst_sim_fs['fs_id']] = {
'snap_id': snap_id,
}
@@ -1317,6 +1358,9 @@ class SimData(object):
"File System: %s not found" % fs_id)
if 'snaps' not in self.fs_dict[fs_id].keys():
self.fs_dict[fs_id]['snaps'] = []
+ else:
+ self._check_dup_name(self.fs_dict[fs_id]['snaps'], snap_name,
+ ErrorNumber.NAME_CONFLICT)
snap_id = self._next_snap_id()
sim_snap = dict()
diff --git a/plugin/simc/simc_lsmplugin.c b/plugin/simc/simc_lsmplugin.c
index ae55667..39255c8 100644
--- a/plugin/simc/simc_lsmplugin.c
+++ b/plugin/simc/simc_lsmplugin.c
@@ -762,7 +762,7 @@ static int volume_create(lsm_plugin_ptr c, lsm_pool *pool,
}
} else {
- rc = lsm_log_error_basic(c, LSM_ERR_EXISTS_NAME, "Existing volume "
+ rc = lsm_log_error_basic(c, LSM_ERR_NAME_CONFLICT, "Existing volume "
"with name");
}
} else {
@@ -867,7 +867,7 @@ static int volume_resize(lsm_plugin_ptr c, lsm_volume *volume,
} else {
pool_deallocate(p, resized_size);
pool_allocate(p, curr_size);
- rc = lsm_log_error_basic(c, LSM_ERR_NO_MAPPING, "ENOMEM");
+ rc = lsm_log_error_basic(c, LSM_ERR_NO_MEMORY, "ENOMEM");
}
} else {
@@ -1028,7 +1028,7 @@ static int access_group_create(lsm_plugin_ptr c,
lsm_string_list_free(initiators);
} else {
- rc = lsm_log_error_basic(c, LSM_ERR_EXISTS_ACCESS_GROUP,
+ rc = lsm_log_error_basic(c, LSM_ERR_NAME_CONFLICT,
"access group with same id found");
}
@@ -1200,7 +1200,7 @@ static int volume_mask(lsm_plugin_ptr c,
}
} else {
- rc = LSM_ERR_IS_MAPPED;
+ rc = LSM_ERR_NO_STATE_CHANGE;
}
}
} else {
@@ -1528,7 +1528,7 @@ static int fs_create(lsm_plugin_ptr c, lsm_pool *pool, const char *name,
if( p == NULL ) {
rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_POOL, "Pool not found!");
} else {
- rc = lsm_log_error_basic(c, LSM_ERR_EXISTS_NAME,
+ rc = lsm_log_error_basic(c, LSM_ERR_NAME_CONFLICT,
"File system with name exists");
}
}
@@ -1751,7 +1751,7 @@ static int ss_create(lsm_plugin_ptr c, lsm_fs *fs,
}
}
} else {
- rc = lsm_log_error_basic(c, LSM_ERR_EXISTS_NAME,
+ rc = lsm_log_error_basic(c, LSM_ERR_NAME_CONFLICT,
"snapshot name exists");
}
} else {
diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 4dcbacf..5bb02ad 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -4259,7 +4259,7 @@ class Smis(IStorageAreaNetwork):
cim_sys.path, property_list=['ElementName'])
for exist_cim_init_mg in exist_cim_init_mgs:
if exist_cim_init_mg['ElementName'] == name:
- raise LsmError(ErrorNumber.EXISTS_ACCESS_GROUP,
+ raise LsmError(ErrorNumber.NAME_CONFLICT,
"Requested name %s is used by " % name +
"another access group, but not containing "
"requested initiator %s" % org_init_id)
diff --git a/python_binding/lsm/_client.py b/python_binding/lsm/_client.py
index 481b368..0a9a75a 100644
--- a/python_binding/lsm/_client.py
+++ b/python_binding/lsm/_client.py
@@ -603,7 +603,7 @@ class Client(INetworkAttachedStorage):
Deletes an initiator from an access group
"""
init_id = AccessGroup.initiator_id_verify(init_id, None,
- raise_exception=True)[2:]
+ raise_exception=True)[2]
return self._tp.rpc('access_group_initiator_delete',
_del_self(locals()))
diff --git a/python_binding/lsm/_common.py b/python_binding/lsm/_common.py
index 4ca5ac4..6cc928b 100644
--- a/python_binding/lsm/_common.py
+++ b/python_binding/lsm/_common.py
@@ -429,17 +429,12 @@ class ErrorNumber(object):
TIMEOUT = 11
DAEMON_NOT_RUNNING = 12
- EXISTS_ACCESS_GROUP = 50
- EXISTS_FS = 51
+ NAME_CONFLICT = 50
EXISTS_INITIATOR = 52
- EXISTS_NAME = 53
- FS_NOT_EXPORTED = 54
- EXISTS_POOL = 56
- EXISTS_VOLUME = 57
INVALID_ARGUMENT = 101
- IS_MAPPED = 125
+ NO_STATE_CHANGE = 125
NETWORK_CONNREFUSED = 140 # Host on network, but connection refused
NETWORK_HOSTDOWN = 141 # Host unreachable on network
@@ -474,7 +469,6 @@ class ErrorNumber(object):
PLUGIN_NOT_EXIST = 311
NOT_ENOUGH_SPACE = 350
- SIZE_SAME = 351
SIZE_TOO_SMALL = 353
SIZE_LIMIT_REACHED = 354
diff --git a/test/plugin_test.py b/test/plugin_test.py
index ecce918..24fe687 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -28,6 +28,7 @@ import atexit
import sys
import yaml
import re
+from lsm import LsmError, ErrorNumber
results = {}
stats = {}
@@ -78,7 +79,8 @@ def r_fcpn():
"""
Generate a random 16 character hex number
"""
- return '%016X' % random.randrange(2 ** 64)
+ rnd_fcpn = '%016x' % random.randrange(2 ** 64)
+ return ':'.join(rnd_fcpn[i:i + 2] for i in range(0, len(rnd_fcpn), 2))
class Duration(object):
@@ -179,7 +181,8 @@ class TestProxy(object):
TestProxy.log_result(_proxy_method_name,
dict(rc=True, stack_trace=None, msg=None))
except lsm.LsmError as le:
- if le.code != lsm.ErrorNumber.NO_SUPPORT:
+ if le.code != lsm.ErrorNumber.NO_SUPPORT and \
+ le.code != lsm.ErrorNumber.NAME_CONFLICT:
TestProxy.log_result(
_proxy_method_name,
dict(rc=False,
@@ -331,7 +334,8 @@ class TestPlugin(unittest.TestCase):
vol = self.c.volume_create(p, rs('v'), vol_size,
lsm.Volume.PROVISION_DEFAULT)[1]
- self.assertTrue(self._volume_exists(vol.id))
+ self.assertTrue(self._volume_exists(vol.id), p.id)
+ self.assertTrue(vol.pool_id == p.id)
return vol, p
def _fs_create(self, system_id):
@@ -359,11 +363,17 @@ class TestPlugin(unittest.TestCase):
self.c.fs_snapshot_delete(fs, ss)
self.assertFalse(self._fs_snapshot_exists(fs, ss.id))
- def _volume_exists(self, volume_id):
+ def _volume_exists(self, volume_id, pool_id=None):
volumes = self.c.volumes()
for v in volumes:
if v.id == volume_id:
+ if pool_id is not None:
+ if v.pool_id == pool_id:
+ return True
+ else:
+ return False
+
return True
return False
@@ -439,6 +449,19 @@ class TestPlugin(unittest.TestCase):
self.assertTrue(volume_clone is not None)
self.assertTrue(self._volume_exists(volume_clone.id))
+
+ if volume_clone is not None:
+ # Lets test for creating a clone with an
+ # existing name
+ try:
+ volume_clone_dupe_name = \
+ self.c.volume_replicate(
+ None, replication_type, vol,
+ volume_clone.name)[1]
+ except LsmError as le:
+ self.assertTrue(le.code ==
+ ErrorNumber.NAME_CONFLICT)
+
self._volume_delete(volume_clone)
self._volume_delete(vol)
@@ -630,11 +653,13 @@ class TestPlugin(unittest.TestCase):
raise Exception("No access group with 1+ member "
"found, cannot do volume mask test")
- if vol is not None:
- self.c.volume_mask(ag, vol)
- self._masking_state(cap, ag, vol, True)
- self.c.volume_unmask(ag, vol)
- self._masking_state(cap, ag, vol, False)
+ if vol is not None and chose_ag is not None:
+ self.c.volume_mask(chose_ag, vol)
+ self._masking_state(cap, chose_ag, vol, True)
+ self.c.volume_unmask(chose_ag, vol)
+ self._masking_state(cap, chose_ag, vol, False)
+
+ if vol:
self._volume_delete(vol)
def _create_access_group(self, cap, s, init_type):
@@ -787,6 +812,28 @@ class TestPlugin(unittest.TestCase):
if ag_to_delete is not None:
self._delete_access_group(ag_to_delete)
+ def test_duplicate_volume_name(self):
+ if self.pool_by_sys_id:
+ for s in self.systems:
+ vol = None
+ cap = self.c.capabilities(s)
+ if supported(cap, [lsm.Capabilities.VOLUME_CREATE]):
+ vol, pool = self._volume_create(s.id)
+ self.assertTrue(vol is not None)
+
+ # Try to create another with same name
+ try:
+ vol_dupe = self.c.volume_create(
+ pool, vol.name, vol.size_bytes,
+ lsm.Volume.PROVISION_DEFAULT)[1]
+ except LsmError as le:
+ self.assertTrue(le.code == ErrorNumber.NAME_CONFLICT)
+
+ if vol is not None and \
+ supported(cap, [lsm.Capabilities.VOLUME_DELETE]):
+ self._volume_delete(vol)
+
+
def dump_results():
"""
unittest.main exits when done so we need to register this handler to
diff --git a/test/tester.c b/test/tester.c
index 0007952..41219db 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -1430,7 +1430,7 @@ START_TEST(test_invalid_input)
rc = lsm_volume_resize(c, new_vol, lsm_volume_number_of_blocks_get(new_vol) *
lsm_volume_block_size_get(new_vol),
&resized, &job, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_VOLUME_SAME_SIZE == rc, "rc = %d", rc);
+ fail_unless(LSM_ERR_NO_STATE_CHANGE == rc, "rc = %d", rc);
rc = lsm_volume_resize(c, new_vol, 20000000, &resized, &job, LSM_FLAG_RSVD);
@@ -2752,7 +2752,7 @@ START_TEST(test_initiator_id_verification)
updated_group = NULL;
G(rc, lsm_access_group_initiator_add, c, group,
- "00:11:22:33:44:55:66:77",
+ "00:11:22:33:44:55:66:78",
LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
LSM_FLAG_RSVD);
@@ -2761,7 +2761,7 @@ START_TEST(test_initiator_id_verification)
updated_group = NULL;
G(rc, lsm_access_group_initiator_add, c, group,
- "00-11-22-33-44-55-66-77",
+ "00-11-22-33-44-55-66-79",
LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
LSM_FLAG_RSVD);
@@ -2770,7 +2770,7 @@ START_TEST(test_initiator_id_verification)
updated_group = NULL;
G(rc, lsm_access_group_initiator_add, c, group,
- "0x00-11-22-33-44-55-66-77",
+ "0x00-11-22-33-44-55-66-80",
LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
LSM_FLAG_RSVD);
NAME_CONFLICT == item with name already exists
NO_STATE_CHANGE == requested operation did nothing
This patch is incomplete as I want to introduce unit tests in the
plug_test.py which exercise all these error paths to ensure that
each of the plug-ins are working as expected.
make check runs clean, but NetApp, Nstor and SMI-S will need
improvements.
Signed-off-by: Tony Asleson <***@redhat.com>
---
.../include/libstoragemgmt/libstoragemgmt_error.h | 13 ++---
c_binding/lsm_mgmt.cpp | 2 +-
plugin/ontap/na.py | 4 ++
plugin/ontap/ontap.py | 8 ++-
plugin/sim/simarray.py | 58 ++++++++++++++++---
plugin/simc/simc_lsmplugin.c | 12 ++--
plugin/smispy/smis.py | 2 +-
python_binding/lsm/_client.py | 2 +-
python_binding/lsm/_common.py | 10 +---
test/plugin_test.py | 65 +++++++++++++++++++---
test/tester.c | 8 +--
11 files changed, 136 insertions(+), 48 deletions(-)
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
index 00a3ff9..fdb6ffa 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
@@ -51,17 +51,12 @@ typedef enum {
LSM_ERR_TIMEOUT = 11, /**< Plug-in is un-responsive */
LSM_ERR_DAEMON_NOT_RUNNING = 12, /**< Daemon is not running */
- LSM_ERR_EXISTS_ACCESS_GROUP = 50, /**< Access group exists */
- LSM_ERR_EXISTS_FS = 51, /**< FS exists */
- 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_EXISTS_POOL = 56, /**< Pool exists */
- LSM_ERR_EXISTS_VOLUME = 57, /**< Volume exists */
+ LSM_ERR_NAME_CONFLICT = 50, /**< Name exists */
+ LSM_ERR_EXISTS_INITIATOR = 52, /**< Initiator exists in another access group */
LSM_ERR_INVALID_ARGUMENT = 101, /**< Precondition checks failed */
- LSM_ERR_IS_MAPPED = 125, /**< Mapping already exists */
+ LSM_ERR_NO_STATE_CHANGE = 125, /**< Operation completed with no change in array state */
LSM_ERR_CONNREFUSED = 140, /**< Host on network, but not allowing connection */
LSM_ERR_HOSTDOWN = 141, /**< Host unreachable on network */
@@ -95,7 +90,7 @@ typedef enum {
LSM_ERR_PLUGIN_NOT_EXIST = 311, /**< Plug-in does not appear to exist */
LSM_ERR_NOT_ENOUGH_SPACE = 350, /**< Insufficient space */
- LSM_ERR_VOLUME_SAME_SIZE = 351, /**< Trying to resize to same size */
+
LSM_ERR_SIZE_TOO_SMALL = 353, /**< Size specified is too small */
LSM_ERR_SIZE_LIMIT_REACHED = 354, /**< Limit has been reached */
diff --git a/c_binding/lsm_mgmt.cpp b/c_binding/lsm_mgmt.cpp
index d48802d..b236549 100644
--- a/c_binding/lsm_mgmt.cpp
+++ b/c_binding/lsm_mgmt.cpp
@@ -993,7 +993,7 @@ int lsm_volume_resize(lsm_connect *c, lsm_volume *volume,
//If you try to resize to same size, we will return error.
if( ( newSize/volume->block_size) == volume->number_of_blocks ) {
- return LSM_ERR_VOLUME_SAME_SIZE;
+ return LSM_ERR_NO_STATE_CHANGE;
}
std::map<std::string, Value> p;
diff --git a/plugin/ontap/na.py b/plugin/ontap/na.py
index 25831e5..7803c65 100644
--- a/plugin/ontap/na.py
+++ b/plugin/ontap/na.py
@@ -164,9 +164,11 @@ class Filer(object):
Note: These are using lsm terminology.
"""
EUNKNOWN = 10 # Non-specific error
+ ENAVOL_NAME_DUPE = 17 # Volume name collision
ENOSPC = 28 # Out of space
ETIMEOUT = 60 # Time-out
EINVALID_ISCSI_NAME = 9006 # Invalid ISCSI IQN
+ EDUPE_VOLUME_PATH = 9012 # Duplicate volume name
ENO_SUCH_VOLUME = 9017 # lun not found
ESIZE_TOO_LARGE = 9034 # Specified too large a size
ENO_SUCH_FS = 9036 # FS not found
@@ -175,7 +177,9 @@ class Filer(object):
EFSDOESNOTEXIST = 13040 # FS does not exist
EFSOFFLINE = 13042 # FS is offline.
EFSNAMEINVALID = 13044 # FS Name invalid
+ ENOSPACE = 13062 # Not enough space
ESERVICENOTLICENSED = 13902 # Not licensed
+ ECLONE_NAME_EXISTS = 14952 # Clone with same name exists
ECLONE_LICENSE_EXPIRED = 14955 # Not licensed
ECLONE_NOT_LICENSED = 14956 # Not licensed
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 09dd942..1a0b851 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -35,6 +35,7 @@ e_map = {
na.Filer.ENOSPC: ErrorNumber.NOT_ENOUGH_SPACE,
na.Filer.ENO_SUCH_VOLUME: ErrorNumber.NOT_FOUND_VOLUME,
na.Filer.ESIZE_TOO_LARGE: ErrorNumber.NOT_ENOUGH_SPACE,
+ na.Filer.ENOSPACE: 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,
@@ -46,7 +47,10 @@ e_map = {
na.Filer.ECLONE_NOT_LICENSED: ErrorNumber.NOT_LICENSED,
na.Filer.EINVALID_ISCSI_NAME: ErrorNumber.INVALID_ARGUMENT,
na.Filer.ETIMEOUT: ErrorNumber.TIMEOUT,
- na.Filer.EUNKNOWN: ErrorNumber.PLUGIN_BUG
+ na.Filer.EUNKNOWN: ErrorNumber.PLUGIN_BUG,
+ na.Filer.EDUPE_VOLUME_PATH: ErrorNumber.NAME_CONFLICT,
+ na.Filer.ENAVOL_NAME_DUPE: ErrorNumber.NAME_CONFLICT,
+ na.Filer.ECLONE_NAME_EXISTS: ErrorNumber.NAME_CONFLICT
}
@@ -717,7 +721,7 @@ class Ontap(IStorageAreaNetwork, INfs):
cur_groups = self.access_groups()
for cg in cur_groups:
if cg.name == name:
- raise LsmError(ErrorNumber.EXISTS_ACCESS_GROUP,
+ raise LsmError(ErrorNumber.NAME_CONFLICT,
"Access group with the same name exists!")
if init_type == AccessGroup.INIT_TYPE_ISCSI_IQN:
diff --git a/plugin/sim/simarray.py b/plugin/sim/simarray.py
index d0519ea..9c22546 100644
--- a/plugin/sim/simarray.py
+++ b/plugin/sim/simarray.py
@@ -914,7 +914,7 @@ class SimData(object):
def volume_create(self, pool_id, vol_name, size_bytes, thinp, flags=0):
self._check_dup_name(
- self.vol_dict.values(), vol_name, ErrorNumber.EXISTS_VOLUME)
+ self.vol_dict.values(), vol_name, ErrorNumber.NAME_CONFLICT)
size_bytes = SimData._block_rounding(size_bytes)
# check free size
free_space = self.pool_free_space(pool_id)
@@ -949,10 +949,14 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Insufficient space in pool")
+ if self.vol_dict[vol_id]['total_space'] == new_size_bytes:
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE, "New size same "
+ "as current")
+
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_ARGUMENT,
+ raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such volume: %s" % vol_id)
def volume_replicate(self, dst_pool_id, rep_type, src_vol_id, new_vol_name,
@@ -960,6 +964,10 @@ class SimData(object):
if src_vol_id not in self.vol_dict.keys():
raise LsmError(ErrorNumber.NOT_FOUND_VOLUME,
"No such volume: %s" % src_vol_id)
+
+ self._check_dup_name(self.vol_dict.values(), new_vol_name,
+ ErrorNumber.NAME_CONFLICT)
+
size_bytes = self.vol_dict[src_vol_id]['total_space']
size_bytes = SimData._block_rounding(size_bytes)
# check free size
@@ -1101,6 +1109,11 @@ class SimData(object):
raise LsmError(error_num, "Name '%s' already in use" % name)
def access_group_create(self, name, init_id, init_type, sys_id, flags=0):
+
+ # Check to see if we have an access group with this name
+ self._check_dup_name(self.ag_dict.values(), name,
+ ErrorNumber.NAME_CONFLICT)
+
exist_sim_ag = self._sim_ag_of_init(init_id)
if exist_sim_ag:
if exist_sim_ag['name'] == name:
@@ -1116,7 +1129,7 @@ class SimData(object):
if init_id in exist_sim_ag['init_ids']:
return exist_sim_ag
else:
- raise LsmError(ErrorNumber.EXISTS_ACCESS_GROUP,
+ raise LsmError(ErrorNumber.NAME_CONFLICT,
"Another access group %s(%s) is using " %
(exist_sim_ag['name'], exist_sim_ag['ag_id']) +
"requested name %s but not contain init_id %s" %
@@ -1143,7 +1156,8 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_FOUND_ACCESS_GROUP,
"Access group not found")
if init_id in self.ag_dict[ag_id]['init_ids']:
- return self.ag_dict[ag_id]
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE, "Initiator already "
+ "in access group")
self._sim_ag_of_init(init_id)
@@ -1163,6 +1177,11 @@ class SimData(object):
new_init_ids.extend([cur_init_id])
del(self.ag_dict[ag_id]['init_ids'])
self.ag_dict[ag_id]['init_ids'] = new_init_ids
+ else:
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE,
+ "Initiator %s type %s not in access group %s"
+ % (init_id, str(type(init_id)),
+ str(self.ag_dict[ag_id]['init_ids'])))
return self.ag_dict[ag_id]
def volume_mask(self, ag_id, vol_id, flags=0):
@@ -1175,6 +1194,11 @@ class SimData(object):
if 'mask' not in self.vol_dict[vol_id].keys():
self.vol_dict[vol_id]['mask'] = dict()
+ if ag_id in self.vol_dict[vol_id]['mask']:
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE, "Volume already "
+ "masked to access "
+ "group")
+
self.vol_dict[vol_id]['mask'][ag_id] = 2
return None
@@ -1189,7 +1213,9 @@ class SimData(object):
return None
if ag_id not in self.vol_dict[vol_id]['mask'].keys():
- return None
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE, "Volume not "
+ "masked to access "
+ "group")
del(self.vol_dict[vol_id]['mask'][ag_id])
return None
@@ -1233,6 +1259,10 @@ class SimData(object):
return self.fs_dict.values()
def fs_create(self, pool_id, fs_name, size_bytes, flags=0):
+
+ self._check_dup_name(self.fs_dict.values(), fs_name,
+ ErrorNumber.NAME_CONFLICT)
+
size_bytes = SimData._block_rounding(size_bytes)
# check free size
free_space = self.pool_free_space(pool_id)
@@ -1267,6 +1297,10 @@ class SimData(object):
raise LsmError(ErrorNumber.NOT_ENOUGH_SPACE,
"Insufficient space in pool")
+ if self.fs_dict[fs_id]['total_space'] == new_size_bytes:
+ raise LsmError(ErrorNumber.NO_STATE_CHANGE,
+ "New size same as current")
+
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
@@ -1281,11 +1315,18 @@ class SimData(object):
if snap_id and snap_id not in self.snap_dict.keys():
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(
- src_sim_fs['pool_id'], dst_fs_name, src_sim_fs['total_space'], 0)
if 'clone' not in src_sim_fs.keys():
src_sim_fs['clone'] = dict()
+
+ # Make sure we don't have a duplicate name
+ self._check_dup_name(self.fs_dict.values(), dst_fs_name,
+ ErrorNumber.NAME_CONFLICT)
+
+ dst_sim_fs = self.fs_create(
+ src_sim_fs['pool_id'], dst_fs_name, src_sim_fs['total_space'], 0)
+
src_sim_fs['clone'][dst_sim_fs['fs_id']] = {
'snap_id': snap_id,
}
@@ -1317,6 +1358,9 @@ class SimData(object):
"File System: %s not found" % fs_id)
if 'snaps' not in self.fs_dict[fs_id].keys():
self.fs_dict[fs_id]['snaps'] = []
+ else:
+ self._check_dup_name(self.fs_dict[fs_id]['snaps'], snap_name,
+ ErrorNumber.NAME_CONFLICT)
snap_id = self._next_snap_id()
sim_snap = dict()
diff --git a/plugin/simc/simc_lsmplugin.c b/plugin/simc/simc_lsmplugin.c
index ae55667..39255c8 100644
--- a/plugin/simc/simc_lsmplugin.c
+++ b/plugin/simc/simc_lsmplugin.c
@@ -762,7 +762,7 @@ static int volume_create(lsm_plugin_ptr c, lsm_pool *pool,
}
} else {
- rc = lsm_log_error_basic(c, LSM_ERR_EXISTS_NAME, "Existing volume "
+ rc = lsm_log_error_basic(c, LSM_ERR_NAME_CONFLICT, "Existing volume "
"with name");
}
} else {
@@ -867,7 +867,7 @@ static int volume_resize(lsm_plugin_ptr c, lsm_volume *volume,
} else {
pool_deallocate(p, resized_size);
pool_allocate(p, curr_size);
- rc = lsm_log_error_basic(c, LSM_ERR_NO_MAPPING, "ENOMEM");
+ rc = lsm_log_error_basic(c, LSM_ERR_NO_MEMORY, "ENOMEM");
}
} else {
@@ -1028,7 +1028,7 @@ static int access_group_create(lsm_plugin_ptr c,
lsm_string_list_free(initiators);
} else {
- rc = lsm_log_error_basic(c, LSM_ERR_EXISTS_ACCESS_GROUP,
+ rc = lsm_log_error_basic(c, LSM_ERR_NAME_CONFLICT,
"access group with same id found");
}
@@ -1200,7 +1200,7 @@ static int volume_mask(lsm_plugin_ptr c,
}
} else {
- rc = LSM_ERR_IS_MAPPED;
+ rc = LSM_ERR_NO_STATE_CHANGE;
}
}
} else {
@@ -1528,7 +1528,7 @@ static int fs_create(lsm_plugin_ptr c, lsm_pool *pool, const char *name,
if( p == NULL ) {
rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_POOL, "Pool not found!");
} else {
- rc = lsm_log_error_basic(c, LSM_ERR_EXISTS_NAME,
+ rc = lsm_log_error_basic(c, LSM_ERR_NAME_CONFLICT,
"File system with name exists");
}
}
@@ -1751,7 +1751,7 @@ static int ss_create(lsm_plugin_ptr c, lsm_fs *fs,
}
}
} else {
- rc = lsm_log_error_basic(c, LSM_ERR_EXISTS_NAME,
+ rc = lsm_log_error_basic(c, LSM_ERR_NAME_CONFLICT,
"snapshot name exists");
}
} else {
diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 4dcbacf..5bb02ad 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -4259,7 +4259,7 @@ class Smis(IStorageAreaNetwork):
cim_sys.path, property_list=['ElementName'])
for exist_cim_init_mg in exist_cim_init_mgs:
if exist_cim_init_mg['ElementName'] == name:
- raise LsmError(ErrorNumber.EXISTS_ACCESS_GROUP,
+ raise LsmError(ErrorNumber.NAME_CONFLICT,
"Requested name %s is used by " % name +
"another access group, but not containing "
"requested initiator %s" % org_init_id)
diff --git a/python_binding/lsm/_client.py b/python_binding/lsm/_client.py
index 481b368..0a9a75a 100644
--- a/python_binding/lsm/_client.py
+++ b/python_binding/lsm/_client.py
@@ -603,7 +603,7 @@ class Client(INetworkAttachedStorage):
Deletes an initiator from an access group
"""
init_id = AccessGroup.initiator_id_verify(init_id, None,
- raise_exception=True)[2:]
+ raise_exception=True)[2]
return self._tp.rpc('access_group_initiator_delete',
_del_self(locals()))
diff --git a/python_binding/lsm/_common.py b/python_binding/lsm/_common.py
index 4ca5ac4..6cc928b 100644
--- a/python_binding/lsm/_common.py
+++ b/python_binding/lsm/_common.py
@@ -429,17 +429,12 @@ class ErrorNumber(object):
TIMEOUT = 11
DAEMON_NOT_RUNNING = 12
- EXISTS_ACCESS_GROUP = 50
- EXISTS_FS = 51
+ NAME_CONFLICT = 50
EXISTS_INITIATOR = 52
- EXISTS_NAME = 53
- FS_NOT_EXPORTED = 54
- EXISTS_POOL = 56
- EXISTS_VOLUME = 57
INVALID_ARGUMENT = 101
- IS_MAPPED = 125
+ NO_STATE_CHANGE = 125
NETWORK_CONNREFUSED = 140 # Host on network, but connection refused
NETWORK_HOSTDOWN = 141 # Host unreachable on network
@@ -474,7 +469,6 @@ class ErrorNumber(object):
PLUGIN_NOT_EXIST = 311
NOT_ENOUGH_SPACE = 350
- SIZE_SAME = 351
SIZE_TOO_SMALL = 353
SIZE_LIMIT_REACHED = 354
diff --git a/test/plugin_test.py b/test/plugin_test.py
index ecce918..24fe687 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -28,6 +28,7 @@ import atexit
import sys
import yaml
import re
+from lsm import LsmError, ErrorNumber
results = {}
stats = {}
@@ -78,7 +79,8 @@ def r_fcpn():
"""
Generate a random 16 character hex number
"""
- return '%016X' % random.randrange(2 ** 64)
+ rnd_fcpn = '%016x' % random.randrange(2 ** 64)
+ return ':'.join(rnd_fcpn[i:i + 2] for i in range(0, len(rnd_fcpn), 2))
class Duration(object):
@@ -179,7 +181,8 @@ class TestProxy(object):
TestProxy.log_result(_proxy_method_name,
dict(rc=True, stack_trace=None, msg=None))
except lsm.LsmError as le:
- if le.code != lsm.ErrorNumber.NO_SUPPORT:
+ if le.code != lsm.ErrorNumber.NO_SUPPORT and \
+ le.code != lsm.ErrorNumber.NAME_CONFLICT:
TestProxy.log_result(
_proxy_method_name,
dict(rc=False,
@@ -331,7 +334,8 @@ class TestPlugin(unittest.TestCase):
vol = self.c.volume_create(p, rs('v'), vol_size,
lsm.Volume.PROVISION_DEFAULT)[1]
- self.assertTrue(self._volume_exists(vol.id))
+ self.assertTrue(self._volume_exists(vol.id), p.id)
+ self.assertTrue(vol.pool_id == p.id)
return vol, p
def _fs_create(self, system_id):
@@ -359,11 +363,17 @@ class TestPlugin(unittest.TestCase):
self.c.fs_snapshot_delete(fs, ss)
self.assertFalse(self._fs_snapshot_exists(fs, ss.id))
- def _volume_exists(self, volume_id):
+ def _volume_exists(self, volume_id, pool_id=None):
volumes = self.c.volumes()
for v in volumes:
if v.id == volume_id:
+ if pool_id is not None:
+ if v.pool_id == pool_id:
+ return True
+ else:
+ return False
+
return True
return False
@@ -439,6 +449,19 @@ class TestPlugin(unittest.TestCase):
self.assertTrue(volume_clone is not None)
self.assertTrue(self._volume_exists(volume_clone.id))
+
+ if volume_clone is not None:
+ # Lets test for creating a clone with an
+ # existing name
+ try:
+ volume_clone_dupe_name = \
+ self.c.volume_replicate(
+ None, replication_type, vol,
+ volume_clone.name)[1]
+ except LsmError as le:
+ self.assertTrue(le.code ==
+ ErrorNumber.NAME_CONFLICT)
+
self._volume_delete(volume_clone)
self._volume_delete(vol)
@@ -630,11 +653,13 @@ class TestPlugin(unittest.TestCase):
raise Exception("No access group with 1+ member "
"found, cannot do volume mask test")
- if vol is not None:
- self.c.volume_mask(ag, vol)
- self._masking_state(cap, ag, vol, True)
- self.c.volume_unmask(ag, vol)
- self._masking_state(cap, ag, vol, False)
+ if vol is not None and chose_ag is not None:
+ self.c.volume_mask(chose_ag, vol)
+ self._masking_state(cap, chose_ag, vol, True)
+ self.c.volume_unmask(chose_ag, vol)
+ self._masking_state(cap, chose_ag, vol, False)
+
+ if vol:
self._volume_delete(vol)
def _create_access_group(self, cap, s, init_type):
@@ -787,6 +812,28 @@ class TestPlugin(unittest.TestCase):
if ag_to_delete is not None:
self._delete_access_group(ag_to_delete)
+ def test_duplicate_volume_name(self):
+ if self.pool_by_sys_id:
+ for s in self.systems:
+ vol = None
+ cap = self.c.capabilities(s)
+ if supported(cap, [lsm.Capabilities.VOLUME_CREATE]):
+ vol, pool = self._volume_create(s.id)
+ self.assertTrue(vol is not None)
+
+ # Try to create another with same name
+ try:
+ vol_dupe = self.c.volume_create(
+ pool, vol.name, vol.size_bytes,
+ lsm.Volume.PROVISION_DEFAULT)[1]
+ except LsmError as le:
+ self.assertTrue(le.code == ErrorNumber.NAME_CONFLICT)
+
+ if vol is not None and \
+ supported(cap, [lsm.Capabilities.VOLUME_DELETE]):
+ self._volume_delete(vol)
+
+
def dump_results():
"""
unittest.main exits when done so we need to register this handler to
diff --git a/test/tester.c b/test/tester.c
index 0007952..41219db 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -1430,7 +1430,7 @@ START_TEST(test_invalid_input)
rc = lsm_volume_resize(c, new_vol, lsm_volume_number_of_blocks_get(new_vol) *
lsm_volume_block_size_get(new_vol),
&resized, &job, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_VOLUME_SAME_SIZE == rc, "rc = %d", rc);
+ fail_unless(LSM_ERR_NO_STATE_CHANGE == rc, "rc = %d", rc);
rc = lsm_volume_resize(c, new_vol, 20000000, &resized, &job, LSM_FLAG_RSVD);
@@ -2752,7 +2752,7 @@ START_TEST(test_initiator_id_verification)
updated_group = NULL;
G(rc, lsm_access_group_initiator_add, c, group,
- "00:11:22:33:44:55:66:77",
+ "00:11:22:33:44:55:66:78",
LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
LSM_FLAG_RSVD);
@@ -2761,7 +2761,7 @@ START_TEST(test_initiator_id_verification)
updated_group = NULL;
G(rc, lsm_access_group_initiator_add, c, group,
- "00-11-22-33-44-55-66-77",
+ "00-11-22-33-44-55-66-79",
LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
LSM_FLAG_RSVD);
@@ -2770,7 +2770,7 @@ START_TEST(test_initiator_id_verification)
updated_group = NULL;
G(rc, lsm_access_group_initiator_add, c, group,
- "0x00-11-22-33-44-55-66-77",
+ "0x00-11-22-33-44-55-66-80",
LSM_ACCESS_GROUP_INIT_TYPE_WWPN, &updated_group,
LSM_FLAG_RSVD);
--
1.8.2.1
1.8.2.1