Set "updated_at" field on access rules
Closes-Bug: #2031193 Change-Id: I9f9f32401d4af4d40b8beb271fa2c9b5ea24105e Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
This commit is contained in:
parent
824fdb3270
commit
234d26cdec
@ -3082,6 +3082,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(
|
||||
@ -3771,6 +3774,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():
|
||||
|
||||
|
@ -146,6 +146,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(
|
||||
@ -2037,6 +2041,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