Rename context.context -> context.configure

We should rename this decorator to be consistent in naming
with other rally plugin types.

Change-Id: I4586e48617f048f8c8a2e88bc3b59aa7f6dfe4a8
This commit is contained in:
Alexandr Nevenchannyy 2015-07-24 00:05:21 +03:00 committed by Boris Pavlovic
parent 7fee56b59a
commit 80fe4536b5
30 changed files with 42 additions and 41 deletions

View File

@ -270,9 +270,9 @@ From the developer's view, contexts management is implemented via **Context clas
from rally.task import context
from rally import consts
@context.context(name="your_context", *# Corresponds to the context field name in task configuration files*
order=100500, *# a number specifying the priority with which the context should be set up*
hidden=False) *# True if the context cannot be configured through the input task file*
@context.configure(name="your_context", *# Corresponds to the context field name in task configuration files*
order=100500, *# a number specifying the priority with which the context should be set up*
hidden=False) *# True if the context cannot be configured through the input task file*
class YourContext(context.Context):
*"""Yet another context class."""*

View File

@ -119,7 +119,7 @@ Inherit a class for your plugin from the base *Context* class. Then, implement t
LOG = logging.getLogger(__name__)
@context.context(name="create_flavor", order=1000)
@context.configure(name="create_flavor", order=1000)
class CreateFlavorContext(context.Context):
"""This sample create flavor with specified options before task starts and
delete it after task completion.

View File

@ -18,7 +18,7 @@ from rally import exceptions
from rally.task import context
@context.context(name="dummy_context", order=750)
@context.configure(name="dummy_context", order=750)
class DummyContext(context.Context):
"""Dummy context."""
CONFIG_SCHEMA = {

View File

@ -23,7 +23,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="ceilometer", order=450)
@context.configure(name="ceilometer", order=450)
class CeilometerSampleGenerator(context.Context):
"""Context for creating samples and collecting resources for benchmarks."""

View File

@ -25,7 +25,7 @@ from rally.task.scenarios import base as scenario_base
LOG = logging.getLogger(__name__)
@context.context(name="volumes", order=420)
@context.configure(name="volumes", order=420)
class VolumeGenerator(context.Context):
"""Context class for adding volumes to each user for benchmarks."""

View File

@ -47,7 +47,7 @@ class CleanupMixin(object):
# NOTE(amaretskiy): Set order to run this just before UserCleanup
@context.context(name="admin_cleanup", order=(sys.maxsize - 1), hidden=True)
@context.configure(name="admin_cleanup", order=(sys.maxsize - 1), hidden=True)
class AdminCleanup(CleanupMixin, context.Context):
"""Context class for admin resources cleanup."""
@ -72,7 +72,7 @@ class AdminCleanup(CleanupMixin, context.Context):
# NOTE(amaretskiy): Set maximum order to run this last
@context.context(name="cleanup", order=sys.maxsize, hidden=True)
@context.configure(name="cleanup", order=sys.maxsize, hidden=True)
class UserCleanup(CleanupMixin, context.Context):
"""Context class for user resources cleanup."""

View File

@ -24,7 +24,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="images", order=410)
@context.configure(name="images", order=410)
class ImageGenerator(context.Context):
"""Context class for adding images to each user for benchmarks."""

View File

@ -24,7 +24,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="stacks", order=435)
@context.configure(name="stacks", order=435)
class StackGenerator(context.Context):
"""Context class for create temporary stacks with resources.

View File

@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__)
# NOTE(boris-42): This context should be hidden for now and used only by
# benchmark engine. In future during various refactoring of
# validation system and rally CI testing we will make it public
@context.context(name="existing_users", order=99, hidden=True)
@context.configure(name="existing_users", order=99, hidden=True)
class ExistingUsers(context.Context):
"""This context supports using existing users in Rally.

View File

@ -25,7 +25,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="roles", order=330)
@context.configure(name="roles", order=330)
class RoleGenerator(context.Context):
"""Context class for adding temporary roles for benchmarks."""

View File

@ -52,7 +52,7 @@ CONF.register_opts(USER_CONTEXT_OPTS,
title="benchmark context options"))
@context.context(name="users", order=100)
@context.configure(name="users", order=100)
class UserGenerator(context.Context):
"""Context class for generating temporary users/tenants for benchmarks."""

View File

@ -28,7 +28,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="murano_packages", order=401)
@context.configure(name="murano_packages", order=401)
class PackageGenerator(context.Context):
"""Context class for uploading applications for murano."""

View File

@ -85,7 +85,7 @@ def _prepare_open_secgroup(endpoint, secgroup_name):
return rally_open.to_dict()
@context.context(name="allow_ssh", order=320)
@context.configure(name="allow_ssh", order=320)
class AllowSSH(context.Context):
@utils.log_task_wrapper(LOG.info, _("Enter context: `allow_ssh`"))

View File

@ -27,7 +27,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="network", order=350)
@context.configure(name="network", order=350)
class Network(context.Context):
CONFIG_SCHEMA = {
"type": "object",

View File

@ -24,7 +24,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="lbaas", order=360)
@context.configure(name="lbaas", order=360)
class Lbaas(context.Context):
CONFIG_SCHEMA = {
"type": "object",

View File

@ -29,7 +29,7 @@ from rally.verification.tempest import tempest
LOG = logging.getLogger(__name__)
@context.context(name="tempest", order=666)
@context.configure(name="tempest", order=666)
class Tempest(context.Context):
CONFIG_SCHEMA = {
"type": "object",

View File

@ -25,7 +25,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="flavors", order=340)
@context.configure(name="flavors", order=340)
class FlavorsGenerator(context.Context):
"""Context creates a list of flavors."""

View File

@ -26,7 +26,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="keypair", order=310)
@context.configure(name="keypair", order=310)
class Keypair(context.Context):
KEYPAIR_NAME = "rally_ssh_key"

View File

@ -26,7 +26,7 @@ from rally.task import types
LOG = logging.getLogger(__name__)
@context.context(name="servers", order=430)
@context.configure(name="servers", order=430)
class ServerGenerator(context.Context):
"""Context class for adding temporary servers for benchmarks.

