Implement UserID in snapshot list response

We have a gap in the microversions implemented in the cinderclient
and the MAX version being reported by the client.

One of those is the addition of "user_id" in the snapshot list
response.  This patch adds that with the appropriate version
checking.  Note that the Max version has already been updated,
but there are a few implementations missing.

Change-Id: Ia8bdb46b46091a89996e404825466430b8906d18
Partial-Bug: #1715759
This commit is contained in:
j-griffith
2017-09-07 23:29:55 +00:00
committed by John Griffith
parent 3869163aa9
commit 3d1225cbb0
2 changed files with 18 additions and 3 deletions

View File

@@ -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)

View File

@@ -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')