diff --git a/cinder/objects/snapshot.py b/cinder/objects/snapshot.py index 6669c4614c9..934c0f774c4 100644 --- a/cinder/objects/snapshot.py +++ b/cinder/objects/snapshot.py @@ -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() diff --git a/cinder/tests/unit/objects/test_snapshot.py b/cinder/tests/unit/objects/test_snapshot.py index 9e361ba536d..e091bc3ce80 100644 --- a/cinder/tests/unit/objects/test_snapshot.py +++ b/cinder/tests/unit/objects/test_snapshot.py @@ -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)