How to use the rally.task.context.configure function in rally

To help you get started, we’ve selected a few rally examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ovn-org / ovn-scale-test / rally_ovs / plugins / ovs / context / sandbox.py View on Github external
import six
from rally.common.i18n import _
from rally.common import logging
from rally.common import db
from rally import consts
from rally.task import context

from rally_ovs.plugins.ovs.consts import ResourceType

LOG = logging.getLogger(__name__)




@context.configure(name="sandbox", order=110)
class Sandbox(context.Context):
    """Context for xxxxx."""

    CONFIG_SCHEMA = {
        "type": "object",
        "$schema": consts.JSON_SCHEMA,
        "properties": {
            "farm": {
                "type": "string"
            },
            "tag": {
                "type": "string"
            }
        },
        "additionalProperties": True
    }
github openstack / rally-openstack / tests / unit / contexts / vm / test_custom_image.py View on Github external
#    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.

import mock
from rally.task import context

from rally_openstack.contexts.vm import custom_image
from tests.unit import test


BASE = "rally_openstack.contexts.vm.custom_image"


@context.configure(name="test_custom_image", order=500)
class FakeImageGenerator(custom_image.BaseCustomImageGenerator):
    def _customize_image(self, *args):
        pass


class BaseCustomImageContextVMTestCase(test.TestCase):

    def setUp(self):
        super(BaseCustomImageContextVMTestCase, self).setUp()

        self.context = test.get_test_context()
        self.context.update({
            "config": {
                "test_custom_image": {
                    "image": {"name": "image"},
                    "flavor": {"name": "flavor"},
github openstack / rally / rally / plugins / openstack / context / network / networks.py View on Github external
from rally.common import logging
from rally.common import utils
from rally.common import validation
from rally import consts
from rally.plugins.openstack import osclients
from rally.plugins.openstack.wrappers import network as network_wrapper
from rally.task import context


LOG = logging.getLogger(__name__)


# NOTE(andreykurilin): admin is used only by cleanup
@validation.add("required_platform", platform="openstack", admin=True,
                users=True)
@context.configure(name="network", platform="openstack", order=350)
class Network(context.Context):
    """Create networking resources.

    This creates networks for all tenants, and optionally creates
    another resources like subnets and routers.
    """

    CONFIG_SCHEMA = {
        "type": "object",
        "$schema": consts.JSON_SCHEMA,
        "properties": {
            "start_cidr": {
                "type": "string"
            },
            "networks_per_tenant": {
                "type": "integer",
github openstack / rally-openstack / rally_openstack / contexts / api_versions.py View on Github external
if ("service_type" in plugin_cfg[client] or
                        "service_name" in plugin_cfg[client]):
                    client_cls.is_service_type_configurable()

                if "version" in plugin_cfg[client]:
                    client_cls.validate_version(plugin_cfg[client]["version"])

            except exceptions.RallyException as e:
                return self.fail(
                    "Invalid settings for '%(client)s': %(error)s" % {
                        "client": client,
                        "error": e.format_message()})


@validation.add("check_api_versions")
@context.configure(name="api_versions", platform="openstack", order=150)
class OpenStackAPIVersions(context.Context):
    """Context for specifying OpenStack clients versions and service types.

    Some OpenStack services support several API versions. To recognize
    the endpoints of each version, separate service types are provided in
    Keystone service catalog.

    Rally has the map of default service names - service types. But since
    service type is an entity, which can be configured manually by admin(
    via keystone api) without relation to service name, such map can be
    insufficient.

    Also, Keystone service catalog does not provide a map types to name
    (this statement is true for keystone < 3.3 ).

    This context was designed for not-default service types and not-default
github openstack / rally-openstack / rally_openstack / contexts / heat / stacks.py View on Github external
#    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.

from rally.common import utils as rutils
from rally.common import validation
from rally.task import context

from rally_openstack.cleanup import manager as resource_manager
from rally_openstack import consts
from rally_openstack.scenarios.heat import utils as heat_utils


@validation.add("required_platform", platform="openstack", users=True)
@context.configure(name="stacks", platform="openstack", order=435)
class StackGenerator(context.Context):
    """Context class for create temporary stacks with resources.

       Stack generator allows to generate arbitrary number of stacks for
       each tenant before test scenarios. In addition, it allows to define
       number of resources (namely OS::Heat::RandomString) that will be created
       inside each stack. After test execution the stacks will be
       automatically removed from heat.
    """

    # The schema of the context configuration format
    CONFIG_SCHEMA = {
        "type": "object",
        "$schema": consts.JSON_SCHEMA,

        "properties": {
github openstack / rally / rally / plugins / openstack / context / sahara / sahara_cluster.py View on Github external
from rally.common import cfg
from rally.common import utils as rutils
from rally.common import validation
from rally import consts
from rally import exceptions
from rally.plugins.openstack.cleanup import manager as resource_manager
from rally.plugins.openstack.scenarios.sahara import utils
from rally.task import context
from rally.task import utils as bench_utils


CONF = cfg.CONF


@validation.add("required_platform", platform="openstack", users=True)
@context.configure(name="sahara_cluster", platform="openstack", order=441)
class SaharaCluster(context.Context):
    """Context class for setting up the Cluster an EDP job."""

    CONFIG_SCHEMA = {
        "type": "object",
        "$schema": consts.JSON_SCHEMA,
        "properties": {
            "plugin_name": {
                "type": "string"
            },
            "hadoop_version": {
                "type": "string",
            },
            "workers_count": {
                "type": "integer",
                "minimum": 1
github openstack / rally / rally / plugins / openstack / context / glance / images.py View on Github external
from rally.common import logging
from rally.common import utils as rutils
from rally.common import validation
from rally import consts
from rally.plugins.openstack.cleanup import manager as resource_manager
from rally.plugins.openstack import osclients
from rally.plugins.openstack.services.image import image
from rally.task import context

CONF = cfg.CONF

LOG = logging.getLogger(__name__)


@validation.add("required_platform", platform="openstack", users=True)
@context.configure(name="images", platform="openstack", order=410)
class ImageGenerator(context.Context):
    """Uploads specified Glance images to every tenant."""

    CONFIG_SCHEMA = {
        "type": "object",
        "$schema": consts.JSON_SCHEMA,
        "properties": {
            "image_url": {
                "type": "string",
                "description": "Location of the source to create image from."
            },
            "disk_format": {
                "description": "The format of the disk.",
                "enum": ["qcow2", "raw", "vhd", "vmdk", "vdi", "iso", "aki",
                         "ari", "ami"]
            },
github openstack / rally-openstack / rally_openstack / contexts / cleanup / admin.py View on Github external
#    License for the specific language governing permissions and limitations
#    under the License.

import sys

from rally.common import validation
from rally.task import context

from rally_openstack.cleanup import manager
from rally_openstack.contexts.cleanup import base
from rally_openstack import scenario


@validation.add(name="check_cleanup_resources", admin_required=True)
# NOTE(amaretskiy): Set order to run this just before UserCleanup
@context.configure(name="admin_cleanup", platform="openstack",
                   order=(sys.maxsize - 1), hidden=True)
class AdminCleanup(base.CleanupMixin, context.Context):
    """Context class for admin resources cleanup."""

    def cleanup(self):
        manager.cleanup(
            names=self.config,
            admin_required=True,
            admin=self.context["admin"],
            users=self.context.get("users", []),
            superclass=scenario.OpenStackScenario,
            task_id=self.get_owner_id())
github openstack / rally / rally / plugins / openstack / context / ec2 / servers.py View on Github external
# License for the specific language governing permissions and limitations
# under the License.

from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally.plugins.openstack.cleanup import manager as resource_manager
from rally.plugins.openstack.scenarios.ec2 import utils as ec2_utils
from rally.plugins.openstack import types
from rally.task import context


LOG = logging.getLogger(__name__)


@context.configure(name="ec2_servers", platform="openstack", order=460)
class EC2ServerGenerator(context.Context):
    """Creates specified amount of nova servers in each tenant uses ec2 API."""

    CONFIG_SCHEMA = {
        "type": "object",
        "$schema": consts.JSON_SCHEMA,
        "properties": {
            "image": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    }
                },
                "additionalProperties": False
            },
github openstack / rally / rally / plugins / openstack / context / magnum / clusters.py View on Github external
# License for the specific language governing permissions and limitations
# under the License.

from rally.common.i18n import _
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally.plugins.openstack.cleanup import manager as resource_manager
from rally.plugins.openstack.scenarios.magnum import utils as magnum_utils
from rally.task import context


LOG = logging.getLogger(__name__)


@context.configure(name="clusters", order=480)
class ClusterGenerator(context.Context):
    """Context class for generating temporary cluster for benchmarks."""

    CONFIG_SCHEMA = {
        "type": "object",
        "$schema": consts.JSON_SCHEMA,
        "properties": {
            "cluster_template_uuid": {
                "type": "string"
            },
            "node_count": {
                "type": "integer",
                "minimum": 1,
                "default": 1
            },
        },