Skip to content

Commit 10835a1

Browse files
JihoJustephenfin
authored andcommitted
Add more filter option of columns for server list -c COLUMN
In order to improve the convenient of use, columns corresponding to the "--long" option has been added so that it can be used in the filter. Currently filterable columns include the following: 'ID', 'Name', 'Status', 'Networks', 'Image', 'Flavor'. Story: 2009150 Task: 43113 Change-Id: I6760ca5da0e3707d1d746ae5eeec7d9162020d15
1 parent dabaec5 commit 10835a1

3 files changed

Lines changed: 51 additions & 0 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,27 @@ def take_action(self, parsed_args):
24582458
if c in ('Security Groups', 'security_groups'):
24592459
columns += ('security_groups_name',)
24602460
column_headers += ('Security Groups',)
2461+
if c in ("Task State", "task_state"):
2462+
columns += ('OS-EXT-STS:task_state',)
2463+
column_headers += ('Task State',)
2464+
if c in ("Power State", "power_state"):
2465+
columns += ('OS-EXT-STS:power_state',)
2466+
column_headers += ('Power State',)
2467+
if c in ("Image ID", "image_id"):
2468+
columns += ('Image ID',)
2469+
column_headers += ('Image ID',)
2470+
if c in ("Flavor ID", "flavor_id"):
2471+
columns += ('Flavor ID',)
2472+
column_headers += ('Flavor ID',)
2473+
if c in ('Availability Zone', "availability_zone"):
2474+
columns += ('OS-EXT-AZ:availability_zone',)
2475+
column_headers += ('Availability Zone',)
2476+
if c in ('Host', "host"):
2477+
columns += ('OS-EXT-SRV-ATTR:host',)
2478+
column_headers += ('Host',)
2479+
if c in ('Properties', "properties"):
2480+
columns += ('Metadata',)
2481+
column_headers += ('Properties',)
24612482

24622483
# convert back to tuple
24632484
column_headers = tuple(column_headers)

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4486,6 +4486,13 @@ def test_server_list_column_option(self):
44864486
'-c', 'User ID',
44874487
'-c', 'Created At',
44884488
'-c', 'Security Groups',
4489+
'-c', 'Task State',
4490+
'-c', 'Power State',
4491+
'-c', 'Image ID',
4492+
'-c', 'Flavor ID',
4493+
'-c', 'Availability Zone',
4494+
'-c', 'Host',
4495+
'-c', 'Properties',
44894496
'--long'
44904497
]
44914498
verifylist = [
@@ -4500,6 +4507,13 @@ def test_server_list_column_option(self):
45004507
self.assertIn('User ID', columns)
45014508
self.assertIn('Created At', columns)
45024509
self.assertIn('Security Groups', columns)
4510+
self.assertIn('Task State', columns)
4511+
self.assertIn('Power State', columns)
4512+
self.assertIn('Image ID', columns)
4513+
self.assertIn('Flavor ID', columns)
4514+
self.assertIn('Availability Zone', columns)
4515+
self.assertIn('Host', columns)
4516+
self.assertIn('Properties', columns)
45034517

45044518
def test_server_list_no_name_lookup_option(self):
45054519
self.data = tuple(
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
feature:
3+
- |
4+
The ``server list`` command now allows users to select the following
5+
additional columns using the ``-c COLUMN`` option:
6+
7+
- Task State
8+
- Power State
9+
- Image ID
10+
- Flavor ID
11+
- Availability Zone
12+
- Host
13+
- Properties
14+
15+
These correspond to columns displayed by default when using the ``--long``
16+
option.

0 commit comments

Comments
 (0)