Manila list shows one export location not multiple

"Export Locations" is a plural field. As discussed,
"list" operation should not show "export locations" anymore.
Hence, removed displaying of it in default mode of list operation.
Still, it can be displayed, if specified explicitly, with --columns,
wherein a string of comma separated column names can be given.

Change-Id: I4ae0cd3760088f1982301aa6f23a5c2d40be2455
Closes-Bug: #1438365
This commit is contained in:
nidhimittalhada 2015-10-06 16:50:39 +05:30
parent 84d4d57fce
commit 47b519106a
4 changed files with 26 additions and 5 deletions

View File

@ -509,7 +509,7 @@ class ManilaCLIClient(base.CLIClient):
cmd += '%s ' % share
return self.manila(cmd)
def list_shares(self, all_tenants=False, filters=None):
def list_shares(self, all_tenants=False, filters=None, columns=None):
"""List shares.
:param all_tenants: bool -- whether to list shares that belong
@ -521,6 +521,8 @@ class ManilaCLIClient(base.CLIClient):
{--'project_id': 'foo'}
{'project-id': 'foo'}
will be transformed to filter parameter "--project-id=foo"
:param columns: comma separated string of columns.
Example, "--columns Name,Size"
"""
cmd = 'list '
if all_tenants:
@ -529,6 +531,8 @@ class ManilaCLIClient(base.CLIClient):
for k, v in filters.items():
cmd += '%(k)s=%(v)s ' % {
'k': self._stranslate_to_cli_optional_param(k), 'v': v}
if columns is not None:
cmd += '--columns ' + columns
shares_raw = self.manila(cmd)
shares = utils.listing(shares_raw)
return shares

View File

@ -204,3 +204,9 @@ class SharesListReadWriteTest(base.BaseTestCase):
def test_list_shares_with_limit(self, filters):
shares = self.user_client.list_shares(filters=filters)
self.assertEqual(filters['limit'], len(shares))
def test_list_share_select_column(self):
shares = self.user_client.list_shares(columns="Name,Size")
self.assertTrue(any(s['Name'] is not None for s in shares))
self.assertTrue(any(s['Size'] is not None for s in shares))
self.assertTrue(all('Description' not in s for s in shares))

View File

@ -458,8 +458,7 @@ class ShellTest(test_utils.TestCase):
'Share Proto',
'Status',
'Is Public',
'Share Type',
'Export location',
'Share Type Name',
'Host',
'Availability Zone'
]

View File

@ -925,15 +925,27 @@ def do_access_list(cs, args):
default=None,
action='single_alias',
help='Filter results by consistency group name or ID.')
@cliutils.arg(
'--columns',
metavar='<columns>',
type=str,
default=None,
help='Comma separated list of columns to be displayed '
'e.g. --columns "export_location,is public"')
@cliutils.service_type('sharev2')
def do_list(cs, args):
"""List NAS shares with filters."""
list_of_keys = [
'ID', 'Name', 'Size', 'Share Proto', 'Status', 'Is Public',
'Share Type', 'Export location', 'Host', 'Availability Zone'
'Share Type Name', 'Host', 'Availability Zone'
]
all_tenants = int(os.environ.get("ALL_TENANTS", args.all_tenants))
columns = args.columns
if columns is not None:
list_of_keys = map(lambda x: x.strip().title(), columns.split(","))
all_tenants = int(os.environ.get("ALL_TENANTS", args.all_tenants))
empty_obj = type('Empty', (object,), {'id': None})
share_type = (_find_share_type(cs, args.share_type)
if args.share_type else empty_obj)