Skip to content

Commit

Permalink
Merge "Rename async package to async_"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Sep 20, 2018
2 parents 670dfe4 + c58e5e0 commit 0701799
Show file tree
Hide file tree
Showing 35 changed files with 66 additions and 65 deletions.
10 changes: 5 additions & 5 deletions doc/source/admin/interoperable-image-import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@ specified in the ``glance-image-import.conf`` file. The plugins are loaded by
the Glance project team, these are already registered for you.)

A plugin must be written in Python as a `Taskflow "Task" object`_. The file
containing this object must be present in the ``glance/async/flows/plugins``
containing this object must be present in the ``glance/async_/flows/plugins``
directory. The plugin file must contain a ``get_flow`` function that returns a
Taskflow Task object wrapped in a linear flow. See the ``no_op`` plugin,
located at ``glance/async/flows/plugins/no_op.py`` for an example of how to do
located at ``glance/async_/flows/plugins/no_op.py`` for an example of how to do
this.

Specifying the plugins to be used
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

First, the plugin code must exist in the directory
``glance/async/flows/plugins``. The name of a plugin is the filename (without
``glance/async_/flows/plugins``. The name of a plugin is the filename (without
extension) of the file containing the plugin code. For example, a file named
``fred_mertz.py`` would contain the plugin ``fred_mertz``.

Expand All @@ -269,7 +269,7 @@ of the form::

For example::

no_op = glance.async.flows.plugins.no_op:get_flow
no_op = glance.async_.flows.plugins.no_op:get_flow

Make sure any plugin you want to use is included here.

Expand Down Expand Up @@ -337,7 +337,7 @@ required.
The first section, ``image_import_opts``, is used to enable the plugin by
specifying the plugin name as one of the elements of the list that is the
value of the `image_import_plugins` parameter. The plugin name is simply
the module name under glance/async/flows/plugins/
the module name under glance/async\_/flows/plugins/

The second section, ``inject_metadata_properties``, is where you set the
parameters for the injection plugin. (Note that the values you specify here
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from taskflow import retry
from taskflow import task

import glance.async.flows._internal_plugins as internal_plugins
import glance.async.flows.plugins as import_plugins
import glance.async_.flows._internal_plugins as internal_plugins
import glance.async_.flows.plugins as import_plugins
from glance.common import exception
from glance.common.scripts.image_import import main as image_import
from glance.common.scripts import utils as script_utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from taskflow import task
from taskflow.types import failure

from glance.async import utils
from glance.async_ import utils
from glance.common import exception
from glance.common.scripts.image_import import main as image_import
from glance.common.scripts import utils as script_utils
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from oslo_utils import excutils
from taskflow.patterns import linear_flow as lf

from glance.async import utils
from glance.async_ import utils
from glance.i18n import _LE


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from taskflow.patterns import linear_flow as lf
from taskflow import task

from glance.async import utils
from glance.async_ import utils
from glance.i18n import _

LOG = logging.getLogger(__name__)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# under the License.


import glance.async.flows.plugins.image_conversion
import glance.async.flows.plugins.inject_image_metadata
import glance.async_.flows.plugins.image_conversion
import glance.async_.flows.plugins.inject_image_metadata


# Note(jokke): This list contains tuples of config options for import plugins.
Expand All @@ -27,9 +27,9 @@
# registered under at the config file.
PLUGIN_OPTS = [
('inject_metadata_properties',
glance.async.flows.plugins.inject_image_metadata.inject_metadata_opts),
glance.async_.flows.plugins.inject_image_metadata.inject_metadata_opts),
('image_conversion',
glance.async.flows.plugins.image_conversion.conversion_plugin_opts),
glance.async_.flows.plugins.image_conversion.conversion_plugin_opts),
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from taskflow import engines
from taskflow.listeners import logging as llistener

import glance.async
import glance.async_
from glance.common import exception
from glance.common.scripts import utils as script_utils
from glance.i18n import _, _LE
Expand Down Expand Up @@ -85,7 +85,7 @@
CONF.register_opts(taskflow_executor_opts, group='taskflow_executor')


class TaskExecutor(glance.async.TaskExecutor):
class TaskExecutor(glance.async_.TaskExecutor):

def __init__(self, context, task_repo, image_repo, image_factory):
self.context = context
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion glance/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def readfn(*args):
MAX_COOP_READER_BUFFER_SIZE = 134217728 # 128M seems like a sane buffer limit

CONF.import_group('import_filtering_opts',
'glance.async.flows._internal_plugins')
'glance.async_.flows._internal_plugins')


