diff --git a/cinderclient/api_versions.py b/cinderclient/api_versions.py index 47a923a82..78bb8a0af 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 e7a166027..9a6852fa6 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 7ffba81a1..195d859f6 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)