summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin_Zheng <zhengzhenyu@huawei.com>2015-08-04 19:43:47 +0800
committerZhenyu Zheng <zhengzhenyu@huawei.com>2015-08-11 03:24:56 +0000
commit01c2e60eb3f3718884dd77cb05b4cde76052fb9d (patch)
tree91ac3a1043487717c73744b139fc7a0f074af422
parentd0af5f5e981ee60bf3d10afc40a971a020611b0e (diff)
downloadpython-novaclient-01c2e60eb3f3718884dd77cb05b4cde76052fb9d.tar.gz
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
-rw-r--r--novaclient/tests/unit/v2/test_shell.py3
-rw-r--r--novaclient/v2/shell.py8
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 8b148c04..828170bd 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 9e840a70..5be248d5 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)