View File

@ -29,7 +29,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="quotas", order=300)
@context.configure(name="quotas", order=300)
class Quotas(context.Context):
"""Context class for updating benchmarks' tenants quotas."""

View File

@ -30,7 +30,7 @@ CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@context.context(name="sahara_cluster", order=441)
@context.configure(name="sahara_cluster", order=441)
class SaharaCluster(context.Context):
"""Context class for setting up the Cluster an EDP job."""

View File

@ -28,7 +28,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="sahara_edp", order=442)
@context.configure(name="sahara_edp", order=442)
class SaharaEDP(context.Context):
"""Context class for setting up the environment for an EDP job."""

View File

@ -26,7 +26,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="sahara_image", order=440)
@context.configure(name="sahara_image", order=440)
class SaharaImage(context.Context):
"""Context class for adding and tagging Sahara images."""

View File

@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
@context.context(name="custom_image", order=500, hidden=True)
@context.configure(name="custom_image", order=500, hidden=True)
class BaseCustomImageGenerator(context.Context):
"""Base class for the contexts providing customized image with.

View File

@ -21,7 +21,7 @@ from rally.plugins.openstack.scenarios.vm import utils as vm_utils
import rally.task.context as context
@context.context(name="image_command_customizer", order=501)
@context.configure(name="image_command_customizer", order=501)
class ImageCommandCustomizerContext(custom_image.BaseCustomImageGenerator):
"""Context class for generating image customized by a command execution.

View File

@ -26,10 +26,10 @@ from rally.task import functional
LOG = logging.getLogger(__name__)
def context(name, order, hidden=False):
def configure(name, order, hidden=False):
"""Context class wrapper.
Each context class has to be wrapped by context() wrapper. It
Each context class has to be wrapped by configure() wrapper. It
sets essential configuration of context classes. Actually this wrapper just
adds attributes to the class.
@ -49,7 +49,7 @@ def context(name, order, hidden=False):
return wrapper
@context(name="base_context", order=0, hidden=True)
@configure(name="base_context", order=0, hidden=True)
class Context(plugin.Plugin, functional.FunctionalMixin):
"""This class is a factory for context classes.

View File

@ -21,7 +21,7 @@ from rally.task import context
LOG = logging.getLogger(__name__)
@context.context(name="create_flavor", order=1000)
@context.configure(name="create_flavor", order=1000)
class CreateFlavorContext(context.Context):
"""Create sample flavor

View File

@ -1494,7 +1494,7 @@ class FakeTimer(rally_utils.Timer):
return 0
@context.context(name="fake", order=1)
@context.configure(name="fake", order=1)
class FakeContext(context.Context):
CONFIG_SCHEMA = {
@ -1515,12 +1515,12 @@ class FakeContext(context.Context):
pass
@context.context(name="fake_hidden_context", order=1, hidden=True)
@context.configure(name="fake_hidden_context", order=1, hidden=True)
class FakeHiddenContext(FakeContext):
pass
@context.context(name="fake_user_context", order=1)
@context.configure(name="fake_user_context", order=1)
class FakeUserContext(FakeContext):
admin = {

View File

@ -25,7 +25,7 @@ from tests.unit import test
BASE = "rally.plugins.openstack.context.vm.custom_image"
@context.context(name="test_custom_image", order=500)
@context.configure(name="test_custom_image", order=500)
class TestImageGenerator(custom_image.BaseCustomImageGenerator):
def _customize_image(self, *args):
pass

View File

@ -63,7 +63,7 @@ class BaseContextTestCase(test.TestCase):
def test_setup_is_abstract(self):
@context.context("test_abstract_setup", 0)
@context.configure("test_abstract_setup", 0)
class A(context.Context):
def cleanup(self):
@ -73,7 +73,7 @@ class BaseContextTestCase(test.TestCase):
def test_cleanup_is_abstract(self):
@context.context("test_abstract_cleanup", 0)
@context.configure("test_abstract_cleanup", 0)
class A(context.Context):
def setup(self):
@ -96,7 +96,7 @@ class BaseContextTestCase(test.TestCase):
def test_lt(self):
@context.context(name="lt", order=fakes.FakeContext.get_order() - 1)
@context.configure(name="lt", order=fakes.FakeContext.get_order() - 1)
class FakeLowerContext(fakes.FakeContext):
pass
@ -107,7 +107,7 @@ class BaseContextTestCase(test.TestCase):
def test_gt(self):
@context.context(name="f", order=fakes.FakeContext.get_order() + 1)
@context.configure(name="f", order=fakes.FakeContext.get_order() + 1)
class FakeBiggerContext(fakes.FakeContext):
pass
@ -118,7 +118,8 @@ class BaseContextTestCase(test.TestCase):
def test_eq(self):
@context.context(name="fake2", order=fakes.FakeContext.get_order() + 1)
@context.configure(name="fake2",
order=fakes.FakeContext.get_order() + 1)
class FakeOtherContext(fakes.FakeContext):
pass