From ca7050ec206284bf74cd06ab7b24178967c42bcc Mon Sep 17 00:00:00 2001 From: Patrick East Date: Wed, 2 Sep 2015 13:58:02 -0700 Subject: [PATCH] Use consolidated update for failover_replication MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 5fb220fa6..2032cf8de 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -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."), -- 2.45.2