* Add lsm.Client.pool_raid_info() support: * Use command 'storcli /c0/d0 show all J'. * Use 'DG Drive LIST' section of output for disk_ids. * Use 'TOPOLOGY' section of output for raid_type. Since the command used here is not sharing the same data layout with command "storcli /c0/v0 show all J" which is used by 'volume_raid_info()' method, we now have two set of codes for detecting RAID type.
* Set lsm.Capabilities.POOL_RAID_INFO. Signed-off-by: Gris Ge <f...@redhat.com> --- plugin/megaraid/megaraid.py | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/plugin/megaraid/megaraid.py b/plugin/megaraid/megaraid.py index 78603fc..ff861b3 100644 --- a/plugin/megaraid/megaraid.py +++ b/plugin/megaraid/megaraid.py @@ -259,6 +259,7 @@ def capabilities(self, system, flags=Client.FLAG_RSVD): cap.set(Capabilities.DISKS) cap.set(Capabilities.VOLUMES) cap.set(Capabilities.VOLUME_RAID_INFO) + cap.set(Capabilities.POOL_RAID_INFO) return cap def _storcli_exec(self, storcli_cmds, flag_json=True): @@ -546,3 +547,56 @@ def volume_raid_info(self, volume, flags=Client.FLAG_RSVD): return [ raid_type, strip_size, disk_count, strip_size, strip_size * strip_count] + + @_handle_errors + def pool_raid_info(self, pool, flags=Client.FLAG_RSVD): + lsi_dg_path = pool.plugin_data + # Check whether pool exists. + try: + dg_show_all_output = self._storcli_exec( + [lsi_dg_path , "show", "all"]) + except ExecError as exec_error: + try: + json_output = json.loads(exec_error.stdout) + detail_error = json_output[ + 'Controllers'][0]['Command Status']['Detailed Status'] + except Exception: + raise exec_error + + if detail_error and detail_error[0]['Status'] == 'Not found': + raise LsmError( + ErrorNumber.NOT_FOUND_POOL, + "Pool not found") + raise + + ctrl_num = lsi_dg_path.split('/')[1][1:] + lsm_disk_map = {} + disk_ids = [] + for lsm_disk in self.disks(): + lsm_disk_map[lsm_disk.plugin_data] = lsm_disk.id + + for dg_disk_info in dg_show_all_output['DG Drive LIST']: + cur_lsi_disk_path = "/c%s" % ctrl_num + "/e%s/s%s" % tuple( + dg_disk_info['EID:Slt'].split(':')) + if cur_lsi_disk_path in lsm_disk_map.keys(): + disk_ids.append(lsm_disk_map[cur_lsi_disk_path]) + else: + raise LsmError( + ErrorNumber.PLUGIN_BUG, + "pool_raid_info(): Failed to find disk id of %s" % + cur_lsi_disk_path) + + raid_type = Volume.RAID_TYPE_UNKNOWN + dg_num = lsi_dg_path.split('/')[2][1:] + for dg_top in dg_show_all_output['TOPOLOGY']: + if dg_top['Arr'] == '-' and \ + dg_top['Row'] == '-' and \ + int(dg_top['DG']) == int(dg_num): + raid_type = _RAID_TYPE_MAP.get( + dg_top['Type'], Volume.RAID_TYPE_UNKNOWN) + break + + if raid_type == Volume.RAID_TYPE_RAID1 and len(disk_ids) >= 4: + raid_type = Volume.RAID_TYPE_RAID10 + + 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