Gris Ge
2014-06-09 12:03:31 UTC
* Revert back to "-o, --optional" lsmcli argument.
* Update manpage warning user:
due to console text width limitation(78), column way display method will
not including all mandatory properties. Only script way display method
will include all mandatory properties.
* If "-o, --optional" is defined, the display method will be forced as
script way due to console text width limitation.
* The lsmcli test has been updated also for this change.
Signed-off-by: Gris Ge <***@redhat.com>
---
doc/man/lsmcli.1.in | 12 +++++++++---
test/cmdtest.py | 8 ++++----
tools/lsmcli/cmdline.py | 31 +++++++++++++++++--------------
3 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/doc/man/lsmcli.1.in b/doc/man/lsmcli.1.in
index 53d8673..bff0e72 100644
--- a/doc/man/lsmcli.1.in
+++ b/doc/man/lsmcli.1.in
@@ -120,7 +120,7 @@ Displaying data in script friendly way.
Without this option, data is displayed in this manner:
ID | Name | Member IDs
- -------------------------------------+-------+-------------
+ -----------------------------------------------------------
87720e90-3a83-11df-b8bf-00a0980ad71b | aggr0 | ID_A
| | ID_B
aa0ffc70-3dba-11df-b8cf-00a0980ad71b | aggr1 | ID_C
@@ -140,6 +140,13 @@ With this option, data is displayed in this manner.
| ID_D
--------------------------------------------------
+Please note:
+.br
+NOT all mandatory properties will be displayed in column way considering the
+user's console text width. But all mandatory properties will be displayed in
+script way. When with "-o, --optional", both mandatory properties and optional
+properties will be displayed.
+
.SH COMMANDS
.SS list
List information on LSM objects
@@ -159,8 +166,7 @@ filesystem.
PLUGINS will list all supported plugins of LSM, not only the current one.
.TP
\fB-o\fR, \fB--optional\fR
-Optional. Valid for \fBPOOLS\fR and \fBDISKS\fR to retrieve optional data if
-available.
+Optional. Retrive and display optional data in '--script, -s' display way.
.TP
\fB--sys\fR \fI<SYS_ID>\fR
Search resources from system with SYS_ID. Only supported when querying these
diff --git a/test/cmdtest.py b/test/cmdtest.py
index f782a32..81d5ee4 100755
--- a/test/cmdtest.py
+++ b/test/cmdtest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-# Copyright (C) 2011-2013 Red Hat, Inc.
+# Copyright (C) 2011-2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -89,7 +89,7 @@ def call(command, expected_rc=0):
"""
if code_coverage:
- actual_command = ['coverage', 'run', '-a']
+ actual_command = ['coverage', 'run', '-o']
actual_command.extend(command)
else:
actual_command = command
@@ -430,7 +430,7 @@ def display_check(display_list, system_id):
call([cmd, 'list', '--type', 'SNAPSHOTS', '--fs', fs_id])
if 'POOLS' in display_list:
- call([cmd, '-H', '-t' + sep, 'list', '--type', 'POOLS', '-a'])
+ call([cmd, '-H', '-t' + sep, 'list', '--type', 'POOLS', '-o'])
def test_display(cap, system_id):
@@ -733,7 +733,7 @@ def optional_data_check():
print "\nTesting query with optional data\n"
for list_type in opt_support_list:
- call([cmd, 'list', '--type', list_type, '-a'])
+ call([cmd, 'list', '--type', list_type, '-o'])
def run_all_tests(cap, system_id):
test_display(cap, system_id)
diff --git a/tools/lsmcli/cmdline.py b/tools/lsmcli/cmdline.py
index a1ccded..b6cfa16 100644
--- a/tools/lsmcli/cmdline.py
+++ b/tools/lsmcli/cmdline.py
@@ -71,7 +71,6 @@ def getch():
termios.tcsetattr(fd, termios.TCSADRAIN, prev)
return ch
-
## This class represents a command line argument error
class ArgError(Exception):
def __init__(self, message, *args, **kwargs):
@@ -189,11 +188,11 @@ cmds = (
type=str.upper),
],
optional=[
- dict(name=('-a', '--all'),
- help='Retrieve and display in script friendly way with ' +
- 'all information including optional data if available',
+ dict(name=('-o', '--optional'),
+ help='Retrieve both mandatory and optional properties.\n'
+ 'Once define, will use "-s, --script" display way',
default=False,
- dest='all',
+ dest='optional',
action='store_true'),
dict(sys_id_filter_opt),
dict(pool_id_filter_opt),
@@ -789,7 +788,7 @@ class CmdLine:
if len(objects) == 0:
return
- if hasattr(self.args, 'all') and self.args.all:
+ if hasattr(self.args, 'optional') and self.args.optional:
display_all = True
flag_with_header = True
@@ -802,6 +801,10 @@ class CmdLine:
if self.args.script:
display_way = DisplayData.DISPLAY_WAY_SCRIPT
+ if hasattr(self.args, 'optional') and self.args.optional:
+ display_all = True
+ display_way = DisplayData.DISPLAY_WAY_SCRIPT
+
DisplayData.display_data(
objects, display_way=display_way, flag_human=self.args.human,
flag_enum=self.args.enum, extra_properties=extra_properties,
@@ -949,7 +952,7 @@ class CmdLine:
search_value = args.nfs_export
if args.type == 'VOLUMES':
- if args.all:
+ if args.optional:
flags |= Volume.FLAG_RETRIEVE_FULL_INFO
if search_key == 'volume_id':
search_key = 'id'
@@ -968,12 +971,12 @@ class CmdLine:
if search_key and search_key not in Pool.SUPPORTED_SEARCH_KEYS:
raise ArgError("Search key '%s' is not supported by "
"pool listing." % search_key)
- if args.all:
+ if args.optional:
flags |= Pool.FLAG_RETRIEVE_FULL_INFO
self.display_data(
self.c.pools(search_key, search_value, flags))
elif args.type == 'FS':
- if args.all:
+ if args.optional:
flags |= FileSystem.FLAG_RETRIEVE_FULL_INFO
if search_key == 'fs_id':
search_key = 'id'
@@ -986,14 +989,14 @@ class CmdLine:
if args.fs is None:
raise ArgError("--fs <file system id> required")
- if args.all:
+ if args.optional:
flags |= FsSnapshot.FLAG_RETRIEVE_FULL_INFO
fs = _get_item(self.c.fs(), args.fs, 'filesystem')
self.display_data(self.c.fs_snapshots(fs, flags))
elif args.type == 'INITIATORS':
self.display_data(self.c.initiators())
elif args.type == 'EXPORTS':
- if args.all:
+ if args.optional:
flags |= NfsExport.FLAG_RETRIEVE_FULL_INFO
if search_key == 'nfs_export_id':
search_key = 'id'
@@ -1005,7 +1008,7 @@ class CmdLine:
elif args.type == 'NFS_CLIENT_AUTH':
self.display_nfs_client_authentication()
elif args.type == 'ACCESS_GROUPS':
- if args.all:
+ if args.optional:
flags |= AccessGroup.FLAG_RETRIEVE_FULL_INFO
if search_key == 'access_group_id':
search_key = 'id'
@@ -1021,7 +1024,7 @@ class CmdLine:
self.display_data(
self.c.access_groups(search_key,search_value, flags))
elif args.type == 'SYSTEMS':
- if args.all:
+ if args.optional:
flags |= System.FLAG_RETRIEVE_FULL_INFO
if search_key:
raise ArgError("System listing with search is not supported")
@@ -1032,7 +1035,7 @@ class CmdLine:
if search_key and search_key not in Disk.SUPPORTED_SEARCH_KEYS:
raise ArgError("Search key '%s' is not supported by "
"disk listing" % search_key)
- if args.all:
+ if args.optional:
flags |= Disk.FLAG_RETRIEVE_FULL_INFO
self.display_data(
self.c.disks(search_key, search_value, flags))
* Update manpage warning user:
due to console text width limitation(78), column way display method will
not including all mandatory properties. Only script way display method
will include all mandatory properties.
* If "-o, --optional" is defined, the display method will be forced as
script way due to console text width limitation.
* The lsmcli test has been updated also for this change.
Signed-off-by: Gris Ge <***@redhat.com>
---
doc/man/lsmcli.1.in | 12 +++++++++---
test/cmdtest.py | 8 ++++----
tools/lsmcli/cmdline.py | 31 +++++++++++++++++--------------
3 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/doc/man/lsmcli.1.in b/doc/man/lsmcli.1.in
index 53d8673..bff0e72 100644
--- a/doc/man/lsmcli.1.in
+++ b/doc/man/lsmcli.1.in
@@ -120,7 +120,7 @@ Displaying data in script friendly way.
Without this option, data is displayed in this manner:
ID | Name | Member IDs
- -------------------------------------+-------+-------------
+ -----------------------------------------------------------
87720e90-3a83-11df-b8bf-00a0980ad71b | aggr0 | ID_A
| | ID_B
aa0ffc70-3dba-11df-b8cf-00a0980ad71b | aggr1 | ID_C
@@ -140,6 +140,13 @@ With this option, data is displayed in this manner.
| ID_D
--------------------------------------------------
+Please note:
+.br
+NOT all mandatory properties will be displayed in column way considering the
+user's console text width. But all mandatory properties will be displayed in
+script way. When with "-o, --optional", both mandatory properties and optional
+properties will be displayed.
+
.SH COMMANDS
.SS list
List information on LSM objects
@@ -159,8 +166,7 @@ filesystem.
PLUGINS will list all supported plugins of LSM, not only the current one.
.TP
\fB-o\fR, \fB--optional\fR
-Optional. Valid for \fBPOOLS\fR and \fBDISKS\fR to retrieve optional data if
-available.
+Optional. Retrive and display optional data in '--script, -s' display way.
.TP
\fB--sys\fR \fI<SYS_ID>\fR
Search resources from system with SYS_ID. Only supported when querying these
diff --git a/test/cmdtest.py b/test/cmdtest.py
index f782a32..81d5ee4 100755
--- a/test/cmdtest.py
+++ b/test/cmdtest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-# Copyright (C) 2011-2013 Red Hat, Inc.
+# Copyright (C) 2011-2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -89,7 +89,7 @@ def call(command, expected_rc=0):
"""
if code_coverage:
- actual_command = ['coverage', 'run', '-a']
+ actual_command = ['coverage', 'run', '-o']
actual_command.extend(command)
else:
actual_command = command
@@ -430,7 +430,7 @@ def display_check(display_list, system_id):
call([cmd, 'list', '--type', 'SNAPSHOTS', '--fs', fs_id])
if 'POOLS' in display_list:
- call([cmd, '-H', '-t' + sep, 'list', '--type', 'POOLS', '-a'])
+ call([cmd, '-H', '-t' + sep, 'list', '--type', 'POOLS', '-o'])
def test_display(cap, system_id):
@@ -733,7 +733,7 @@ def optional_data_check():
print "\nTesting query with optional data\n"
for list_type in opt_support_list:
- call([cmd, 'list', '--type', list_type, '-a'])
+ call([cmd, 'list', '--type', list_type, '-o'])
def run_all_tests(cap, system_id):
test_display(cap, system_id)
diff --git a/tools/lsmcli/cmdline.py b/tools/lsmcli/cmdline.py
index a1ccded..b6cfa16 100644
--- a/tools/lsmcli/cmdline.py
+++ b/tools/lsmcli/cmdline.py
@@ -71,7 +71,6 @@ def getch():
termios.tcsetattr(fd, termios.TCSADRAIN, prev)
return ch
-
## This class represents a command line argument error
class ArgError(Exception):
def __init__(self, message, *args, **kwargs):
@@ -189,11 +188,11 @@ cmds = (
type=str.upper),
],
optional=[
- dict(name=('-a', '--all'),
- help='Retrieve and display in script friendly way with ' +
- 'all information including optional data if available',
+ dict(name=('-o', '--optional'),
+ help='Retrieve both mandatory and optional properties.\n'
+ 'Once define, will use "-s, --script" display way',
default=False,
- dest='all',
+ dest='optional',
action='store_true'),
dict(sys_id_filter_opt),
dict(pool_id_filter_opt),
@@ -789,7 +788,7 @@ class CmdLine:
if len(objects) == 0:
return
- if hasattr(self.args, 'all') and self.args.all:
+ if hasattr(self.args, 'optional') and self.args.optional:
display_all = True
flag_with_header = True
@@ -802,6 +801,10 @@ class CmdLine:
if self.args.script:
display_way = DisplayData.DISPLAY_WAY_SCRIPT
+ if hasattr(self.args, 'optional') and self.args.optional:
+ display_all = True
+ display_way = DisplayData.DISPLAY_WAY_SCRIPT
+
DisplayData.display_data(
objects, display_way=display_way, flag_human=self.args.human,
flag_enum=self.args.enum, extra_properties=extra_properties,
@@ -949,7 +952,7 @@ class CmdLine:
search_value = args.nfs_export
if args.type == 'VOLUMES':
- if args.all:
+ if args.optional:
flags |= Volume.FLAG_RETRIEVE_FULL_INFO
if search_key == 'volume_id':
search_key = 'id'
@@ -968,12 +971,12 @@ class CmdLine:
if search_key and search_key not in Pool.SUPPORTED_SEARCH_KEYS:
raise ArgError("Search key '%s' is not supported by "
"pool listing." % search_key)
- if args.all:
+ if args.optional:
flags |= Pool.FLAG_RETRIEVE_FULL_INFO
self.display_data(
self.c.pools(search_key, search_value, flags))
elif args.type == 'FS':
- if args.all:
+ if args.optional:
flags |= FileSystem.FLAG_RETRIEVE_FULL_INFO
if search_key == 'fs_id':
search_key = 'id'
@@ -986,14 +989,14 @@ class CmdLine:
if args.fs is None:
raise ArgError("--fs <file system id> required")
- if args.all:
+ if args.optional:
flags |= FsSnapshot.FLAG_RETRIEVE_FULL_INFO
fs = _get_item(self.c.fs(), args.fs, 'filesystem')
self.display_data(self.c.fs_snapshots(fs, flags))
elif args.type == 'INITIATORS':
self.display_data(self.c.initiators())
elif args.type == 'EXPORTS':
- if args.all:
+ if args.optional:
flags |= NfsExport.FLAG_RETRIEVE_FULL_INFO
if search_key == 'nfs_export_id':
search_key = 'id'
@@ -1005,7 +1008,7 @@ class CmdLine:
elif args.type == 'NFS_CLIENT_AUTH':
self.display_nfs_client_authentication()
elif args.type == 'ACCESS_GROUPS':
- if args.all:
+ if args.optional:
flags |= AccessGroup.FLAG_RETRIEVE_FULL_INFO
if search_key == 'access_group_id':
search_key = 'id'
@@ -1021,7 +1024,7 @@ class CmdLine:
self.display_data(
self.c.access_groups(search_key,search_value, flags))
elif args.type == 'SYSTEMS':
- if args.all:
+ if args.optional:
flags |= System.FLAG_RETRIEVE_FULL_INFO
if search_key:
raise ArgError("System listing with search is not supported")
@@ -1032,7 +1035,7 @@ class CmdLine:
if search_key and search_key not in Disk.SUPPORTED_SEARCH_KEYS:
raise ArgError("Search key '%s' is not supported by "
"disk listing" % search_key)
- if args.all:
+ if args.optional:
flags |= Disk.FLAG_RETRIEVE_FULL_INFO
self.display_data(
self.c.disks(search_key, search_value, flags))
--
1.8.3.1
1.8.3.1