From ce7e952d7800b6b94ba381c29558d0d6fb67711d Mon Sep 17 00:00:00 2001 From: Xing Yang Date: Sun, 22 Nov 2015 17:39:56 -0500 Subject: [PATCH] Update db in CGSnapshot create 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index cfd466dfc..98ccec46a 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -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' -- 2.45.2