]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Pass db into driver as constructor's parameter
authorAnn Kamyshnikova <akamyshnikova@mirantis.com>
Mon, 26 Aug 2013 13:13:06 +0000 (17:13 +0400)
committerAnn Kamyshnikova <akamyshnikova@mirantis.com>
Wed, 28 Aug 2013 09:05:23 +0000 (13:05 +0400)
This will be required when code specific for target admin moves to
brick.

Change-Id: Ia48ea927f2efb2c551c359f7e7f98bf586919ab3

cinder/volume/driver.py
cinder/volume/manager.py

index 9dbf3778e425cd5f112f6a1d0501958e3440f319..1925cbe61e4b8f3666fca05e655717ad969b3f90 100644 (file)
@@ -102,7 +102,7 @@ class VolumeDriver(object):
 
     def __init__(self, execute=utils.execute, *args, **kwargs):
         # NOTE(vish): db is set by Manager
-        self.db = None
+        self.db = kwargs.get('db')
         self.configuration = kwargs.get('configuration', None)
         if self.configuration:
             self.configuration.append_config_values(volume_opts)
index feb78a0215ddc9db4efa8804cea0a6c4aeb71696..a3728597e329959816fd7f49d7ca5fcbe7d20682 100644 (file)
@@ -135,6 +135,9 @@ class VolumeManager(manager.SchedulerDependentManager):
     def __init__(self, volume_driver=None, service_name=None,
                  *args, **kwargs):
         """Load the driver from the one specified in args, or from flags."""
+        # update_service_capabilities needs service_name to be volume
+        super(VolumeManager, self).__init__(service_name='volume',
+                                            *args, **kwargs)
         self.configuration = Configuration(volume_manager_opts,
                                            config_group=service_name)
         if not volume_driver:
@@ -147,13 +150,8 @@ class VolumeManager(manager.SchedulerDependentManager):
             volume_driver = MAPPING[volume_driver]
         self.driver = importutils.import_object(
             volume_driver,
-            configuration=self.configuration)
-        # update_service_capabilities needs service_name to be volume
-        super(VolumeManager, self).__init__(service_name='volume',
-                                            *args, **kwargs)
-        # NOTE(vish): Implementation specific db handling is done
-        #             by the driver.
-        self.driver.db = self.db
+            configuration=self.configuration,
+            db=self.db)
 
     def init_host(self):
         """Do any initialization that needs to be run if this is a