6a28603f48
1. Create_volume flows were moved to separate files from __init__.py. In future each flow should be implemented in a separate file. 2. Add flows.common package for tasks that could be used by different flows. 3. Proposed file structure for flows is more clean and helps to find and reuse common code. 4. _exception_to_unicode function and tests were removed because never used. Partially implements: blueprint create-volume-flow Change-Id: I63473f549f0c501fe0f373830bc1080239d01892
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
# For more information please visit: https://wiki.openstack.org/wiki/TaskFlow
|
|
from taskflow import task
|
|
|
|
|
|
def _make_task_name(cls, addons=None):
|
|
"""Makes a pretty name for a task class."""
|
|
base_name = ".".join([cls.__module__, cls.__name__])
|
|
extra = ''
|
|
if addons:
|
|
extra = ';%s' % (", ".join([str(a) for a in addons]))
|
|
return base_name + extra
|
|
|
|
|
|
class CinderTask(task.Task):
|
|
"""The root task class for all cinder tasks.
|
|
|
|
It automatically names the given task using the module and class that
|
|
implement the given task as the task name.
|
|
"""
|
|
|
|
def __init__(self, addons=None, **kwargs):
|
|
super(CinderTask, self).__init__(_make_task_name(self.__class__,
|
|
addons),
|
|
**kwargs)
|