diff options
author | Gorka Eguileor <geguileo@redhat.com> | 2021-04-21 16:01:11 +0200 |
---|---|---|
committer | Brian Rosmaita <rosmaita.fossdev@gmail.com> | 2021-08-25 17:17:46 -0400 |
commit | f94908008e7432678f89c58e7e61773e71c2acf5 (patch) | |
tree | 4588f364ae1609c2ac782cd0a6a49bc00af1767b | |
parent | fe1a377527ae8477246571eaa2a785014f746af5 (diff) | |
download | python-cinderclient-f94908008e7432678f89c58e7e61773e71c2acf5.tar.gz |
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
-rw-r--r-- | cinderclient/api_versions.py | 2 | ||||
-rw-r--r-- | cinderclient/tests/unit/v3/test_shell.py | 10 | ||||
-rw-r--r-- | cinderclient/v3/shell.py | 21 |
3 files changed, 17 insertions, 16 deletions
diff --git a/cinderclient/api_versions.py b/cinderclient/api_versions.py index 47a923a..78bb8a0 100644 --- a/cinderclient/api_versions.py +++ b/cinderclient/api_versions.py @@ -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 = {} diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py index e7a1660..9a6852f 100644 --- a/cinderclient/tests/unit/v3/test_shell.py +++ b/cinderclient/tests/unit/v3/test_shell.py @@ -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') diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index 7ffba81..195d859 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -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,15 +2173,14 @@ 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"): - 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'], - sortby_index=sortby_index) + # 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', + 'Consumes Quota', 'User ID'], + exclude_unavailable=True, + sortby_index=sortby_index) if show_count: print("Snapshot in total: %s" % total_count) |