* New command 'pool-raid-info' to utilize lsm.Client.pool_raid_info() method.
* Manpage updated. * New alias 'pri' for 'pool-raid-info' command. Signed-off-by: Gris Ge <f...@redhat.com> --- doc/man/lsmcli.1.in | 9 +++++++++ tools/lsmcli/cmdline.py | 19 ++++++++++++++++++- tools/lsmcli/data_display.py | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/doc/man/lsmcli.1.in b/doc/man/lsmcli.1.in index e2af14f..df82f5d 100644 --- a/doc/man/lsmcli.1.in +++ b/doc/man/lsmcli.1.in @@ -351,6 +351,13 @@ Query RAID information for given volume. \fB--vol\fR \fI<VOL_ID>\fR Required. The ID of volume to query. +.SS pool-raid-info +.TP 15 +Query RAID information for given pool. +.TP +\fB--pool\fR \fI<POOL_ID>\fR +Required. The ID of pool to query. + .SS access-group-create .TP 15 Create an access group. @@ -589,6 +596,8 @@ Alias of 'volume-mask' Alias of 'volume-unmask' .SS vri Alias of 'volume-raid-info' +.SS pri +Alias of 'pool-raid-info' .SS ac Alias of 'access-group-create' .SS aa diff --git a/tools/lsmcli/cmdline.py b/tools/lsmcli/cmdline.py index 980b3a0..cd687df 100644 --- a/tools/lsmcli/cmdline.py +++ b/tools/lsmcli/cmdline.py @@ -39,7 +39,8 @@ from lsm.lsmcli.data_display import ( DisplayData, PlugData, out, - vol_provision_str_to_type, vol_rep_type_str_to_type, VolumeRAIDInfo) + vol_provision_str_to_type, vol_rep_type_str_to_type, VolumeRAIDInfo, + PoolRAIDInfo) ## Wraps the invocation to the command line @@ -376,6 +377,14 @@ def _get_item(l, the_id, friendly_name='item', raise_error=True): ), dict( + name='pool-raid-info', + help='Query Pool RAID infomation', + args=[ + dict(pool_id_opt), + ], + ), + + dict( name='access-group-create', help='Create an access group', args=[ @@ -637,6 +646,7 @@ def _get_item(l, the_id, friendly_name='item', raise_error=True): ['ar', 'access-group-remove'], ['ad', 'access-group-delete'], ['vri', 'volume-raid-info'], + ['pri', 'pool-raid-info'], ) @@ -1334,6 +1344,13 @@ def volume_raid_info(self, args): VolumeRAIDInfo( lsm_vol.id, *self.c.volume_raid_info(lsm_vol))]) + def pool_raid_info(self, args): + lsm_pool = _get_item(self.c.pools(), args.pool, "Pool") + self.display_data( + [ + PoolRAIDInfo( + lsm_pool.id, *self.c.pool_raid_info(lsm_pool))]) + ## 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 19f7114..115f15a 100644 --- a/tools/lsmcli/data_display.py +++ b/tools/lsmcli/data_display.py @@ -279,6 +279,26 @@ def raid_type_to_str(raid_type): return _enum_type_to_str(raid_type, VolumeRAIDInfo._RAID_TYPE_MAP) +class PoolRAIDInfo(object): + _MEMBER_TYPE_MAP = { + Pool.MEMBER_TYPE_UNKNOWN: 'Unknown', + Pool.MEMBER_TYPE_OTHER: 'Unknown', + Pool.MEMBER_TYPE_POOL: 'Pool', + Pool.MEMBER_TYPE_DISK: 'Disk', + } + + def __init__(self, pool_id, raid_type, member_type, member_ids): + self.pool_id = pool_id + self.raid_type = raid_type + self.member_type = member_type + self.member_ids = member_ids + + @staticmethod + def member_type_to_str(member_type): + return _enum_type_to_str( + member_type, PoolRAIDInfo._MEMBER_TYPE_MAP) + + class DisplayData(object): def __init__(self): @@ -557,6 +577,27 @@ def __init__(self): 'value_conv_human': VOL_RAID_INFO_VALUE_CONV_HUMAN, } + POOL_RAID_INFO_HEADER = OrderedDict() + POOL_RAID_INFO_HEADER['pool_id'] = 'Pool ID' + POOL_RAID_INFO_HEADER['raid_type'] = 'RAID Type' + POOL_RAID_INFO_HEADER['member_type'] = 'Member Type' + POOL_RAID_INFO_HEADER['member_ids'] = 'Member IDs' + + POOL_RAID_INFO_COLUMN_SKIP_KEYS = [] + + POOL_RAID_INFO_VALUE_CONV_ENUM = { + 'raid_type': VolumeRAIDInfo.raid_type_to_str, + 'member_type': PoolRAIDInfo.member_type_to_str, + } + POOL_RAID_INFO_VALUE_CONV_HUMAN = [] + + VALUE_CONVERT[PoolRAIDInfo] = { + 'headers': POOL_RAID_INFO_HEADER, + 'column_skip_keys': POOL_RAID_INFO_COLUMN_SKIP_KEYS, + 'value_conv_enum': POOL_RAID_INFO_VALUE_CONV_ENUM, + 'value_conv_human': POOL_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