]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Update db in CGSnapshot create
authorXing Yang <xing.yang@emc.com>
Sun, 22 Nov 2015 22:39:56 +0000 (17:39 -0500)
committerXing Yang <xing.yang@emc.com>
Mon, 8 Feb 2016 19:23:27 +0000 (14:23 -0500)
Model_update returned from the driver in cgsnapshot_create
is not used to update the db. This patch changes that.

Change-Id: I051da3b3a8f570c9dbd0893dfc93c8500a1c9cc8

cinder/volume/manager.py

index cfd466dfc0a3b8f336f693e00919fe6727f0677e..98ccec46ad2dc27470af62ebfc114f4130b1775a 100644 (file)
@@ -2970,15 +2970,12 @@ class VolumeManager(manager.SchedulerDependentManager):
 
             if snapshots_model_update:
                 for snap_model in snapshots_model_update:
-                    # Update db if status is error
-                    if snap_model['status'] == 'error':
-                        # NOTE(xyang): snapshots is a list of snapshot objects.
-                        # snapshots_model_update should be a list of dicts.
-                        snap = next((item for item in snapshots if
-                                     item.id == snap_model['id']), None)
-                        if snap:
-                            snap.status = snap_model['status']
-                            snap.save()
+                    # Update db for snapshot.
+                    # NOTE(xyang): snapshots is a list of snapshot objects.
+                    # snapshots_model_update should be a list of dicts.
+                    self.db.snapshot_update(context,
+                                            snap_model['id'],
+                                            snap_model)
 
                     if (snap_model['status'] in ['error_deleting', 'error'] and
                             model_update['status'] not in
@@ -2992,6 +2989,9 @@ class VolumeManager(manager.SchedulerDependentManager):
                     LOG.error(msg)
                     raise exception.VolumeDriverException(message=msg)
 
+                cgsnapshot.update(model_update)
+                cgsnapshot.save()
+
         except exception.CinderException:
             with excutils.save_and_reraise_exception():
                 cgsnapshot.status = 'error'