Set "updated_at" field on access rules
Closes-Bug: #2031193 Change-Id: I9f9f32401d4af4d40b8beb271fa2c9b5ea24105e Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com> (cherry-picked from commit234d26cdec
) (cherry picked from commite6950e3456
) (cherry picked from commit1ee09205ad
) (cherry picked from commit1b9d500f22
) (cherry picked from commit127007a1d0
)
This commit is contained in:
parent
6386142c0d
commit
b23874d8be
|
@ -2636,6 +2636,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(
|
||||
|
@ -3134,6 +3137,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(
|
||||
|
@ -1787,6 +1791,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…
Reference in New Issue