Support availability-zone in volume type
Since 3.52, new option '--filters' has been added to 'type-list' command, and it's only valid for administrator. Change-Id: I140f6d61a2747d4fcaabfbccea864dcc7eb841d1 Depends-On: I4e6aa7af707bd063e7edf2b0bf28e3071ad5c67a Partial-Implements: bp support-az-in-volumetype
This commit is contained in:
parent
bd712fa0ca
commit
5a1513244c
@ -29,7 +29,7 @@ LOG = logging.getLogger(__name__)
|
||||
# key is a deprecated version and value is an alternative version.
|
||||
DEPRECATED_VERSIONS = {"1": "2"}
|
||||
DEPRECATED_VERSION = "2.0"
|
||||
MAX_VERSION = "3.50"
|
||||
MAX_VERSION = "3.52"
|
||||
MIN_VERSION = "3.0"
|
||||
|
||||
_SUBSTITUTIONS = {}
|
||||
|
@ -244,6 +244,20 @@ class ShellTest(utils.TestCase):
|
||||
self.run_command,
|
||||
'list --group_id fake_id')
|
||||
|
||||
def test_type_list_with_filters_invalid(self):
|
||||
self.assertRaises(exceptions.UnsupportedAttribute,
|
||||
self.run_command,
|
||||
'--os-volume-api-version 3.51 type-list '
|
||||
'--filters key=value')
|
||||
|
||||
def test_type_list_with_filters(self):
|
||||
self.run_command('--os-volume-api-version 3.52 type-list '
|
||||
'--filters extra_specs={key:value}')
|
||||
self.assert_called(
|
||||
'GET', '/types?%s' % parse.urlencode(
|
||||
{'extra_specs':
|
||||
{six.text_type('key'): six.text_type('value')}}))
|
||||
|
||||
@ddt.data("3.10", "3.11")
|
||||
def test_list_with_group_id_after_3_10(self, version):
|
||||
command = ('--os-volume-api-version %s list --group_id fake_id' %
|
||||
|
@ -52,6 +52,27 @@ def do_list_filters(cs, args):
|
||||
shell_utils.print_resource_filter_list(filters)
|
||||
|
||||
|
||||
@utils.arg('--filters',
|
||||
type=six.text_type,
|
||||
nargs='*',
|
||||
start_version='3.52',
|
||||
metavar='<key=value>',
|
||||
default=None,
|
||||
help="Filter key and value pairs. Admin only.")
|
||||
def do_type_list(cs, args):
|
||||
"""Lists available 'volume types'.
|
||||
|
||||
(Only admin and tenant users will see private types)
|
||||
"""
|
||||
# pylint: disable=function-redefined
|
||||
search_opts = {}
|
||||
# Update search option with `filters`
|
||||
if hasattr(args, 'filters') and args.filters is not None:
|
||||
search_opts.update(shell_utils.extract_filters(args.filters))
|
||||
vtypes = cs.volume_types.list(search_opts=search_opts)
|
||||
shell_utils.print_volume_type_list(vtypes)
|
||||
|
||||
|
||||
@utils.arg('--all-tenants',
|
||||
metavar='<all_tenants>',
|
||||
nargs='?',
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
|
||||
"""Volume Type interface."""
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from cinderclient.apiclient import base as common_base
|
||||
from cinderclient import base
|
||||
@ -86,10 +87,13 @@ class VolumeTypeManager(base.ManagerWithFind):
|
||||
|
||||
:rtype: list of :class:`VolumeType`.
|
||||
"""
|
||||
query_string = ''
|
||||
if not is_public:
|
||||
query_string = '?is_public=%s' % is_public
|
||||
return self._list("/types%s" % (query_string), "volume_types")
|
||||
if not search_opts:
|
||||
search_opts = dict()
|
||||
if is_public:
|
||||
search_opts.update({"is_public": is_public})
|
||||
query_string = "?%s" % parse.urlencode(
|
||||
search_opts) if search_opts else ''
|
||||
return self._list("/types%s" % query_string, "volume_types")
|
||||
|
||||
def get(self, volume_type):
|
||||
"""Get a specific volume type.
|
||||
|
@ -4341,11 +4341,18 @@ cinder type-list
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
usage: cinder type-list
|
||||
usage: cinder type-list [--filters <key=value> [<key=value> ...]]
|
||||
|
||||
Lists available 'volume types'. (Only admin and tenant users will see private
|
||||
types)
|
||||
|
||||
**Optional arguments:**
|
||||
|
||||
``--filters [<key=value> [<key=value> ...]]``
|
||||
Filter key and value pairs. Please use 'cinder list-filters'
|
||||
to check enabled filters from server, Default=None.
|
||||
(Supported by API version 3.52 and later)
|
||||
|
||||
.. _cinder_type-show:
|
||||
|
||||
cinder type-show
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- New command option ``--filters`` is added to ``type-list``
|
||||
command to support filter types since 3.52, and it's only
|
||||
valid for administrator.
|
Loading…
Reference in New Issue
Block a user