]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use consolidated update for failover_replication
authorPatrick East <patrick.east@purestorage.com>
Wed, 2 Sep 2015 20:58:02 +0000 (13:58 -0700)
committerPatrick East <patrick.east@purestorage.com>
Thu, 3 Sep 2015 18:47:38 +0000 (11:47 -0700)
Right now it’s using a special built volume_updates dictionary that
contains some fields *and* a model update. We then glom all of them
together into an update dictionary for the volume model.

This change simplifies them into a single model update more in-line with
how the other volume API’s work for drivers.

It also fixes a bug where the model_update property of the volume_update
was not being applied to the db model.

Change-Id: I8ad85bf0e62099a8ea4dd471dfcb64fa057f1021
Closes-Bug: #1491587

cinder/volume/manager.py

index 5fb220fa6b90047eb00cb60f436dd9bbf4f02353..2032cf8dea4c2c3b97c3c3d7a1e18d211b24c7b4 100644 (file)
@@ -3137,18 +3137,18 @@ class VolumeManager(manager.SchedulerDependentManager):
         """
         try:
             volume = self.db.volume_get(context, volume['id'])
-            volume_updates = self.driver.replication_failover(context,
-                                                              volume,
-                                                              secondary)
+            model_update = self.driver.replication_failover(context,
+                                                            volume,
+                                                            secondary)
 
-            # volume_updates is a dict containing a report of relevant
-            # items based on the backend and how it operates or what it needs
+            # model_updates is a dict containing a report of relevant
+            # items based on the backend and how it operates or what it needs.
+            # For example:
             # {'host': 'secondary-configured-cinder-backend',
-            #  'model_update': {'update-all-the-provider-info-etc'},
+            #  'provider_location: 'foo',
             #  'replication_driver_data': 'driver-specific-stuff-for-db'}
             # Where 'host' is a valid cinder host string like
             #  'foo@bar#baz'
-            # model_update and replication_driver_data are required
 
         except exception.CinderException:
 
@@ -3167,25 +3167,12 @@ class VolumeManager(manager.SchedulerDependentManager):
                                   {'replication_status': 'error'})
             raise exception.VolumeBackendAPIException(data=err_msg)
 
-        # TODO(jdg): Come back and condense thes into a single update
-        update = {}
-        model_update = volume_updates.get('model_update', None)
-        driver_update = volume_updates.get('replication_driver_data', None)
-        host_update = volume_updates.get('host', None)
-
         if model_update:
-            update['model'] = model_update
-        if driver_update:
-            update['replication_driver_data'] = driver_update
-        if host_update:
-            update['host'] = host_update
-
-        if update:
             try:
                 volume = self.db.volume_update(
                     context,
                     volume['id'],
-                    update)
+                    model_update)
 
             except exception.CinderException as ex:
                 LOG.exception(_LE("Driver replication data update failed."),