From: John Griffith Date: Wed, 9 Sep 2015 15:15:31 +0000 (+0000) Subject: Pass in snapshot refs for host on provider_update X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ba0a12d52f7aa044d36f43dbe003858a29142bab;p=openstack-build%2Fcinder-build.git Pass in snapshot refs for host on provider_update Now that snapshot_get_by_host is fixed we can and should pass in a list of snapshot-refs to the drivers update_provider method (just like we do with volumes). Change-Id: I062efd1b7ab16f3f999464d3190c204026bba5ec Closes-Bug: #1489182 --- diff --git a/cinder/tests/unit/test_solidfire.py b/cinder/tests/unit/test_solidfire.py index 5210e0846..1f333abe3 100644 --- a/cinder/tests/unit/test_solidfire.py +++ b/cinder/tests/unit/test_solidfire.py @@ -1023,6 +1023,7 @@ class SolidFireVolumeTestCase(test.TestCase): vid_1 = 'c9125d6d-22ff-4cc3-974d-d4e350df9c91' vid_2 = '79883868-6933-47a1-a362-edfbf8d55a18' + sid_1 = 'e3caa4fa-485e-45ca-970e-1d3e693a2520' project_1 = 'e6fb073c-11f0-4f4c-897c-90e7c7c4bcf8' project_2 = '4ff32607-305c-4a6b-a51a-0dd33124eecf' @@ -1032,7 +1033,10 @@ class SolidFireVolumeTestCase(test.TestCase): {'id': vid_2, 'project_id': project_2, 'provider_id': 22}] - + snaprefs = [{'id': sid_1, + 'project_id': project_1, + 'provider_id': None, + 'volume_id': 'vid_1'}] sf_vols = [{'volumeID': 99, 'name': 'UUID-' + vid_1, 'accountID': 100}, @@ -1046,6 +1050,7 @@ class SolidFireVolumeTestCase(test.TestCase): with mock.patch.object( sfv, '_issue_api_request', side_effect=_fake_issue_api_req): - volume_updates, snapshot_updates = sfv.update_provider_info(vrefs) + volume_updates, snapshot_updates = sfv.update_provider_info( + vrefs, snaprefs) self.assertEqual(99, volume_updates[0]['provider_id']) self.assertEqual(1, len(volume_updates)) diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 49e48dc8c..085d2c7b4 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -1388,10 +1388,11 @@ class BaseVD(object): """ return None - def update_provider_info(self, volumes): + def update_provider_info(self, volumes, snapshots): """Get provider info updates from driver. :param volumes: List of Cinder volumes to check for updates + :param snapshots: List of Cinder snapshots to check for updates :return: tuple (volume_updates, snapshot_updates) where volume updates {'id': uuid, provider_id: } diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index f662c3826..e1c64a37c 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -204,7 +204,7 @@ class SolidFireDriver(san.SanISCSIDriver): 'provider_id': sfvol['volumeID']}) return updates - def update_provider_info(self, vrefs): + def update_provider_info(self, vrefs, snaprefs): volume_updates = self._init_volume_mappings(vrefs) snapshot_updates = None return (volume_updates, snapshot_updates) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index e0610b48c..0587c189c 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -317,13 +317,14 @@ class VolumeManager(manager.SchedulerDependentManager): LOG.info(_LI("Determined volume DB was not empty at startup.")) return False - def _sync_provider_info(self, ctxt, volumes): + def _sync_provider_info(self, ctxt, volumes, snapshots): # NOTE(jdg): For now this just updates provider_id, we can add more # add more items to the update if theyr'e releveant but we need # to be safe in what we allow and add a list of allowed keys # things that make sense are provider_*, replication_status etc - updates, snapshot_updates = self.driver.update_provider_info(volumes) + updates, snapshot_updates = self.driver.update_provider_info( + volumes, snapshots) host_vols = utils.list_of_dicts_to_dict(volumes, 'id') for u in updates or []: @@ -377,7 +378,8 @@ class VolumeManager(manager.SchedulerDependentManager): self.driver.init_capabilities() volumes = self.db.volume_get_all_by_host(ctxt, self.host) - self._sync_provider_info(ctxt, volumes) + snapshots = self.db.snapshot_get_by_host(ctxt, self.host) + self._sync_provider_info(ctxt, volumes, snapshots) # FIXME volume count for exporting is wrong try: