Merge "Add missing `updated_at` field in share-instance show."

This commit is contained in:
Zuul 2022-04-11 17:57:24 +00:00 committed by Gerrit Code Review
commit c33da8bbb5
8 changed files with 29 additions and 2 deletions

View File

@ -7,6 +7,7 @@
"availability_zone": "nova",
"replica_state": null,
"created_at": "2015-09-07T08:41:20.000000",
"updated_at": "2015-09-07T08:43:10.000000",
"share_network_id": "713df749-aac0-4a54-af52-10f6c991e80c",
"cast_rules_to_readonly": false,
"share_server_id": "ba11930a-bf1a-4aa7-bae4-a8dfbaa3cc73",
@ -22,6 +23,7 @@
"availability_zone": "nova",
"replica_state": null,
"created_at": "2015-09-07T08:51:34.000000",
"updated_at": "2015-09-10T02:01:22.000000",
"share_network_id": "713df749-aac0-4a54-af52-10f6c991e80c",
"cast_rules_to_readonly": false,
"share_server_id": "ba11930a-bf1a-4aa7-bae4-a8dfbaa3cc73",
@ -37,6 +39,7 @@
"availability_zone": "nova",
"replica_state": null,
"created_at": "2015-09-07T09:01:15.000000",
"updated_at": "2015-09-07T09:02:30.000000",
"share_network_id": "713df749-aac0-4a54-af52-10f6c991e80c",
"cast_rules_to_readonly": false,
"share_server_id": "ba11930a-bf1a-4aa7-bae4-a8dfbaa3cc73",

View File

@ -6,6 +6,7 @@
"availability_zone": "nova",
"replica_state": null,
"created_at": "2015-09-07T08:51:34.000000",
"updated_at": "2015-09-07T08:52:20.000000",
"cast_rules_to_readonly": false,
"share_network_id": "713df749-aac0-4a54-af52-10f6c991e80c",
"share_server_id": "ba11930a-bf1a-4aa7-bae4-a8dfbaa3cc73",

View File

@ -56,6 +56,7 @@ Response parameters
- progress: progress_share_instance
- availability_zone: availability_zone
- created_at: created_at
- updated_at: updated_at
- replica_state: replica_state
- export_location: export_location
- export_locations: export_locations
@ -116,6 +117,7 @@ Response parameters
- progress: progress_share_instance
- availability_zone: availability_zone
- created_at: created_at
- updated_at: updated_at
- replica_state: replica_state
- export_location: export_location
- export_locations: export_locations

View File

@ -185,6 +185,7 @@ REST_API_VERSION_HISTORY = """
* 2.70 - Added support for multiple share network subnets in the same
availability zone. Also, users can add subnets for an in-use share
network.
* 2.71 - Added 'updated_at' field in share instance show API output.
"""
@ -192,7 +193,7 @@ REST_API_VERSION_HISTORY = """
# The default api version request is defined to be the
# minimum version of the API supported.
_MIN_API_VERSION = "2.0"
_MAX_API_VERSION = "2.70"
_MAX_API_VERSION = "2.71"
DEFAULT_API_VERSION = _MIN_API_VERSION

View File

@ -392,3 +392,7 @@ ____
for an in-use share network. To distinguish this update support a new
property called 'network_allocation_update_support' was added in the share
network and share server.
2.71
----
Added 'updated_at' field in share instance show API output.

View File

@ -28,6 +28,7 @@ class ViewBuilder(common.ViewBuilder):
"add_cast_rules_to_readonly_field",
"add_progress_field",
"translate_creating_from_snapshot_status",
"add_updated_at_field",
]
def detail_list(self, request, instances):
@ -106,3 +107,7 @@ class ViewBuilder(common.ViewBuilder):
@common.ViewBuilder.versioned_method("2.54")
def add_progress_field(self, context, instance_dict, share_instance):
instance_dict['progress'] = share_instance.get('progress')
@common.ViewBuilder.versioned_method("2.71")
def add_updated_at_field(self, context, instance_dict, share_instance):
instance_dict['updated_at'] = share_instance.get('updated_at')

View File

@ -133,7 +133,7 @@ class ShareInstancesAPITest(test.TestCase):
self.mock_policy_check.assert_called_once_with(
req_context, self.resource_name, 'index')
@ddt.data('2.3', '2.54')
@ddt.data('2.3', '2.54', '2.71')
def test_show(self, version):
test_instance = db_utils.create_share(size=1).instance
id = test_instance['id']
@ -147,6 +147,12 @@ class ShareInstancesAPITest(test.TestCase):
self.assertIn("progress", actual_result['share_instance'])
else:
self.assertNotIn("progress", actual_result['share_instance'])
if (api_version_request.APIVersionRequest(version) >=
api_version_request.APIVersionRequest("2.71")):
self.assertIn("updated_at", actual_result['share_instance'])
else:
self.assertNotIn("updated_at", actual_result['share_instance'])
self.mock_policy_check.assert_called_once_with(
self.admin_context, self.resource_name, 'show')

View File

@ -0,0 +1,5 @@
---
fixes:
- |
In order to let user know when was the last time share instance updated, a
field ``updated_at`` is added in the response of share instance show API.