From 01c2e60eb3f3718884dd77cb05b4cde76052fb9d Mon Sep 17 00:00:00 2001 From: Kevin_Zheng Date: Tue, 4 Aug 2015 19:43:47 +0800 Subject: [PATCH] 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 --- novaclient/tests/unit/v2/test_shell.py | 3 ++- novaclient/v2/shell.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index 8b148c04c..828170bd3 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -2471,7 +2471,8 @@ class ShellTest(utils.TestCase): self.run_command('server-group-create wjsg affinity') self.assert_called('POST', '/os-server-groups', {'server_group': {'name': 'wjsg', - 'policies': ['affinity']}}) + 'policies': ['affinity']}}, + pos=0) def test_delete_multi_server_groups(self): self.run_command('server-group-delete 12345 56789') diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index 9e840a70d..5be248d55 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -4422,7 +4422,13 @@ def do_availability_zone_list(cs, _args): def _print_server_group_details(server_group): - columns = ['Id', 'Name', 'Policies', 'Members', 'Metadata'] + # This is for compatible with Nova v2 API, remove after v2 + # is dropped. + if hasattr(server_group, 'project_id'): + columns = ['Id', 'Name', 'Project_id', 'Policies', + 'Members', 'Metadata'] + else: + columns = ['Id', 'Name', 'Policies', 'Members', 'Metadata'] utils.print_list(server_group, columns)