diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py index ccfb45b35..87567dcea 100644 --- a/cinderclient/tests/unit/v3/test_shell.py +++ b/cinderclient/tests/unit/v3/test_shell.py @@ -998,3 +998,12 @@ class ShellTest(utils.TestCase): cmd += '1234' self.run_command(cmd) self.assert_called('POST', '/backups') + + @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') + self.assert_called('GET', '/snapshots/detail') + columns = ['ID', 'Volume ID', 'Status', 'Name', 'Size', 'User ID'] + mock_print_list.assert_called_once_with(mock.ANY, columns, + sortby_index=0) diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index d81bb03c5..208c81ff2 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -1722,9 +1722,15 @@ def do_snapshot_list(cs, args): sort=args.sort) shell_utils.translate_volume_snapshot_keys(snapshots) sortby_index = None if args.sort else 0 - utils.print_list(snapshots, - ['ID', 'Volume ID', 'Status', 'Name', 'Size'], - sortby_index=sortby_index) + 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) @api_versions.wraps('3.27')