Discussion:
[PATCH] ONTAP Plugin: Handle NOT_FOUND_VOLUME error in volume_raid_info().
Gris Ge
2015-08-05 13:23:34 UTC
Permalink
* Run the volume/LUN existence check before checking RAID information.

Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/ontap/ontap.py | 3 +++
1 file changed, 3 insertions(+)

diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 107f295..4ffad56 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -1306,6 +1306,9 @@ def _raid_type_of_na_aggr(na_aggr):

@handle_ontap_errors
def volume_raid_info(self, volume, flags=0):
+ # Check existance of LUN
+ self.f.luns_get_specific(None, na_lun_name=volume.id);
+
na_vol_name = Ontap._get_volume_from_path(volume.pool_id)
na_vol = self.f.volumes(volume_name=na_vol_name)
if len(na_vol) == 0:
--
1.8.3.1
Tony Asleson
2015-08-05 13:55:17 UTC
Permalink
Hi Gris,

Please add a unit test for this, eg. creating then deleting a volume and
then calling volume_raid_info on the non-existing volume and for good
path as we don't appear to have unit tests for volume_raid_info.

Thanks,
Tony
Post by Gris Ge
* Run the volume/LUN existence check before checking RAID information.
---
plugin/ontap/ontap.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 107f295..4ffad56 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@handle_ontap_errors
+ # Check existance of LUN
+ self.f.luns_get_specific(None, na_lun_name=volume.id);
+
na_vol_name = Ontap._get_volume_from_path(volume.pool_id)
na_vol = self.f.volumes(volume_name=na_vol_name)
Gris Ge
2015-09-06 06:50:15 UTC
Permalink
* Run the volume/LUN existence check before checking RAID information.

Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/ontap/ontap.py | 3 +++
1 file changed, 3 insertions(+)

diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 107f295..2d4366c 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -1306,6 +1306,9 @@ def _raid_type_of_na_aggr(na_aggr):

@handle_ontap_errors
def volume_raid_info(self, volume, flags=0):
+ # Check existance of LUN
+ self.f.luns_get_specific(None, na_lun_name=volume.id)
+
na_vol_name = Ontap._get_volume_from_path(volume.pool_id)
na_vol = self.f.volumes(volume_name=na_vol_name)
if len(na_vol) == 0:
--
1.8.3.1
Gris Ge
2015-09-06 06:50:16 UTC
Permalink
* New test for lsm.Client.volume_raid_info() method.
* Including test for ErrorNumber.NOT_FOUND_VOLUME when volume not exists.

Signed-off-by: Gris Ge <***@redhat.com>
---
test/plugin_test.py | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index d91b151..d733988 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -1344,6 +1344,44 @@ def test_volume_raid_create(self):
self._skip_current_test(
"Skip test: not support of VOLUME_RAID_CREATE")

+ def test_volume_raid_info(self):
+ flag_supported = False
+ pool_id_to_lsm_vols = dict()
+ created_lsm_vol = None
+
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+ if supported(cap, [Cap.VOLUME_RAID_INFO]):
+ flag_supported = True
+ if flag_supported is False:
+ self._skip_current_test(
+ "Skip test: current system does not support "
+ "query volume raid info(lsm.Capabilities.VOLUME_RAID_INFO)")
+
+ # Try to find a volume per pool.
+ lsm_vols = self.c.volumes()
+ for lsm_vol in lsm_vols:
+ pool_id = lsm_vol.pool_id
+ if len(pool_id) != 0 and \
+ pool_id_to_lsm_vols.get(pool_id) is None:
+ pool_id_to_lsm_vols[pool_id] = lsm_vol
+
+ lsm_vols = pool_id_to_lsm_vols.values()
+ created_lsm_vol = self._volume_create(s.id)[0]
+ lsm_vols.append(created_lsm_vol)
+
+ for lsm_vol in lsm_vols:
+ [raid_type, strip_size, disk_count, min_io_size, opt_io_size] = \
+ self.c.volume_raid_info(lsm_vol)
+
+ # Test NOT_FOUND_VOLUME error.
+ self._volume_delete(created_lsm_vol)
+ try:
+ self.c.volume_raid_info(lsm_vol)
+ except lsm.LsmError as le:
+ if le.code != ErrorNumber.NOT_FOUND_VOLUME:
+ raise
+

def dump_results():
"""
--
1.8.3.1
Loading...