* New command 'pool-raid-info' to utilize lsm.Client.pool_raid_info() method.
* Manpage updated.
* New alias 'pri' for 'pool-raid-info' command.
Changes in V2:
* Renamed command to 'pool-member-info' and alias 'pmi'
Changes in V4:
* Add bash auto completion of lsmcli for 'pool-member-info' command and its
alias.
Signed-off-by: Gris Ge <fge(a)redhat.com>
---
doc/man/lsmcli.1.in | 9 +++++++++
tools/bash_completion/lsmcli | 8 +++++++-
tools/lsmcli/cmdline.py | 19 ++++++++++++++++++-
tools/lsmcli/data_display.py | 41 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/doc/man/lsmcli.1.in b/doc/man/lsmcli.1.in
index 381d676..6faf690 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-member-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 pmi
+Alias of 'pool-member-info'
.SS ac
Alias of 'access-group-create'
.SS aa
diff --git a/tools/bash_completion/lsmcli b/tools/bash_completion/lsmcli
index a67083b..164604f 100644
--- a/tools/bash_completion/lsmcli
+++ b/tools/bash_completion/lsmcli
@@ -76,7 +76,7 @@ function _lsm()
fs-resize fs-export fs-unexport fs-clone fs-snap-create \
fs-snap-delete fs-snap-restore fs-dependants fs-dependants-rm \
file-clone ls lp lv ld la lf lt c p vc vd vr vm vi ve vi ac \
- aa ar ad vri"
+ aa ar ad vri pool-member-info pmi"
list_args="--type"
list_type_args="volumes pools fs snapshots exports nfs_client_auth \
@@ -124,6 +124,7 @@ function _lsm()
fs_snap_restore_args="--snap --fs --file --fileas --force"
fs_dependants_args="--fs"
file_clone_args="--fs --src --dst --backing-snapshot"
+ pool_member_info_args="--pool"
# These operations can potentially be slow and cause hangs depending on plugin and
configuration
if [[ ${NO_VALUE_LOOKUP} -ne 0 ]] ; then
@@ -396,6 +397,11 @@ function _lsm()
COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) )
return 0
;;
+ pool-member-info|pmi)
+ possible_args "${pool_member_info_args}"
+ COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) )
+ return 0
+ ;;
*)
;;
esac
diff --git a/tools/lsmcli/cmdline.py b/tools/lsmcli/cmdline.py
index 9b2b682..d26da80 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-member-info',
+ help='Query Pool membership 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'],
+ ['pmi', 'pool-member-info'],
)
@@ -1334,6 +1344,13 @@ def volume_raid_info(self, args):
VolumeRAIDInfo(
lsm_vol.id, *self.c.volume_raid_info(lsm_vol))])
+ def pool_member_info(self, args):
+ lsm_pool = _get_item(self.c.pools(), args.pool, "Pool")
+ self.display_data(
+ [
+ PoolRAIDInfo(
+ lsm_pool.id, *self.c.pool_member_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