* New command:
    lsmcli volume-raid-info --vol <VOL_ID>

 * New alias:
    lsmcli vri == lsmcli volume-raid-info

Changes in V2:
 * Fix output format when volume not found passed to  _get_item() in
   volume_raid_info()

Changes in V5(No changes in V3, V4):
 * Sync API changes of name 'extent_count' to 'disk_count', column name
   changed to 'Disk Count'.

Signed-off-by: Gris Ge <f...@redhat.com>
---
 tools/lsmcli/cmdline.py      | 18 +++++++++++++-
 tools/lsmcli/data_display.py | 58 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/tools/lsmcli/cmdline.py b/tools/lsmcli/cmdline.py
index a781314..980b3a0 100644
--- a/tools/lsmcli/cmdline.py
+++ b/tools/lsmcli/cmdline.py
@@ -39,7 +39,7 @@ from lsm import (Client, Pool, VERSION, LsmError, Disk,
 
 from lsm.lsmcli.data_display import (
     DisplayData, PlugData, out,
-    vol_provision_str_to_type, vol_rep_type_str_to_type)
+    vol_provision_str_to_type, vol_rep_type_str_to_type, VolumeRAIDInfo)
 
 
 ## Wraps the invocation to the command line
@@ -368,6 +368,14 @@ cmds = (
     ),
 
     dict(
+        name='volume-raid-info',
+        help='Query volume RAID infomation',
+        args=[
+            dict(vol_id_opt),
+        ],
+    ),
+
+    dict(
         name='access-group-create',
         help='Create an access group',
         args=[
@@ -628,6 +636,7 @@ aliases = (
     ['aa', 'access-group-add'],
     ['ar', 'access-group-remove'],
     ['ad', 'access-group-delete'],
+    ['vri', 'volume-raid-info'],
 )
 
 
@@ -1318,6 +1327,13 @@ class CmdLine:
         self._wait_for_it("volume-dependant-rm",
                           self.c.volume_child_dependency_rm(v), None)
 
+    def volume_raid_info(self, args):
+        lsm_vol = _get_item(self.c.volumes(), args.vol, "Volume")
+        self.display_data(
+            [
+                VolumeRAIDInfo(
+                    lsm_vol.id, *self.c.volume_raid_info(lsm_vol))])
+
     ## Displays file system dependants
     def fs_dependants(self, args):
         fs = _get_item(self.c.fs(), args.fs, "File System")
diff --git a/tools/lsmcli/data_display.py b/tools/lsmcli/data_display.py
index 285a14f..e0524c8 100644
--- a/tools/lsmcli/data_display.py
+++ b/tools/lsmcli/data_display.py
@@ -243,6 +243,41 @@ class PlugData(object):
             self.version = plugin_version
 
 
+class VolumeRAIDInfo(object):
+    _RAID_TYPE_MAP = {
+        Volume.RAID_TYPE_RAID0: 'RAID0',
+        Volume.RAID_TYPE_RAID1: 'RAID1',
+        Volume.RAID_TYPE_RAID3: 'RAID3',
+        Volume.RAID_TYPE_RAID4: 'RAID4',
+        Volume.RAID_TYPE_RAID5: 'RAID5',
+        Volume.RAID_TYPE_RAID6: 'RAID6',
+        Volume.RAID_TYPE_RAID10: 'RAID10',
+        Volume.RAID_TYPE_RAID15: 'RAID15',
+        Volume.RAID_TYPE_RAID16: 'RAID16',
+        Volume.RAID_TYPE_RAID50: 'RAID50',
+        Volume.RAID_TYPE_RAID60: 'RAID60',
+        Volume.RAID_TYPE_RAID51: 'RAID51',
+        Volume.RAID_TYPE_RAID61: 'RAID61',
+        Volume.RAID_TYPE_JBOD: 'JBOD',
+        Volume.RAID_TYPE_MIXED: 'MIXED',
+        Volume.RAID_TYPE_OTHER: 'OTHER',
+        Volume.RAID_TYPE_UNKNOWN: 'UNKNOWN',
+    }
+
+    def __init__(self, vol_id, raid_type, strip_size, disk_count,
+                 min_io_size, opt_io_size):
+        self.vol_id = vol_id
+        self.raid_type = raid_type
+        self.strip_size = strip_size
+        self.disk_count = disk_count
+        self.min_io_size = min_io_size
+        self.opt_io_size = opt_io_size
+
+    @staticmethod
+    def raid_type_to_str(raid_type):
+        return _enum_type_to_str(raid_type, VolumeRAIDInfo._RAID_TYPE_MAP)
+
+
 class DisplayData(object):
 
     def __init__(self):
@@ -498,6 +533,29 @@ class DisplayData(object):
         'value_conv_human': TGT_PORT_VALUE_CONV_HUMAN,
     }
 
+    VOL_RAID_INFO_HEADER = OrderedDict()
+    VOL_RAID_INFO_HEADER['vol_id'] = 'Volume ID'
+    VOL_RAID_INFO_HEADER['raid_type'] = 'RAID Type'
+    VOL_RAID_INFO_HEADER['strip_size'] = 'Strip Size'
+    VOL_RAID_INFO_HEADER['disk_count'] = 'Disk Count'
+    VOL_RAID_INFO_HEADER['min_io_size'] = 'Minimum I/O Size'
+    VOL_RAID_INFO_HEADER['opt_io_size'] = 'Optimal I/O Size'
+
+    VOL_RAID_INFO_COLUMN_SKIP_KEYS = []
+
+    VOL_RAID_INFO_VALUE_CONV_ENUM = {
+        'raid_type': VolumeRAIDInfo.raid_type_to_str,
+        }
+    VOL_RAID_INFO_VALUE_CONV_HUMAN = [
+        'strip_size', 'min_io_size', 'opt_io_size']
+
+    VALUE_CONVERT[VolumeRAIDInfo] = {
+        'headers': VOL_RAID_INFO_HEADER,
+        'column_skip_keys': VOL_RAID_INFO_COLUMN_SKIP_KEYS,
+        'value_conv_enum': VOL_RAID_INFO_VALUE_CONV_ENUM,
+        'value_conv_human': VOL_RAID_INFO_VALUE_CONV_HUMAN,
+    }
+
     @staticmethod
     def _get_man_pro_value(obj, key, value_conv_enum, value_conv_human,
                            flag_human, flag_enum):
-- 
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