Add "server group show" command

Support compute v2 "server group show" command in OSC.

Implements: blueprint nova-server-group-support
Closes-Bug: #1542171

Change-Id: I1a6d103151c704bda5b67cb9a49cc43c7d9f1d6a
This commit is contained in:
Rui Chen 2016-03-31 15:52:08 +08:00
parent 4e22728013
commit a0d79968ca
5 changed files with 70 additions and 0 deletions

View File

@ -63,3 +63,18 @@ List all server groups
.. option:: --long
List additional fields in output
server group show
-----------------
Display server group details
.. program:: server group show
.. code-block:: bash
os server group show
<server-group>
.. describe:: <server-group>
Server group to display (name or ID)

View File

@ -156,3 +156,27 @@ class ListServerGroup(command.Lister):
'Members': utils.format_list,
}
) for s in data))
class ShowServerGroup(command.ShowOne):
"""Display server group details."""
def get_parser(self, prog_name):
parser = super(ShowServerGroup, self).get_parser(prog_name)
parser.add_argument(
'server_group',
metavar='<server-group>',
help='server group to display (name or ID)',
)
return parser
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
group = utils.find_resource(compute_client.server_groups,
parsed_args.server_group)
info = {}
info.update(group._info)
columns = _get_columns(info)
data = utils.get_dict_properties(info, columns,
formatters=_formatters)
return columns, data

View File

@ -258,3 +258,26 @@ class TestServerGroupList(TestServerGroup):
self.assertEqual(self.list_columns_long, columns)
self.assertEqual(self.list_data_long, tuple(data))
class TestServerGroupShow(TestServerGroup):
def setUp(self):
super(TestServerGroupShow, self).setUp()
self.server_groups_mock.get.return_value = self.fake_server_group
self.cmd = server_group.ShowServerGroup(self.app, None)
def test_server_group_show(self):
arglist = [
'affinity_group',
]
verifylist = [
('server_group', 'affinity_group'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)

View File

@ -0,0 +1,7 @@
---
features:
- |
Add support for compute v2 ``server group`` related commands, include:
create, delete, list and show.
[Bug `1542171 <https://bugs.launchpad.net/python-openstackclient/+bug/1542171>`_]
[Blueprint `nova-server-group-support <https://blueprints.launchpad.net/python-openstackclient/+spec/nova-server-group-support>`_]

View File

@ -134,6 +134,7 @@ openstack.compute.v2 =
server_group_create = openstackclient.compute.v2.server_group:CreateServerGroup
server_group_delete = openstackclient.compute.v2.server_group:DeleteServerGroup
server_group_list = openstackclient.compute.v2.server_group:ListServerGroup
server_group_show = openstackclient.compute.v2.server_group:ShowServerGroup
usage_list = openstackclient.compute.v2.usage:ListUsage
usage_show = openstackclient.compute.v2.usage:ShowUsage