Fix Snapshot object metadata loading
The Snapshot object will fail to correctly load metadata. Initialize the object fully so that obj_what_changed() works as intended. This prevents the error: AttributeError: 'Snapshot' object has no attribute '_obj_metadata' Closes-Bug: #1805790 Co-Author: Gorka Eguileor <geguileo@redhat.com> Change-Id: Idee4836ee3e4f9b9f4099e7a1a3d7a4bada3f7b8 (cherry picked from commit7ad0b0660c
) (cherry picked from commitbce461ba43
)
This commit is contained in:
parent
2d8f2dc117
commit
24bdb9791a
|
@ -95,7 +95,7 @@ class Snapshot(cleanable.CinderCleanableObject, base.CinderObject,
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Snapshot, self).__init__(*args, **kwargs)
|
||||
self._orig_metadata = {}
|
||||
self.metadata = kwargs.get('metadata', {})
|
||||
|
||||
self._reset_metadata_tracking()
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ class TestSnapshot(test_objects.BaseObjectsTestCase):
|
|||
self.assertEqual(volume, snapshot.volume)
|
||||
volume_get_by_id.assert_called_once_with(self.context,
|
||||
snapshot.volume_id)
|
||||
self.assertEqual(snapshot.metadata, {})
|
||||
# Test cgsnapshot lazy-loaded field
|
||||
cgsnapshot = objects.CGSnapshot(context=self.context,
|
||||
id=fake.CGSNAPSHOT_ID)
|
||||
|
|
Loading…
Reference in New Issue