* NetApp ONTAP strip size(minimum I/O size) is 4KiB, stripe size(
   optimal I/O size) is 64KiB.  Both are unchangeable.

 * The extent count(disk count) is taken from aggregate 'disk-count'
   property.

 * Changed Filer.aggregates() to accept an optional argument 'aggr_name'
   which query defined aggregate only.

 * Uncommented and updated the old code for converting NetApp RAID level to
   libstoragemgmt RAID level.

 * Tested on ONTAP simulator 8.1.1 7-mode and real ONTAP 8.0.2 7-mode.

Changes in V5(No changes in V2, V3, V4):

 * Sync API changes for argument name.

Signed-off-by: Gris Ge <f...@redhat.com>
---
 plugin/ontap/na.py    |  8 ++++++--
 plugin/ontap/ontap.py | 55 +++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/plugin/ontap/na.py b/plugin/ontap/na.py
index 1e015ba..b68577c 100644
--- a/plugin/ontap/na.py
+++ b/plugin/ontap/na.py
@@ -231,11 +231,15 @@ class Filer(object):
         disks = self._invoke('disk-list-info')
         return disks['disk-details']['disk-detail-info']
 
-    def aggregates(self):
+    def aggregates(self, aggr_name=None):
         """
         Return a list of aggregates
+        If aggr_name provided, return [na_aggr]
         """
-        pools = self._invoke('aggr-list-info')
+        if aggr_name:
+            pools = self._invoke('aggr-list-info', {'aggregate': aggr_name})
+        else:
+            pools = self._invoke('aggr-list-info')
         tmp = pools['aggregates']['aggr-info']
         return to_list(tmp)
 
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index c2a2c58..b6358a8 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -121,6 +121,10 @@ class Ontap(IStorageAreaNetwork, INfs):
         'restricted': 'volume is restricted to protocol accesses',
     }
 
+    # strip size: http://www.netapp.com/us/media/tr-3001.pdf
+    _STRIP_SIZE = 4096
+    _OPT_IO_SIZE = 65536
+
     def __init__(self):
         self.f = None
         self.sys_info = None
@@ -310,19 +314,6 @@ class Ontap(IStorageAreaNetwork, INfs):
         return search_property(
             [self._lun(l) for l in luns], search_key, search_value)
 
-#    @staticmethod
-#    def _raid_type_of_na_aggr(na_aggr):
-#        na_raid_statuses = na_aggr['raid-status'].split(',')
-#        if 'raid0' in na_raid_statuses:
-#            return Pool.RAID_TYPE_RAID0
-#        if 'raid4' in na_raid_statuses:
-#            return Pool.RAID_TYPE_RAID4
-#        if 'raid_dp' in na_raid_statuses:
-#            return Pool.RAID_TYPE_RAID6
-#        if 'mixed_raid_type' in na_raid_statuses:
-#            return Pool.RAID_TYPE_MIXED
-#        return Pool.RAID_TYPE_UNKNOWN
-
     # This is based on NetApp ONTAP Manual pages:
     # https://library.netapp.com/ecmdocs/ECMP1196890/html/man1/na_aggr.1.html
     _AGGR_RAID_STATUS_CONV = {
@@ -1290,3 +1281,41 @@ class Ontap(IStorageAreaNetwork, INfs):
                                  self.sys_info.id))
 
         return search_property(tp, search_key, search_value)
+
+    @staticmethod
+    def _raid_type_of_na_aggr(na_aggr):
+        na_raid_statuses = na_aggr['raid-status'].split(',')
+        if 'mixed_raid_type' in na_raid_statuses:
+            return Volume.RAID_TYPE_MIXED
+        elif 'raid0' in na_raid_statuses:
+            return Volume.RAID_TYPE_RAID0
+        elif 'raid4' in na_raid_statuses:
+            return Volume.RAID_TYPE_RAID4
+        elif 'raid_dp' in na_raid_statuses:
+            return Volume.RAID_TYPE_RAID6
+        return Pool.RAID_TYPE_UNKNOWN
+
+    @handle_ontap_errors
+    def volume_raid_info(self, volume, flags=0):
+        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:
+            # If parent pool not found, then this LSM volume should not exist.
+            raise LsmError(
+                ErrorNumber.NOT_FOUND_VOLUME,
+                "Volume not found")
+        if len(na_vol) != 1:
+            raise LsmError(
+                ErrorNumber.PLUGIN_BUG,
+                "volume_raid_info(): Got 2+ na_vols from self.f.volumes() "
+                "%s" % na_vol)
+
+        na_vol = na_vol[0]
+        na_aggr_name = na_vol['containing-aggregate']
+        na_aggr = self.f.aggregates(aggr_name=na_aggr_name)[0]
+        raid_type = Ontap._raid_type_of_na_aggr(na_aggr)
+        disk_count = int(na_aggr['disk-count'])
+
+        return [
+            raid_type, Ontap._STRIP_SIZE, disk_count, Ontap._STRIP_SIZE,
+            Ontap._OPT_IO_SIZE]
-- 
1.8.3.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Libstoragemgmt-devel mailing list
Libstoragemgmt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libstoragemgmt-devel

Reply via email to