diff --git a/api-ref/source/v3/parameters.yaml b/api-ref/source/v3/parameters.yaml index 9ba961b4402..3f6acefa8fb 100644 --- a/api-ref/source/v3/parameters.yaml +++ b/api-ref/source/v3/parameters.yaml @@ -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``. diff --git a/api-ref/source/v3/samples/snapshot-create-response.json b/api-ref/source/v3/samples/snapshot-create-response.json index d8901e88dec..6f6cc931017 100644 --- a/api-ref/source/v3/samples/snapshot-create-response.json +++ b/api-ref/source/v3/samples/snapshot-create-response.json @@ -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" } diff --git a/api-ref/source/v3/samples/snapshot-show-response.json b/api-ref/source/v3/samples/snapshot-show-response.json index 25a8c6c9def..f5524180aca 100644 --- a/api-ref/source/v3/samples/snapshot-show-response.json +++ b/api-ref/source/v3/samples/snapshot-show-response.json @@ -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, diff --git a/api-ref/source/v3/samples/snapshot-update-response.json b/api-ref/source/v3/samples/snapshot-update-response.json index a2fa2779393..6c4415b04ff 100644 --- a/api-ref/source/v3/samples/snapshot-update-response.json +++ b/api-ref/source/v3/samples/snapshot-update-response.json @@ -6,6 +6,7 @@ "id": "4b502fcb-1f26-45f8-9fe5-3b9a0a52eaf2", "size": 1, "status": "available", + "user_id": "40c2102f4a554b848d96b14f3eec39ed", "volume_id": "2402b902-0b7a-458c-9c07-7435a826f794" } } diff --git a/api-ref/source/v3/samples/snapshots-list-detailed-response.json b/api-ref/source/v3/samples/snapshots-list-detailed-response.json index 463b98ec12d..f077cf629f8 100644 --- a/api-ref/source/v3/samples/snapshots-list-detailed-response.json +++ b/api-ref/source/v3/samples/snapshots-list-detailed-response.json @@ -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", diff --git a/api-ref/source/v3/samples/snapshots-list-response.json b/api-ref/source/v3/samples/snapshots-list-response.json index 8d7e4973acb..8777228938a 100644 --- a/api-ref/source/v3/samples/snapshots-list-response.json +++ b/api-ref/source/v3/samples/snapshots-list-response.json @@ -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, diff --git a/api-ref/source/v3/volumes-v3-snapshots.inc b/api-ref/source/v3/volumes-v3-snapshots.inc index 597be57c201..e7639434bcb 100644 --- a/api-ref/source/v3/volumes-v3-snapshots.inc +++ b/api-ref/source/v3/volumes-v3-snapshots.inc @@ -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 diff --git a/cinder/api/openstack/api_version_request.py b/cinder/api/openstack/api_version_request.py index bc34f2f370f..be845111900 100644 --- a/cinder/api/openstack/api_version_request.py +++ b/cinder/api/openstack/api_version_request.py @@ -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" diff --git a/cinder/api/openstack/rest_api_version_history.rst b/cinder/api/openstack/rest_api_version_history.rst index 1f01e414cc4..40d6c2f56d2 100644 --- a/cinder/api/openstack/rest_api_version_history.rst +++ b/cinder/api/openstack/rest_api_version_history.rst @@ -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. diff --git a/cinder/api/v3/views/snapshots.py b/cinder/api/v3/views/snapshots.py index 1f3e3b79fdd..c5bd87005a5 100644 --- a/cinder/api/v3/views/snapshots.py +++ b/cinder/api/v3/views/snapshots.py @@ -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 diff --git a/cinder/tests/unit/api/v3/test_snapshots.py b/cinder/tests/unit/api/v3/test_snapshots.py index 9fe7d0481d0..5cb1408822e 100644 --- a/cinder/tests/unit/api/v3/test_snapshots.py +++ b/cinder/tests/unit/api/v3/test_snapshots.py @@ -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 diff --git a/releasenotes/notes/bug-1614095-add-user_id-to-snapshot_show-4884fab825983c3a.yaml b/releasenotes/notes/bug-1614095-add-user_id-to-snapshot_show-4884fab825983c3a.yaml new file mode 100644 index 00000000000..0440a6ea6ca --- /dev/null +++ b/releasenotes/notes/bug-1614095-add-user_id-to-snapshot_show-4884fab825983c3a.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add ``user_id`` field to snapshot list/detail and snapshot show.