Add consumes quota field support
Cinder microversion v3.65 adds consumes_quota key to volume and snapshots as a way to differentiate between use generated resources and temporary ones. This patch adds support for this microversion and presents the consumes_quota field when the server sends it (which only happens when we request this microversion). Change-Id: I524490aa988fa4d654bfa8050d89cf99ce50bb4b Depends-On: I655a47fc75ddc11caf1defe984d9a66a9ad5a2e7 Implements: blueprint temp-resources
This commit is contained in:

committed by
Brian Rosmaita

parent
fe1a377527
commit
f94908008e
@@ -26,7 +26,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
# key is unsupported version, value is appropriate supported alternative
|
||||
REPLACEMENT_VERSIONS = {"1": "3", "2": "3"}
|
||||
MAX_VERSION = "3.64"
|
||||
MAX_VERSION = "3.65"
|
||||
MIN_VERSION = "3.0"
|
||||
|
||||
_SUBSTITUTIONS = {}
|
||||
|
@@ -1318,12 +1318,14 @@ class ShellTest(utils.TestCase):
|
||||
self.assert_called('POST', '/backups', body=expected)
|
||||
|
||||
@mock.patch("cinderclient.utils.print_list")
|
||||
def test_snapshot_list_with_userid(self, mock_print_list):
|
||||
"""Ensure 3.41 provides User ID header."""
|
||||
self.run_command('--os-volume-api-version 3.41 snapshot-list')
|
||||
def test_snapshot_list(self, mock_print_list):
|
||||
"""Ensure we always present all existing fields when listing snaps."""
|
||||
self.run_command('--os-volume-api-version 3.65 snapshot-list')
|
||||
self.assert_called('GET', '/snapshots/detail')
|
||||
columns = ['ID', 'Volume ID', 'Status', 'Name', 'Size', 'User ID']
|
||||
columns = ['ID', 'Volume ID', 'Status', 'Name', 'Size',
|
||||
'Consumes Quota', 'User ID']
|
||||
mock_print_list.assert_called_once_with(mock.ANY, columns,
|
||||
exclude_unavailable=True,
|
||||
sortby_index=0)
|
||||
|
||||
@mock.patch('cinderclient.v3.volumes.Volume.migrate_volume')
|
||||
|
@@ -507,8 +507,8 @@ def do_list(cs, args):
|
||||
[x.title().strip() for x in field_titles]) if k != 'Id']
|
||||
key_list.extend(unique_titles)
|
||||
else:
|
||||
key_list = ['ID', 'Status', 'Name', 'Size', 'Volume Type',
|
||||
'Bootable', 'Attached to']
|
||||
key_list = ['ID', 'Status', 'Name', 'Size', 'Consumes Quota',
|
||||
'Volume Type', 'Bootable', 'Attached to']
|
||||
# If all_tenants is specified, print
|
||||
# Tenant ID as well.
|
||||
if search_opts['all_tenants']:
|
||||
@@ -2173,14 +2173,13 @@ def do_snapshot_list(cs, args):
|
||||
|
||||
shell_utils.translate_volume_snapshot_keys(snapshots)
|
||||
sortby_index = None if args.sort else 0
|
||||
if cs.api_version >= api_versions.APIVersion("3.41"):
|
||||
# It's the server's responsibility to return the appropriate fields for the
|
||||
# requested microversion, we present all known fields and skip those that
|
||||
# are missing.
|
||||
utils.print_list(snapshots,
|
||||
['ID', 'Volume ID', 'Status',
|
||||
'Name', 'Size', 'User ID'],
|
||||
sortby_index=sortby_index)
|
||||
else:
|
||||
utils.print_list(snapshots,
|
||||
['ID', 'Volume ID', 'Status', 'Name', 'Size'],
|
||||
['ID', 'Volume ID', 'Status', 'Name', 'Size',
|
||||
'Consumes Quota', 'User ID'],
|
||||
exclude_unavailable=True,
|
||||
sortby_index=sortby_index)
|
||||
if show_count:
|
||||
print("Snapshot in total: %s" % total_count)
|
||||
|
Reference in New Issue
Block a user