def validate_import_uri(uri):
Expand Down
2 changes: 1 addition & 1 deletion glance/domain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def new_task_executor(self, context):
TaskExecutorFactory.eventlet_deprecation_warned = True
task_executor = 'taskflow'

executor_cls = ('glance.async.%s_executor.'
executor_cls = ('glance.async_.%s_executor.'
'TaskExecutor' % task_executor)
LOG.debug("Loading %s executor", task_executor)
executor = importutils.import_class(executor_cls)
Expand Down
19 changes: 10 additions & 9 deletions glance/opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

import glance.api.middleware.context
import glance.api.versions
import glance.async.flows._internal_plugins
import glance.async.flows.api_image_import
import glance.async.flows.convert
from glance.async.flows.plugins import plugin_opts
import glance.async.taskflow_executor
import glance.async_.flows._internal_plugins
import glance.async_.flows.api_image_import
import glance.async_.flows.convert
from glance.async_.flows.plugins import plugin_opts
import glance.async_.taskflow_executor
import glance.common.config
import glance.common.location_strategy
import glance.common.location_strategy.store_type
Expand Down Expand Up @@ -71,8 +71,8 @@
('image_format', glance.common.config.image_format_opts),
('task', glance.common.config.task_opts),
('taskflow_executor', list(itertools.chain(
glance.async.taskflow_executor.taskflow_executor_opts,
glance.async.flows.convert.convert_task_opts))),
glance.async_.taskflow_executor.taskflow_executor_opts,
glance.async_.flows.convert.convert_task_opts))),
('store_type_location_strategy',
glance.common.location_strategy.store_type.store_type_opts),
profiler.list_opts()[0],
Expand Down Expand Up @@ -109,9 +109,10 @@
(None, [])
]
_image_import_opts = [
('image_import_opts', glance.async.flows.api_image_import.api_import_opts),
('image_import_opts',
glance.async_.flows.api_image_import.api_import_opts),
('import_filtering_opts',
glance.async.flows._internal_plugins.import_filtering_opts),
glance.async_.flows._internal_plugins.import_filtering_opts),
]


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import glance_store
from oslo_config import cfg

import glance.async.flows.plugins.inject_image_metadata as inject_metadata
import glance.async_.flows.plugins.inject_image_metadata as inject_metadata
from glance.common import utils
from glance import domain
from glance import gateway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from oslo_config import cfg

import glance.async.flows.api_image_import as import_flow
import glance.async_.flows.api_image_import as import_flow
import glance.tests.utils as test_utils

CONF = cfg.CONF
Expand Down Expand Up @@ -52,7 +52,7 @@ def setUp(self):
self.mock_task_repo = mock.MagicMock()
self.mock_image_repo = mock.MagicMock()

