diff options
| author | wangxiyuan <wangxiyuan@huawei.com> | 2017-02-10 16:39:33 +0800 |
|---|---|---|
| committer | wangxiyuan <wangxiyuan@huawei.com> | 2017-05-25 10:01:10 +0800 |
| commit | c349b318ae63dea2ce2b159f8ab3f02fafe59596 (patch) | |
| tree | 61e5e8a7a74d720e936c89db5b52f81816b0fbeb /cinderclient/v3 | |
| parent | 58c60e787f7b5a0fcc856f1114e5a2fe03beb364 (diff) | |
| download | python-cinderclient-c349b318ae63dea2ce2b159f8ab3f02fafe59596.tar.gz | |
Support list-volume for group show
V3.25 support query groups with volumes, this patch add the client
support.
Partial-Implements: blueprint improvement-to-query-consistency-group-detail
Partial-Bug: #1663474
Change-Id: Ic0d86b9265f295877eebca97ff450f5efd73b184
Diffstat (limited to 'cinderclient/v3')
| -rw-r--r-- | cinderclient/v3/groups.py | 18 | ||||
| -rw-r--r-- | cinderclient/v3/shell.py | 15 |
2 files changed, 29 insertions, 4 deletions
diff --git a/cinderclient/v3/groups.py b/cinderclient/v3/groups.py index 4bd5643..386a6a3 100644 --- a/cinderclient/v3/groups.py +++ b/cinderclient/v3/groups.py @@ -14,6 +14,7 @@ # under the License. """Group interface (v3 extension).""" +from six.moves.urllib import parse from cinderclient import api_versions from cinderclient import base @@ -106,20 +107,31 @@ class GroupManager(base.ManagerWithFind): "/groups/action", body=body) return common_base.DictWithMeta(body['group'], resp) - def get(self, group_id): + def get(self, group_id, **kwargs): """Get a group. :param group_id: The ID of the group to get. :rtype: :class:`Group` """ - return self._get("/groups/%s" % group_id, + query_params = utils.unicode_key_value_to_string(kwargs) + + query_string = "" + if query_params: + params = sorted(query_params.items(), key=lambda x: x[0]) + query_string = "?%s" % parse.urlencode(params) + + return self._get("/groups/%s" % group_id + query_string, "group") - def list(self, detailed=True, search_opts=None): + def list(self, detailed=True, search_opts=None, list_volume=False): """Lists all groups. :rtype: list of :class:`Group` """ + if list_volume: + if not search_opts: + search_opts = {} + search_opts['list_volume'] = True query_string = utils.build_query_param(search_opts) detail = "" diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index 4f85097..57586e4 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -831,13 +831,26 @@ def do_group_list(cs, args): @api_versions.wraps('3.13') +@utils.arg('--list-volume', + dest='list_volume', + metavar='<False|True>', + nargs='?', + type=bool, + const=True, + default=False, + help='Shows volumes included in the group.', + start_version='3.25') @utils.arg('group', metavar='<group>', help='Name or ID of a group.') def do_group_show(cs, args): """Shows details of a group.""" info = dict() - group = shell_utils.find_group(cs, args.group) + if getattr(args, 'list_volume', None): + group = shell_utils.find_group(cs, args.group, + list_volume=args.list_volume) + else: + group = shell_utils.find_group(cs, args.group) info.update(group._info) info.pop('links', None) |
