Merge "Add more filter option of columns for server list -c COLUMN"

This commit is contained in:
Zuul 2022-06-20 15:19:49 +00:00 committed by Gerrit Code Review
commit 15608a2696
3 changed files with 51 additions and 0 deletions

View File

@ -2458,6 +2458,27 @@ class ListServer(command.Lister):
if c in ('Security Groups', 'security_groups'):
columns += ('security_groups_name',)
column_headers += ('Security Groups',)
if c in ("Task State", "task_state"):
columns += ('OS-EXT-STS:task_state',)
column_headers += ('Task State',)
if c in ("Power State", "power_state"):
columns += ('OS-EXT-STS:power_state',)
column_headers += ('Power State',)
if c in ("Image ID", "image_id"):
columns += ('Image ID',)
column_headers += ('Image ID',)
if c in ("Flavor ID", "flavor_id"):
columns += ('Flavor ID',)
column_headers += ('Flavor ID',)
if c in ('Availability Zone', "availability_zone"):
columns += ('OS-EXT-AZ:availability_zone',)
column_headers += ('Availability Zone',)
if c in ('Host', "host"):
columns += ('OS-EXT-SRV-ATTR:host',)
column_headers += ('Host',)
if c in ('Properties', "properties"):
columns += ('Metadata',)
column_headers += ('Properties',)
# convert back to tuple
column_headers = tuple(column_headers)

View File

@ -4486,6 +4486,13 @@ class TestServerList(_TestServerList):
'-c', 'User ID',
'-c', 'Created At',
'-c', 'Security Groups',
'-c', 'Task State',
'-c', 'Power State',
'-c', 'Image ID',
'-c', 'Flavor ID',
'-c', 'Availability Zone',
'-c', 'Host',
'-c', 'Properties',
'--long'
]
verifylist = [
@ -4500,6 +4507,13 @@ class TestServerList(_TestServerList):
self.assertIn('User ID', columns)
self.assertIn('Created At', columns)
self.assertIn('Security Groups', columns)
self.assertIn('Task State', columns)
self.assertIn('Power State', columns)
self.assertIn('Image ID', columns)
self.assertIn('Flavor ID', columns)
self.assertIn('Availability Zone', columns)
self.assertIn('Host', columns)
self.assertIn('Properties', columns)
def test_server_list_no_name_lookup_option(self):
self.data = tuple(

View File

@ -0,0 +1,16 @@
---
feature:
- |
The ``server list`` command now allows users to select the following
additional columns using the ``-c COLUMN`` option:
- Task State
- Power State
- Image ID
- Flavor ID
- Availability Zone
- Host
- Properties
These correspond to columns displayed by default when using the ``--long``
option.