Browse Source

Allow display project-id for server groups

Currently, the display of server groups doesn't contain informations
about project-id. It is very difficult for admin to tell which
group belongs to which project when using command:
"nova server-group-list --all-projects".

This patch adds project-id to the display.

Change-Id: I010bf02f696396c404bc7a51ce93252c8c7f68a6
Partial-bug:#1481210
tags/2.27.0
Kevin_Zheng 4 years ago
parent
commit
01c2e60eb3
2 changed files with 9 additions and 2 deletions
  1. 2
    1
      novaclient/tests/unit/v2/test_shell.py
  2. 7
    1
      novaclient/v2/shell.py

+ 2
- 1
novaclient/tests/unit/v2/test_shell.py View File

@@ -2471,7 +2471,8 @@ class ShellTest(utils.TestCase):
2471 2471
         self.run_command('server-group-create wjsg affinity')
2472 2472
         self.assert_called('POST', '/os-server-groups',
2473 2473
                            {'server_group': {'name': 'wjsg',
2474
-                                             'policies': ['affinity']}})
2474
+                                             'policies': ['affinity']}},
2475
+                           pos=0)
2475 2476
 
2476 2477
     def test_delete_multi_server_groups(self):
2477 2478
         self.run_command('server-group-delete 12345 56789')

+ 7
- 1
novaclient/v2/shell.py View File

@@ -4422,7 +4422,13 @@ def do_availability_zone_list(cs, _args):
4422 4422
 
4423 4423
 
4424 4424
 def _print_server_group_details(server_group):
4425
-    columns = ['Id', 'Name', 'Policies', 'Members', 'Metadata']
4425
+    # This is for compatible with Nova v2 API, remove after v2
4426
+    # is dropped.
4427
+    if hasattr(server_group, 'project_id'):
4428
+        columns = ['Id', 'Name', 'Project_id', 'Policies',
4429
+                   'Members', 'Metadata']
4430
+    else:
4431
+        columns = ['Id', 'Name', 'Policies', 'Members', 'Metadata']
4426 4432
     utils.print_list(server_group, columns)
4427 4433
 
4428 4434
 

Loading…
Cancel
Save