Add status column for "openstack image list"

Actually, the status column is useful for the user.
So, it`s better to output this info by default (or, user had
to specify the extra option, i.e. --long).

Change-Id: Id2a9f86f0de5310f8f5ff9a46bf1b7411094b519
Closes-Bug: #1519181
This commit is contained in:
xiexs 2015-11-23 08:19:00 -05:00
parent 27869c0f3f
commit 342fd158e9
4 changed files with 36 additions and 20 deletions

View File

@ -354,7 +354,12 @@ class ListImage(lister.Lister):
kwargs['public'] = True kwargs['public'] = True
if parsed_args.private: if parsed_args.private:
kwargs['private'] = True kwargs['private'] = True
kwargs['detailed'] = bool(parsed_args.property or parsed_args.long) # Note: We specifically need to do that below to get the 'status'
# column.
#
# Always set kwargs['detailed'] to True, and then filter the columns
# according to whether the --long option is specified or not.
kwargs['detailed'] = True
if parsed_args.long: if parsed_args.long:
columns = ( columns = (
@ -382,7 +387,7 @@ class ListImage(lister.Lister):
'Properties', 'Properties',
) )
else: else:
columns = ("ID", "Name") columns = ("ID", "Name", "Status")
column_headers = columns column_headers = columns
# List of image data received # List of image data received

View File

@ -417,7 +417,7 @@ class ListImage(lister.Lister):
'Tags', 'Tags',
) )
else: else:
columns = ("ID", "Name") columns = ("ID", "Name", "Status")
column_headers = columns column_headers = columns
# List of image data received # List of image data received

View File

@ -261,16 +261,17 @@ class TestImageList(TestImage):
# DisplayCommandBase.take_action() returns two tuples # DisplayCommandBase.take_action() returns two tuples
columns, data = self.cmd.take_action(parsed_args) columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with( self.api_mock.image_list.assert_called_with(
detailed=False, detailed=True,
marker=image_fakes.image_id, marker=image_fakes.image_id,
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(collist, columns) self.assertEqual(collist, columns)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name, image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))
@ -288,17 +289,18 @@ class TestImageList(TestImage):
# DisplayCommandBase.take_action() returns two tuples # DisplayCommandBase.take_action() returns two tuples
columns, data = self.cmd.take_action(parsed_args) columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with( self.api_mock.image_list.assert_called_with(
detailed=False, detailed=True,
public=True, public=True,
marker=image_fakes.image_id, marker=image_fakes.image_id,
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(collist, columns) self.assertEqual(collist, columns)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name, image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))
@ -316,17 +318,18 @@ class TestImageList(TestImage):
# DisplayCommandBase.take_action() returns two tuples # DisplayCommandBase.take_action() returns two tuples
columns, data = self.cmd.take_action(parsed_args) columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with( self.api_mock.image_list.assert_called_with(
detailed=False, detailed=True,
private=True, private=True,
marker=image_fakes.image_id, marker=image_fakes.image_id,
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(collist, columns) self.assertEqual(collist, columns)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name, image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))
@ -401,12 +404,13 @@ class TestImageList(TestImage):
property_field='properties', property_field='properties',
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(columns, collist) self.assertEqual(columns, collist)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name, image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))
@ -423,7 +427,7 @@ class TestImageList(TestImage):
# DisplayCommandBase.take_action() returns two tuples # DisplayCommandBase.take_action() returns two tuples
columns, data = self.cmd.take_action(parsed_args) columns, data = self.cmd.take_action(parsed_args)
self.api_mock.image_list.assert_called_with( self.api_mock.image_list.assert_called_with(
detailed=False, detailed=True,
marker=image_fakes.image_id, marker=image_fakes.image_id,
) )
si_mock.assert_called_with( si_mock.assert_called_with(
@ -431,12 +435,13 @@ class TestImageList(TestImage):
'name:asc' 'name:asc'
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(collist, columns) self.assertEqual(collist, columns)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))

View File

@ -374,12 +374,13 @@ class TestImageList(TestImage):
marker=image_fakes.image_id, marker=image_fakes.image_id,
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(collist, columns) self.assertEqual(collist, columns)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name, image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))
@ -402,12 +403,13 @@ class TestImageList(TestImage):
marker=image_fakes.image_id, marker=image_fakes.image_id,
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(collist, columns) self.assertEqual(collist, columns)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name, image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))
@ -430,12 +432,13 @@ class TestImageList(TestImage):
marker=image_fakes.image_id, marker=image_fakes.image_id,
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(collist, columns) self.assertEqual(collist, columns)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name, image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))
@ -458,12 +461,13 @@ class TestImageList(TestImage):
marker=image_fakes.image_id, marker=image_fakes.image_id,
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(columns, collist) self.assertEqual(columns, collist)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name, image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))
@ -536,12 +540,13 @@ class TestImageList(TestImage):
property_field='properties', property_field='properties',
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(columns, collist) self.assertEqual(columns, collist)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name, image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))
@ -565,12 +570,13 @@ class TestImageList(TestImage):
'name:asc' 'name:asc'
) )
collist = ('ID', 'Name') collist = ('ID', 'Name', 'Status')
self.assertEqual(collist, columns) self.assertEqual(collist, columns)
datalist = (( datalist = ((
image_fakes.image_id, image_fakes.image_id,
image_fakes.image_name image_fakes.image_name,
'',
), ) ), )
self.assertEqual(datalist, tuple(data)) self.assertEqual(datalist, tuple(data))