@mock.patch('glance.async.flows.api_image_import._VerifyStaging.__init__')
@mock.patch('glance.async_.flows.api_image_import._VerifyStaging.__init__')
@mock.patch('taskflow.patterns.linear_flow.Flow.add')
@mock.patch('taskflow.patterns.linear_flow.__init__')
def _pass_uri(self, mock_lf_init, mock_flow_add, mock_VS_init,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from oslo_config import cfg
import six

from glance.async.flows import convert
from glance.async import taskflow_executor
from glance.async_.flows import convert
from glance.async_ import taskflow_executor
from glance.common.scripts import utils as script_utils
from glance.common import utils
from glance import domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from taskflow import task
from taskflow.types import failure

import glance.async.flows.base_import as import_flow
from glance.async import taskflow_executor
from glance.async import utils as async_utils
import glance.async_.flows.base_import as import_flow
from glance.async_ import taskflow_executor
from glance.async_ import utils as async_utils
from glance.common.scripts.image_import import main as image_import
from glance.common.scripts import utils as script_utils
from glance.common import utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from oslo_concurrency import processutils
from oslo_config import cfg

from glance.async.flows import introspect
from glance.async import utils as async_utils
from glance.async_.flows import introspect
from glance.async_ import utils as async_utils
from glance import domain
import glance.tests.utils as test_utils

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
except ImportError:
from defusedxml.ElementTree import ParseError

from glance.async.flows import ovf_process
from glance.async_.flows import ovf_process
import glance.tests.utils as test_utils
from oslo_config import cfg

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from glance_store import backend
from oslo_config import cfg

from glance.async.flows._internal_plugins import web_download
from glance.async_.flows._internal_plugins import web_download

import glance.common.exception
import glance.common.scripts.utils as script_utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import mock

import glance.async
import glance.async_
import glance.tests.utils as test_utils


Expand All @@ -28,10 +28,10 @@ def setUp(self):
self.task_repo = mock.Mock()
self.image_repo = mock.Mock()
self.image_factory = mock.Mock()
self.executor = glance.async.TaskExecutor(self.context,
self.task_repo,
self.image_repo,
self.image_factory)
self.executor = glance.async_.TaskExecutor(self.context,
self.task_repo,
self.image_repo,
self.image_factory)

def test_begin_processing(self):
# setup
Expand All @@ -40,7 +40,7 @@ def test_begin_processing(self):
task = mock.Mock()

with mock.patch.object(
glance.async.TaskExecutor,
glance.async_.TaskExecutor,
'_run') as mock_run:
self.task_repo.get.return_value = task
self.executor.begin_processing(task_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from oslo_config import cfg
from taskflow import engines

from glance.async import taskflow_executor
from glance.async_ import taskflow_executor
from glance.common.scripts.image_import import main as image_import
from glance import domain
import glance.tests.utils as test_utils
Expand Down
14 changes: 7 additions & 7 deletions glance/tests/unit/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from oslo_config import cfg
import oslo_utils.importutils

import glance.async
from glance.async import taskflow_executor
import glance.async_
from glance.async_ import taskflow_executor
from glance.common import exception
from glance.common import timeutils
from glance import domain
Expand Down Expand Up @@ -467,12 +467,12 @@ def test_fail(self, mock_utcnow):
self.task.expires_at
)

@mock.patch.object(glance.async.TaskExecutor, 'begin_processing')
@mock.patch.object(glance.async_.TaskExecutor, 'begin_processing')
def test_run(self, mock_begin_processing):
executor = glance.async.TaskExecutor(context=mock.ANY,
task_repo=mock.ANY,
image_repo=mock.ANY,
image_factory=mock.ANY)
executor = glance.async_.TaskExecutor(context=mock.ANY,
task_repo=mock.ANY,
image_repo=mock.ANY,
image_factory=mock.ANY)
self.task.run(executor)

mock_begin_processing.assert_called_once_with(self.task.task_id)
Expand Down
6 changes: 3 additions & 3 deletions glance/tests/unit/test_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import oslo_messaging
import webob

import glance.async
import glance.async_
from glance.common import exception
from glance.common import timeutils
import glance.context
Expand Down Expand Up @@ -681,7 +681,7 @@ def test_task_delete_notification_disabled(self):
self.assertEqual(0, len(output_logs))

def test_task_run_notification(self):
with mock.patch('glance.async.TaskExecutor') as mock_executor:
with mock.patch('glance.async_.TaskExecutor') as mock_executor:
executor = mock_executor.return_value
executor._run.return_value = mock.Mock()
self.task_proxy.run(executor=mock_executor)
Expand All @@ -694,7 +694,7 @@ def test_task_run_notification(self):

def test_task_run_notification_disabled(self):
self.config(disabled_notifications=['task.run'])
with mock.patch('glance.async.TaskExecutor') as mock_executor:
with mock.patch('glance.async_.TaskExecutor') as mock_executor:
executor = mock_executor.return_value
executor._run.return_value = mock.Mock()
self.task_proxy.run(executor=mock_executor)
Expand Down
18 changes: 9 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ glance.database.metadata_backend =
sqlalchemy = glance.db.sqlalchemy.metadata

glance.flows =
api_image_import = glance.async.flows.api_image_import:get_flow
import = glance.async.flows.base_import:get_flow
api_image_import = glance.async_.flows.api_image_import:get_flow
import = glance.async_.flows.base_import:get_flow

glance.flows.import =
convert = glance.async.flows.convert:get_flow
introspect = glance.async.flows.introspect:get_flow
ovf_process = glance.async.flows.ovf_process:get_flow
convert = glance.async_.flows.convert:get_flow
introspect = glance.async_.flows.introspect:get_flow
ovf_process = glance.async_.flows.ovf_process:get_flow

glance.image_import.plugins =
no_op = glance.async.flows.plugins.no_op:get_flow
inject_image_metadata=glance.async.flows.plugins.inject_image_metadata:get_flow
image_conversion=glance.async.flows.plugins.image_conversion:get_flow
no_op = glance.async_.flows.plugins.no_op:get_flow
inject_image_metadata=glance.async_.flows.plugins.inject_image_metadata:get_flow
image_conversion=glance.async_.flows.plugins.image_conversion:get_flow

glance.image_import.internal_plugins =
web_download = glance.async.flows._internal_plugins.web_download:get_flow
web_download = glance.async_.flows._internal_plugins.web_download:get_flow


[egg_info]
Expand Down

0 comments on commit 0701799

Please sign in to comment.