Merge "Set "updated_at" field on access rules" into stable/xena
This commit is contained in:
commit
814201c7fe
@ -2680,6 +2680,9 @@ def share_instance_access_update(context, access_id, instance_id, updates):
|
||||
share_access_map_updates, share_instance_access_map_updates = (
|
||||
_extract_subdict_by_fields(updates, share_access_fields)
|
||||
)
|
||||
updated_at = timeutils.utcnow()
|
||||
share_access_map_updates['updated_at'] = updated_at
|
||||
share_instance_access_map_updates['updated_at'] = updated_at
|
||||
|
||||
with session.begin():
|
||||
share_access = _share_access_get_query(
|
||||
@ -3197,6 +3200,10 @@ def share_snapshot_instance_access_update(
|
||||
_extract_subdict_by_fields(updates, snapshot_access_fields)
|
||||
)
|
||||
|
||||
updated_at = timeutils.utcnow()
|
||||
snapshot_access_map_updates['updated_at'] = updated_at
|
||||
share_instance_access_map_updates['updated_at'] = updated_at
|
||||
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
|
||||
|
@ -145,6 +145,10 @@ class ShareAccessDatabaseAPITestCase(test.TestCase):
|
||||
self.assertEqual(constants.STATUS_ERROR,
|
||||
instance_access_mapping['state'])
|
||||
self.assertEqual('watson4heisman', access['access_key'])
|
||||
self.assertIsNotNone(access['updated_at'])
|
||||
time_now = timeutils.utcnow()
|
||||
self.assertTrue(access['updated_at'] < time_now)
|
||||
self.assertTrue(instance_access_mapping['updated_at'] < time_now)
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_share_access_get_all_for_instance_with_share_access_data(
|
||||
@ -1829,6 +1833,9 @@ class ShareSnapshotDatabaseAPITestCase(test.TestCase):
|
||||
{'state': constants.STATUS_ACTIVE})
|
||||
|
||||
self.assertSubDictMatch(values, actual_result.to_dict())
|
||||
self.assertIsNotNone(actual_result['updated_at'])
|
||||
time_now = timeutils.utcnow()
|
||||
self.assertTrue(actual_result['updated_at'] < time_now)
|
||||
|
||||
def test_share_snapshot_instance_access_get(self):
|
||||
access = db_utils.create_snapshot_access(
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
The ``updated_at`` field is correctly set on share and snapshot access
|
||||
rules when an update has been made on the database.
|
Loading…
x
Reference in New Issue
Block a user