* Add lsm.Client.pool_raid_info() support:
  * Base on 'hpssacli ctrl slot=0 show config detail' command.

 * Set lsm.Capabilities.POOL_RAID_INFO.

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

diff --git a/plugin/hpsa/hpsa.py b/plugin/hpsa/hpsa.py
index 721b64b..f338d7f 100644
--- a/plugin/hpsa/hpsa.py
+++ b/plugin/hpsa/hpsa.py
@@ -278,6 +278,7 @@ def capabilities(self, system, flags=Client.FLAG_RSVD):
         cap.set(Capabilities.VOLUMES)
         cap.set(Capabilities.DISKS)
         cap.set(Capabilities.VOLUME_RAID_INFO)
+        cap.set(Capabilities.POOL_RAID_INFO)
         return cap
 
     def _sacli_exec(self, sacli_cmds, flag_convert=True):
@@ -525,3 +526,41 @@ def volume_raid_info(self, volume, flags=Client.FLAG_RSVD):
                 "Volume not found")
 
         return [raid_type, strip_size, disk_count, strip_size, stripe_size]
+
+    @_handle_errors
+    def pool_raid_info(self, pool, flags=Client.FLAG_RSVD):
+        """
+        Depend on command:
+            hpssacli ctrl slot=0 show config detail
+        """
+        if not pool.plugin_data:
+            raise LsmError(
+                ErrorNumber.INVALID_ARGUMENT,
+                "Ilegal input volume argument: missing plugin_data property")
+
+        (ctrl_num, array_num) = pool.plugin_data.split(":")
+        ctrl_data = self._sacli_exec(
+            ["ctrl", "slot=%s" % ctrl_num, "show", "config", "detail"]
+            ).values()[0]
+
+        disk_ids = []
+        raid_type = Volume.RAID_TYPE_UNKNOWN
+        for key_name in ctrl_data.keys():
+            if key_name == "Array: %s" % array_num:
+                for array_key_name in ctrl_data[key_name].keys():
+                    if array_key_name.startswith("Logical Drive: ") and \
+                       raid_type == Volume.RAID_TYPE_UNKNOWN:
+                        raid_type = _hp_raid_type_to_lsm(
+                            ctrl_data[key_name][array_key_name])
+                    elif array_key_name.startswith("physicaldrive"):
+                        hp_disk = ctrl_data[key_name][array_key_name]
+                        if hp_disk['Drive Type'] == 'Data Drive':
+                            disk_ids.append(hp_disk['Serial Number'])
+                break
+
+        if len(disk_ids) == 0:
+            raise LsmError(
+                ErrorNumber.NOT_FOUND_POOL,
+                "Pool not found")
+
+        return raid_type, Pool.MEMBER_TYPE_DISK, disk_ids
-- 
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