Show user_id when cinder snapshot-show

The user_id attribute should be shown for end user or other
project(eg:ceilometer, cloudkitty). And it should consistent
with other cinder command to be shown.

Change-Id: I629bacb73135fd7756f6008b5c376a8ab0f0df6a
Closes-Bug: #1614095
This commit is contained in:
luqitao 2017-06-09 03:07:54 -04:00
parent 3046f75968
commit b1e2b0459c
12 changed files with 33 additions and 4 deletions

View File

@ -2037,6 +2037,13 @@ user_id:
in: body
required: true
type: string
user_id_2:
description: |
The UUID of the user.
in: body
required: true
type: string
min_version: 3.41
user_message:
description: |
The translated readable message corresponding to ``event_id``.

View File

@ -6,6 +6,7 @@
"metadata": {},
"volume_id": "5aa119a8-d25b-45a7-8d1b-88e127885635",
"size": 1,
"user_id": "40c2102f4a554b848d96b14f3eec39ed",
"id": "ffa9bc5e-1172-4021-acaf-cdcd78a9584d",
"name": "snap-001"
}

View File

@ -5,6 +5,7 @@
"description": "Daily backup",
"created_at": "2013-02-25T04:13:17.000000",
"metadata": {},
"user_id": "40c2102f4a554b848d96b14f3eec39ed",
"volume_id": "5aa119a8-d25b-45a7-8d1b-88e127885635",
"os-extended-snapshot-attributes:project_id": "0c2eba2c5af04d3f9e9d0d410b371fde",
"size": 1,

View File

@ -6,6 +6,7 @@
"id": "4b502fcb-1f26-45f8-9fe5-3b9a0a52eaf2",
"size": 1,
"status": "available",
"user_id": "40c2102f4a554b848d96b14f3eec39ed",
"volume_id": "2402b902-0b7a-458c-9c07-7435a826f794"
}
}

View File

@ -7,6 +7,7 @@
},
"os-extended-snapshot-attributes:progress": "100%",
"name": "test-volume-snapshot",
"user_id": "40c2102f4a554b848d96b14f3eec39ed",
"volume_id": "173f7b48-c4c1-4e70-9acc-086b39073506",
"os-extended-snapshot-attributes:project_id": "bab7d5c60cd041a0a36f7c4b6e1dd978",
"created_at": "2015-11-29T02:25:51.000000",

View File

@ -6,6 +6,7 @@
"name": "test"
},
"name": "test-volume-snapshot",
"user_id": "40c2102f4a554b848d96b14f3eec39ed",
"volume_id": "173f7b48-c4c1-4e70-9acc-086b39073506",
"created_at": "2015-11-29T02:25:51.000000",
"size": 1,

View File

@ -65,6 +65,7 @@ Response Parameters
- description: description
- created_at: created_at
- name: name
- user_id: user_id_2
- volume_id: volume_id
- os-extended-snapshot-attributes:project_id: os-extended-snapshot-attributes:project_id
- size: size
@ -116,6 +117,7 @@ Response Parameters
- created_at: created_at
- name: name
- snapshot: snapshot
- user_id: user_id_2
- volume_id: volume_id
- metadata: metadata
- id: id
@ -158,6 +160,7 @@ Response Parameters
- description: description
- created_at: created_at
- name: name
- user_id: user_id_2
- volume_id: volume_id
- metadata: metadata
- id: id
@ -319,6 +322,7 @@ Response Parameters
- created_at: created_at
- name: name
- snapshot: snapshot
- user_id: user_id_2
- volume_id: volume_id
- os-extended-snapshot-attributes:project_id: os-extended-snapshot-attributes:project_id
- size: size
@ -373,6 +377,7 @@ Response Parameters
- created_at: created_at
- name: name
- snapshot: snapshot
- user_id: user_id_2
- volume_id: volume_id
- metadata: metadata
- id: id

View File

@ -94,7 +94,7 @@ REST_API_VERSION_HISTORY = """
* 3.38 - Add replication group API (Tiramisu).
* 3.39 - Add ``project_id`` admin filters support to limits.
* 3.40 - Add volume revert to its latest snapshot support.
* 3.41 - Add ``user_id`` field to snapshot list/detail and snapshot show.
"""
# The minimum and maximum versions of the API supported
@ -102,7 +102,7 @@ REST_API_VERSION_HISTORY = """
# minimum version of the API supported.
# Explicitly using /v1 or /v2 endpoints will still work
_MIN_API_VERSION = "3.0"
_MAX_API_VERSION = "3.40"
_MAX_API_VERSION = "3.41"
_LEGACY_API_VERSION1 = "1.0"
_LEGACY_API_VERSION2 = "2.0"

View File

@ -338,3 +338,7 @@ user documentation.
3.40
----
Add volume revert to its latest snapshot support.
3.41
----
Add ``user_id`` field to snapshot list/detail and snapshot show.

View File

@ -29,5 +29,6 @@ class ViewBuilder(views_v2.ViewBuilder):
if req_version.matches("3.14", None):
snapshot_ref['snapshot']['group_snapshot_id'] = (
snapshot.get('group_snapshot_id'))
if req_version.matches("3.41", None):
snapshot_ref['snapshot']['user_id'] = snapshot.get('user_id')
return snapshot_ref

View File

@ -68,7 +68,7 @@ class SnapshotApiTest(test.TestCase):
self.controller = snapshots.SnapshotsController()
self.ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
@ddt.data('3.14', '3.13')
@ddt.data('3.14', '3.13', '3.41')
@mock.patch('cinder.db.snapshot_metadata_get', return_value=dict())
@mock.patch('cinder.objects.Volume.get_by_id')
@mock.patch('cinder.objects.Snapshot.get_by_id')
@ -98,8 +98,12 @@ class SnapshotApiTest(test.TestCase):
self.assertIn('updated_at', resp_dict['snapshot'])
if max_ver == '3.14':
self.assertIn('group_snapshot_id', resp_dict['snapshot'])
self.assertNotIn('user_id', resp_dict['snapshot'])
elif max_ver == '3.13':
self.assertNotIn('group_snapshot_id', resp_dict['snapshot'])
self.assertNotIn('user_id', resp_dict['snapshot'])
elif max_ver == '3.41':
self.assertIn('user_id', resp_dict['snapshot'])
def test_snapshot_show_invalid_id(self):
snapshot_id = INVALID_UUID

View File

@ -0,0 +1,3 @@
---
features:
- Add ``user_id`` field to snapshot list/detail and snapshot show.