]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Pass in snapshot refs for host on provider_update
authorJohn Griffith <john.griffith8@gmail.com>
Wed, 9 Sep 2015 15:15:31 +0000 (15:15 +0000)
committerJohn Griffith <john.griffith8@gmail.com>
Wed, 9 Sep 2015 15:17:24 +0000 (15:17 +0000)
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

cinder/tests/unit/test_solidfire.py
cinder/volume/driver.py
cinder/volume/drivers/solidfire.py
cinder/volume/manager.py

index 5210e0846d874fad67ae1063a0c54b03ce882758..1f333abe32c5064c3fc3ca699ee4a64e799491d8 100644 (file)
@@ -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))
index 49e48dc8c6d4bb0827066af89626f5b7d9c6fb93..085d2c7b48bbeb34d37ace77f2edcbc9fef4d616 100644 (file)
@@ -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: <provider-id>}
index f662c382612946c5c60c03bdad3ab8b697381e59..e1c64a37c269b9add78ce86c0106b0af6645009d 100644 (file)
@@ -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)
index e0610b48cdf632fd3ce0ab099466aa724f849cf5..0587c189c908221e21a690ffc94858cf5450fef9 100644 (file)
@@ -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: