]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Move the frequently injection task to the base folder.
authorJoshua Harlow <harlowja@yahoo-inc.com>
Wed, 21 Aug 2013 00:47:12 +0000 (17:47 -0700)
committerJoshua Harlow <harlowja@yahoo-inc.com>
Thu, 22 Aug 2013 21:30:30 +0000 (14:30 -0700)
Key/value injection is a typical way to bootstrap a
dependency based system (as there needs to be an
initial set of values to depend on). Since this inject
task is frequently used to accomplish this we should
just move it to the base file.

Change-Id: Ib49e949f319bc18744fc95f8a02fab1eade0fb6a

cinder/volume/flows/base.py
cinder/volume/flows/create_volume.py

index 9c074c52e6101fde1784e425e0d081fd1c95ddd2..54ce06ad098fd023f36807240b1083394ecae9de 100644 (file)
@@ -37,3 +37,25 @@ class CinderTask(task.Task):
     def __init__(self, addons=None):
         super(CinderTask, self).__init__(_make_task_name(self.__class__,
                                                          addons))
+
+
+class InjectTask(CinderTask):
+    """This injects a dict into the flow.
+
+    This injection is done so that the keys (and values) provided can be
+    dependended on by tasks further down the line. Since taskflow is dependency
+    based this can be considered the bootstrapping task that provides an
+    initial set of values for other tasks to get started with. If this did not
+    exist then tasks would fail locating there dependent tasks and the values
+    said dependent tasks produce.
+
+    Reversion strategy: N/A
+    """
+
+    def __init__(self, inject_what, addons=None):
+        super(InjectTask, self).__init__(addons=addons)
+        self.provides.update(inject_what.keys())
+        self._inject = inject_what
+
+    def __call__(self, context):
+        return dict(self._inject)
index e88c37980157f266fb9218e823f0877d9bd381b9..f495121f6fe7c361325a512a95e9108f8fe5dfbd 100644 (file)
@@ -146,28 +146,6 @@ def _error_out_volume(context, db, volume_id, reason=None):
                                           'update': update})
 
 
-class ValuesInjectTask(base.CinderTask):
-    """This injects a dict into the flow.
-
-    This injection is done so that the keys (and values) provided can be
-    dependended on by tasks further down the line. Since taskflow is dependency
-    based this can be considered the bootstrapping task that provides an
-    initial set of values for other tasks to get started with. If this did not
-    exist then tasks would fail locating there dependent tasks and the values
-    said dependent tasks produce.
-
-    Reversion strategy: N/A
-    """
-
-    def __init__(self, inject_what):
-        super(ValuesInjectTask, self).__init__(addons=[ACTION])
-        self.provides.update(inject_what.keys())
-        self._inject = inject_what
-
-    def __call__(self, context):
-        return dict(self._inject)
-
-
 class ExtractVolumeRequestTask(base.CinderTask):
     """Processes an api request values into a validated set of values.
 
@@ -1569,7 +1547,7 @@ def get_api_flow(scheduler_rpcapi, volume_rpcapi, db,
     # This injects the initial starting flow values into the workflow so that
     # the dependency order of the tasks provides/requires can be correctly
     # determined.
-    api_flow.add(ValuesInjectTask(create_what))
+    api_flow.add(base.InjectTask(create_what, addons=[ACTION]))
     api_flow.add(ExtractVolumeRequestTask(image_service,
                                           az_check_functor))
     api_flow.add(QuotaReserveTask())
@@ -1611,13 +1589,13 @@ def get_scheduler_flow(db, driver, request_spec=None, filter_properties=None,
     # This injects the initial starting flow values into the workflow so that
     # the dependency order of the tasks provides/requires can be correctly
     # determined.
-    scheduler_flow.add(ValuesInjectTask({
+    scheduler_flow.add(base.InjectTask({
         'request_spec': request_spec,
         'filter_properties': filter_properties,
         'volume_id': volume_id,
         'snapshot_id': snapshot_id,
         'image_id': image_id,
-    }))
+    }, addons=[ACTION]))
 
     # This will extract and clean the spec from the starting values.
     scheduler_flow.add(ExtractSchedulerSpecTask(db))
@@ -1715,14 +1693,14 @@ def get_manager_flow(db, driver, scheduler_rpcapi, host, volume_id,
     # This injects the initial starting flow values into the workflow so that
     # the dependency order of the tasks provides/requires can be correctly
     # determined.
-    volume_flow.add(ValuesInjectTask({
+    volume_flow.add(base.InjectTask({
         'filter_properties': filter_properties,
         'image_id': image_id,
         'request_spec': request_spec,
         'snapshot_id': snapshot_id,
         'source_volid': source_volid,
         'volume_id': volume_id,
-    }))
+    }, addons=[ACTION]))
 
     # We can actually just check if we should reschedule on failure ahead of
     # time instead of trying to determine this later, certain values are needed