Introduce a base class for all OpenStack context
Currently this class is a new home for _iterate_per_tenants method that was deprecated at rally framework. Change-Id: I1f301455dc32c78270ed0411c6a79a5f2c68e827
This commit is contained in:
parent
83eae7f02a
commit
e43b0728c8
@ -19,6 +19,12 @@ Changelog
|
|||||||
[unreleased]
|
[unreleased]
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
Added
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
* The *rally_openstack.task.context.OpenStackContext* class which provides
|
||||||
|
helpers for all OpenStack context.
|
||||||
|
|
||||||
Changed
|
Changed
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ import random
|
|||||||
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.configure("check_api_versions")
|
@validation.configure("check_api_versions")
|
||||||
@ -44,7 +44,7 @@ class CheckOpenStackAPIVersionsValidator(validation.Validator):
|
|||||||
|
|
||||||
@validation.add("check_api_versions")
|
@validation.add("check_api_versions")
|
||||||
@context.configure(name="api_versions", platform="openstack", order=150)
|
@context.configure(name="api_versions", platform="openstack", order=150)
|
||||||
class OpenStackAPIVersions(context.Context):
|
class OpenStackAPIVersions(context.OpenStackContext):
|
||||||
"""Context for specifying OpenStack clients versions and service types.
|
"""Context for specifying OpenStack clients versions and service types.
|
||||||
|
|
||||||
Some OpenStack services support several API versions. To recognize
|
Some OpenStack services support several API versions. To recognize
|
||||||
|
@ -15,13 +15,12 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.ceilometer import utils as ceilo_utils
|
from rally_openstack.scenarios.ceilometer import utils as ceilo_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -29,7 +28,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="ceilometer", platform="openstack", order=450)
|
@context.configure(name="ceilometer", platform="openstack", order=450)
|
||||||
class CeilometerSampleGenerator(context.Context):
|
class CeilometerSampleGenerator(context.OpenStackContext):
|
||||||
"""Creates ceilometer samples and resources."""
|
"""Creates ceilometer samples and resources."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -128,8 +127,7 @@ class CeilometerSampleGenerator(context.Context):
|
|||||||
}
|
}
|
||||||
resources = []
|
resources = []
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
self.context["tenants"][tenant_id]["samples"] = []
|
self.context["tenants"][tenant_id]["samples"] = []
|
||||||
self.context["tenants"][tenant_id]["resources"] = []
|
self.context["tenants"][tenant_id]["resources"] = []
|
||||||
scenario = ceilo_utils.CeilometerScenario(
|
scenario = ceilo_utils.CeilometerScenario(
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.services.storage import block
|
from rally_openstack.services.storage import block
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", admin=True)
|
@validation.add("required_platform", platform="openstack", admin=True)
|
||||||
@context.configure(name="volume_types", platform="openstack", order=410)
|
@context.configure(name="volume_types", platform="openstack", order=410)
|
||||||
class VolumeTypeGenerator(context.Context):
|
class VolumeTypeGenerator(context.OpenStackContext):
|
||||||
"""Adds cinder volumes types."""
|
"""Adds cinder volumes types."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
|
@ -12,17 +12,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.services.storage import block
|
from rally_openstack.services.storage import block
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@context.configure(name="volumes", platform="openstack", order=420)
|
@context.configure(name="volumes", platform="openstack", order=420)
|
||||||
class VolumeGenerator(context.Context):
|
class VolumeGenerator(context.OpenStackContext):
|
||||||
"""Creates volumes for each tenant."""
|
"""Creates volumes for each tenant."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -59,8 +57,7 @@ class VolumeGenerator(context.Context):
|
|||||||
volume_type = self.config.get("type", None)
|
volume_type = self.config.get("type", None)
|
||||||
volumes_per_tenant = self.config["volumes_per_tenant"]
|
volumes_per_tenant = self.config["volumes_per_tenant"]
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
self.context["tenants"][tenant_id].setdefault("volumes", [])
|
self.context["tenants"][tenant_id].setdefault("volumes", [])
|
||||||
clients = osclients.Clients(user["credential"])
|
clients = osclients.Clients(user["credential"])
|
||||||
cinder_service = block.BlockStorage(
|
cinder_service = block.BlockStorage(
|
||||||
|
@ -16,18 +16,18 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager
|
from rally_openstack.cleanup import manager
|
||||||
from rally_openstack.contexts.cleanup import base
|
from rally_openstack.contexts.cleanup import base
|
||||||
from rally_openstack import scenario
|
from rally_openstack import scenario
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add(name="check_cleanup_resources", admin_required=True)
|
@validation.add(name="check_cleanup_resources", admin_required=True)
|
||||||
# NOTE(amaretskiy): Set order to run this just before UserCleanup
|
# NOTE(amaretskiy): Set order to run this just before UserCleanup
|
||||||
@context.configure(name="admin_cleanup", platform="openstack",
|
@context.configure(name="admin_cleanup", platform="openstack",
|
||||||
order=(sys.maxsize - 1), hidden=True)
|
order=(sys.maxsize - 1), hidden=True)
|
||||||
class AdminCleanup(base.CleanupMixin, context.Context):
|
class AdminCleanup(base.CleanupMixin, context.OpenStackContext):
|
||||||
"""Context class for admin resources cleanup."""
|
"""Context class for admin resources cleanup."""
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
@ -16,18 +16,18 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager
|
from rally_openstack.cleanup import manager
|
||||||
from rally_openstack.contexts.cleanup import base
|
from rally_openstack.contexts.cleanup import base
|
||||||
from rally_openstack import scenario
|
from rally_openstack import scenario
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add(name="check_cleanup_resources", admin_required=False)
|
@validation.add(name="check_cleanup_resources", admin_required=False)
|
||||||
# NOTE(amaretskiy): Set maximum order to run this last
|
# NOTE(amaretskiy): Set maximum order to run this last
|
||||||
@context.configure(name="cleanup", platform="openstack", order=sys.maxsize,
|
@context.configure(name="cleanup", platform="openstack", order=sys.maxsize,
|
||||||
hidden=True)
|
hidden=True)
|
||||||
class UserCleanup(base.CleanupMixin, context.Context):
|
class UserCleanup(base.CleanupMixin, context.OpenStackContext):
|
||||||
"""Context class for user resources cleanup."""
|
"""Context class for user resources cleanup."""
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
@ -18,12 +18,12 @@ import pkgutil
|
|||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.scenarios.heat import utils as heat_utils
|
from rally_openstack.scenarios.heat import utils as heat_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
def get_data(filename_or_resource):
|
def get_data(filename_or_resource):
|
||||||
@ -34,7 +34,7 @@ def get_data(filename_or_resource):
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="heat_dataplane", platform="openstack", order=435)
|
@context.configure(name="heat_dataplane", platform="openstack", order=435)
|
||||||
class HeatDataplane(context.Context):
|
class HeatDataplane(context.OpenStackContext):
|
||||||
"""Context class for create stack by given template.
|
"""Context class for create stack by given template.
|
||||||
|
|
||||||
This context will create stacks by given template for each tenant and
|
This context will create stacks by given template for each tenant and
|
||||||
@ -125,8 +125,7 @@ class HeatDataplane(context.Context):
|
|||||||
with parameters.unlocked():
|
with parameters.unlocked():
|
||||||
if "network_id" not in parameters:
|
if "network_id" not in parameters:
|
||||||
parameters["network_id"] = self._get_public_network_id()
|
parameters["network_id"] = self._get_public_network_id()
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
for name, path in self.config.get("context_parameters",
|
for name, path in self.config.get("context_parameters",
|
||||||
{}).items():
|
{}).items():
|
||||||
parameters[name] = self._get_context_parameter(user,
|
parameters[name] = self._get_context_parameter(user,
|
||||||
|
@ -12,18 +12,17 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.designate import utils
|
from rally_openstack.scenarios.designate import utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="zones", platform="openstack", order=600)
|
@context.configure(name="zones", platform="openstack", order=600)
|
||||||
class ZoneGenerator(context.Context):
|
class ZoneGenerator(context.OpenStackContext):
|
||||||
"""Context to add `zones_per_tenant` zones for each tenant."""
|
"""Context to add `zones_per_tenant` zones for each tenant."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -43,7 +42,7 @@ class ZoneGenerator(context.Context):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants(
|
||||||
self.context["users"]):
|
self.context["users"]):
|
||||||
self.context["tenants"][tenant_id].setdefault("zones", [])
|
self.context["tenants"][tenant_id].setdefault("zones", [])
|
||||||
designate_util = utils.DesignateScenario(
|
designate_util = utils.DesignateScenario(
|
||||||
|
@ -16,12 +16,12 @@ from rally.common import cfg
|
|||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.services.image import image
|
from rally_openstack.services.image import image
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
@ -31,7 +31,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="images", platform="openstack", order=410)
|
@context.configure(name="images", platform="openstack", order=410)
|
||||||
class ImageGenerator(context.Context):
|
class ImageGenerator(context.OpenStackContext):
|
||||||
"""Uploads specified Glance images to every tenant."""
|
"""Uploads specified Glance images to every tenant."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -159,8 +159,7 @@ class ImageGenerator(context.Context):
|
|||||||
if "image_name" in self.config and images_per_tenant == 1:
|
if "image_name" in self.config and images_per_tenant == 1:
|
||||||
image_name = self.config["image_name"]
|
image_name = self.config["image_name"]
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
current_images = []
|
current_images = []
|
||||||
clients = osclients.Clients(user["credential"])
|
clients = osclients.Clients(user["credential"])
|
||||||
image_service = image.Image(
|
image_service = image.Image(
|
||||||
|
@ -13,18 +13,17 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.heat import utils as heat_utils
|
from rally_openstack.scenarios.heat import utils as heat_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="stacks", platform="openstack", order=435)
|
@context.configure(name="stacks", platform="openstack", order=435)
|
||||||
class StackGenerator(context.Context):
|
class StackGenerator(context.OpenStackContext):
|
||||||
"""Context class for create temporary stacks with resources.
|
"""Context class for create temporary stacks with resources.
|
||||||
|
|
||||||
Stack generator allows to generate arbitrary number of stacks for
|
Stack generator allows to generate arbitrary number of stacks for
|
||||||
@ -72,8 +71,7 @@ class StackGenerator(context.Context):
|
|||||||
def setup(self):
|
def setup(self):
|
||||||
template = self._prepare_stack_template(
|
template = self._prepare_stack_template(
|
||||||
self.config["resources_per_stack"])
|
self.config["resources_per_stack"])
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
heat_scenario = heat_utils.HeatScenario(
|
heat_scenario = heat_utils.HeatScenario(
|
||||||
{"user": user, "task": self.context["task"],
|
{"user": user, "task": self.context["task"],
|
||||||
"owner_id": self.context["owner_id"]})
|
"owner_id": self.context["owner_id"]})
|
||||||
|
@ -18,11 +18,11 @@ from rally.common import cfg
|
|||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.services.identity import identity
|
from rally_openstack.services.identity import identity
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -32,7 +32,7 @@ CONF = cfg.CONF
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="roles", platform="openstack", order=330)
|
@context.configure(name="roles", platform="openstack", order=330)
|
||||||
class RoleGenerator(context.Context):
|
class RoleGenerator(context.OpenStackContext):
|
||||||
"""Context class for assigning roles for users."""
|
"""Context class for assigning roles for users."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
|
@ -20,15 +20,14 @@ import uuid
|
|||||||
from rally.common import broker
|
from rally.common import broker
|
||||||
from rally.common import cfg
|
from rally.common import cfg
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import credential
|
from rally_openstack import credential
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.services.identity import identity
|
from rally_openstack.services.identity import identity
|
||||||
|
from rally_openstack.task import context
|
||||||
from rally_openstack.wrappers import network
|
from rally_openstack.wrappers import network
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ USER_DOMAIN_DESCR = "ID of domain in which users will be created."
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="users", platform="openstack", order=100)
|
@context.configure(name="users", platform="openstack", order=100)
|
||||||
class UserGenerator(context.Context):
|
class UserGenerator(context.OpenStackContext):
|
||||||
"""Creates specified amount of keystone users and tenants."""
|
"""Creates specified amount of keystone users and tenants."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -149,8 +148,7 @@ class UserGenerator(context.Context):
|
|||||||
LOG.debug("Security group context is disabled: %s" % msg)
|
LOG.debug("Security group context is disabled: %s" % msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
with logging.ExceptionLogger(
|
with logging.ExceptionLogger(
|
||||||
LOG, "Unable to delete default security group"):
|
LOG, "Unable to delete default security group"):
|
||||||
uclients = osclients.Clients(user["credential"])
|
uclients = osclients.Clients(user["credential"])
|
||||||
|
@ -16,15 +16,15 @@ import os
|
|||||||
|
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.magnum import utils as magnum_utils
|
from rally_openstack.scenarios.magnum import utils as magnum_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="ca_certs", platform="openstack", order=490)
|
@context.configure(name="ca_certs", platform="openstack", order=490)
|
||||||
class CaCertGenerator(context.Context):
|
class CaCertGenerator(context.OpenStackContext):
|
||||||
"""Creates ca certs."""
|
"""Creates ca certs."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -70,8 +70,7 @@ class CaCertGenerator(context.Context):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
|
|
||||||
magnum_scenario = magnum_utils.MagnumScenario({
|
magnum_scenario = magnum_utils.MagnumScenario({
|
||||||
"user": user,
|
"user": user,
|
||||||
|
@ -12,18 +12,17 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.magnum import utils as magnum_utils
|
from rally_openstack.scenarios.magnum import utils as magnum_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="cluster_templates", platform="openstack", order=470)
|
@context.configure(name="cluster_templates", platform="openstack", order=470)
|
||||||
class ClusterTemplateGenerator(context.Context):
|
class ClusterTemplateGenerator(context.OpenStackContext):
|
||||||
"""Creates Magnum cluster template."""
|
"""Creates Magnum cluster template."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -102,8 +101,7 @@ class ClusterTemplateGenerator(context.Context):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
|
|
||||||
magnum_scenario = magnum_utils.MagnumScenario({
|
magnum_scenario = magnum_utils.MagnumScenario({
|
||||||
"user": user,
|
"user": user,
|
||||||
|
@ -12,19 +12,18 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.magnum import utils as magnum_utils
|
from rally_openstack.scenarios.magnum import utils as magnum_utils
|
||||||
from rally_openstack.scenarios.nova import utils as nova_utils
|
from rally_openstack.scenarios.nova import utils as nova_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="clusters", platform="openstack", order=480)
|
@context.configure(name="clusters", platform="openstack", order=480)
|
||||||
class ClusterGenerator(context.Context):
|
class ClusterGenerator(context.OpenStackContext):
|
||||||
"""Creates specified amount of Magnum clusters."""
|
"""Creates specified amount of Magnum clusters."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -45,8 +44,7 @@ class ClusterGenerator(context.Context):
|
|||||||
DEFAULT_CONFIG = {"node_count": 1}
|
DEFAULT_CONFIG = {"node_count": 1}
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
|
|
||||||
nova_scenario = nova_utils.NovaScenario({
|
nova_scenario = nova_utils.NovaScenario({
|
||||||
"user": user,
|
"user": user,
|
||||||
|
@ -14,14 +14,13 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import cfg
|
from rally.common import cfg
|
||||||
from rally.common import utils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts as rally_consts
|
from rally_openstack import consts as rally_consts
|
||||||
from rally_openstack.contexts.manila import consts
|
from rally_openstack.contexts.manila import consts
|
||||||
from rally_openstack.scenarios.manila import utils as manila_utils
|
from rally_openstack.scenarios.manila import utils as manila_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
@ -30,7 +29,7 @@ CONTEXT_NAME = consts.SECURITY_SERVICES_CONTEXT_NAME
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name=CONTEXT_NAME, platform="openstack", order=445)
|
@context.configure(name=CONTEXT_NAME, platform="openstack", order=445)
|
||||||
class SecurityServices(context.Context):
|
class SecurityServices(context.OpenStackContext):
|
||||||
"""This context creates 'security services' for Manila project."""
|
"""This context creates 'security services' for Manila project."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -65,7 +64,7 @@ class SecurityServices(context.Context):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user, tenant_id in (utils.iterate_per_tenants(
|
for user, tenant_id in (self._iterate_per_tenants(
|
||||||
self.context.get("users", []))):
|
self.context.get("users", []))):
|
||||||
self.context["tenants"][tenant_id][CONTEXT_NAME] = {
|
self.context["tenants"][tenant_id][CONTEXT_NAME] = {
|
||||||
"security_services": [],
|
"security_services": [],
|
||||||
|
@ -15,15 +15,14 @@
|
|||||||
|
|
||||||
from rally.common import cfg
|
from rally.common import cfg
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts as rally_consts
|
from rally_openstack import consts as rally_consts
|
||||||
from rally_openstack.contexts.manila import consts
|
from rally_openstack.contexts.manila import consts
|
||||||
from rally_openstack.scenarios.manila import utils as manila_utils
|
from rally_openstack.scenarios.manila import utils as manila_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
@ -63,7 +62,7 @@ users that does not satisfy criteria.
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name=CONTEXT_NAME, platform="openstack", order=450)
|
@context.configure(name=CONTEXT_NAME, platform="openstack", order=450)
|
||||||
class ShareNetworks(context.Context):
|
class ShareNetworks(context.OpenStackContext):
|
||||||
"""This context creates share networks for Manila project."""
|
"""This context creates share networks for Manila project."""
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -141,7 +140,7 @@ class ShareNetworks(context.Context):
|
|||||||
|
|
||||||
def _setup_for_autocreated_users(self):
|
def _setup_for_autocreated_users(self):
|
||||||
# Create share network for each network of tenant
|
# Create share network for each network of tenant
|
||||||
for user, tenant_id in (utils.iterate_per_tenants(
|
for user, tenant_id in (self._iterate_per_tenants(
|
||||||
self.context.get("users", []))):
|
self.context.get("users", []))):
|
||||||
networks = self.context["tenants"][tenant_id].get("networks")
|
networks = self.context["tenants"][tenant_id].get("networks")
|
||||||
manila_scenario = manila_utils.ManilaScenario({
|
manila_scenario = manila_utils.ManilaScenario({
|
||||||
|
@ -14,14 +14,13 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import cfg
|
from rally.common import cfg
|
||||||
from rally.common import utils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts as rally_consts
|
from rally_openstack import consts as rally_consts
|
||||||
from rally_openstack.contexts.manila import consts
|
from rally_openstack.contexts.manila import consts
|
||||||
from rally_openstack.scenarios.manila import utils as manila_utils
|
from rally_openstack.scenarios.manila import utils as manila_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CONTEXT_NAME = consts.SHARES_CONTEXT_NAME
|
CONTEXT_NAME = consts.SHARES_CONTEXT_NAME
|
||||||
@ -29,7 +28,7 @@ CONTEXT_NAME = consts.SHARES_CONTEXT_NAME
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name=CONTEXT_NAME, platform="openstack", order=455)
|
@context.configure(name=CONTEXT_NAME, platform="openstack", order=455)
|
||||||
class Shares(context.Context):
|
class Shares(context.OpenStackContext):
|
||||||
"""This context creates shares for Manila project."""
|
"""This context creates shares for Manila project."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -78,8 +77,7 @@ class Shares(context.Context):
|
|||||||
tenant_ctxt["shares"].append(share.to_dict())
|
tenant_ctxt["shares"].append(share.to_dict())
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user, tenant_id in (
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
utils.iterate_per_tenants(self.context.get("users", []))):
|
|
||||||
manila_scenario = manila_utils.ManilaScenario({
|
manila_scenario = manila_utils.ManilaScenario({
|
||||||
"task": self.task,
|
"task": self.task,
|
||||||
"owner_id": self.context["owner_id"],
|
"owner_id": self.context["owner_id"],
|
||||||
|
@ -14,15 +14,15 @@
|
|||||||
|
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.monasca import utils as monasca_utils
|
from rally_openstack.scenarios.monasca import utils as monasca_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="monasca_metrics", platform="openstack", order=510)
|
@context.configure(name="monasca_metrics", platform="openstack", order=510)
|
||||||
class MonascaMetricGenerator(context.Context):
|
class MonascaMetricGenerator(context.OpenStackContext):
|
||||||
"""Creates Monasca Metrics."""
|
"""Creates Monasca Metrics."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -85,8 +85,7 @@ class MonascaMetricGenerator(context.Context):
|
|||||||
"dimensions": self.config["dimensions"]
|
"dimensions": self.config["dimensions"]
|
||||||
}
|
}
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
scenario = monasca_utils.MonascaScenario(
|
scenario = monasca_utils.MonascaScenario(
|
||||||
context={"user": user, "task": self.context["task"]}
|
context={"user": user, "task": self.context["task"]}
|
||||||
)
|
)
|
||||||
|
@ -13,18 +13,17 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.murano import utils as murano_utils
|
from rally_openstack.scenarios.murano import utils as murano_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="murano_environments", platform="openstack", order=402)
|
@context.configure(name="murano_environments", platform="openstack", order=402)
|
||||||
class EnvironmentGenerator(context.Context):
|
class EnvironmentGenerator(context.OpenStackContext):
|
||||||
"""Context class for creating murano environments."""
|
"""Context class for creating murano environments."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -41,8 +40,7 @@ class EnvironmentGenerator(context.Context):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user, tenant_id in utils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
self.context["tenants"][tenant_id]["environments"] = []
|
self.context["tenants"][tenant_id]["environments"] = []
|
||||||
for i in range(self.config["environments_per_tenant"]):
|
for i in range(self.config["environments_per_tenant"]):
|
||||||
murano_util = murano_utils.MuranoScenario(
|
murano_util = murano_utils.MuranoScenario(
|
||||||
|
@ -16,20 +16,19 @@
|
|||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from rally.common import utils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.scenarios.murano import utils as mutils
|
from rally_openstack.scenarios.murano import utils as mutils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="murano_packages", platform="openstack", order=401)
|
@context.configure(name="murano_packages", platform="openstack", order=401)
|
||||||
class PackageGenerator(context.Context):
|
class PackageGenerator(context.OpenStackContext):
|
||||||
"""Context class for uploading applications for murano."""
|
"""Context class for uploading applications for murano."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -57,8 +56,7 @@ class PackageGenerator(context.Context):
|
|||||||
raise exceptions.ContextSetupFailure(msg=msg % pckg_path,
|
raise exceptions.ContextSetupFailure(msg=msg % pckg_path,
|
||||||
ctx_name=self.get_name())
|
ctx_name=self.get_name())
|
||||||
|
|
||||||
for user, tenant_id in utils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
clients = osclients.Clients(user["credential"])
|
clients = osclients.Clients(user["credential"])
|
||||||
self.context["tenants"][tenant_id]["packages"] = []
|
self.context["tenants"][tenant_id]["packages"] = []
|
||||||
if is_config_app_dir:
|
if is_config_app_dir:
|
||||||
|
@ -14,11 +14,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
|
from rally_openstack.task import context
|
||||||
from rally_openstack.wrappers import network
|
from rally_openstack.wrappers import network
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +116,7 @@ def _prepare_open_secgroup(credential, secgroup_name):
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="allow_ssh", platform="openstack", order=320)
|
@context.configure(name="allow_ssh", platform="openstack", order=320)
|
||||||
class AllowSSH(context.Context):
|
class AllowSSH(context.OpenStackContext):
|
||||||
"""Sets up security groups for all users to access VM via SSH."""
|
"""Sets up security groups for all users to access VM via SSH."""
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
@ -138,8 +137,7 @@ class AllowSSH(context.Context):
|
|||||||
secgroup_name)
|
secgroup_name)
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
for user, tenant_id in utils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
with logging.ExceptionLogger(
|
with logging.ExceptionLogger(
|
||||||
LOG,
|
LOG,
|
||||||
"Unable to delete security group: %s."
|
"Unable to delete security group: %s."
|
||||||
|
@ -12,18 +12,17 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
|
from rally_openstack.task import context
|
||||||
from rally_openstack.wrappers import network as network_wrapper
|
from rally_openstack.wrappers import network as network_wrapper
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="existing_network", platform="openstack", order=349)
|
@context.configure(name="existing_network", platform="openstack", order=349)
|
||||||
class ExistingNetwork(context.Context):
|
class ExistingNetwork(context.OpenStackContext):
|
||||||
"""This context supports using existing networks in Rally.
|
"""This context supports using existing networks in Rally.
|
||||||
|
|
||||||
This context should be used on a deployment with existing users.
|
This context should be used on a deployment with existing users.
|
||||||
@ -36,8 +35,7 @@ class ExistingNetwork(context.Context):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user, tenant_id in utils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context.get("users", [])):
|
|
||||||
net_wrapper = network_wrapper.wrap(
|
net_wrapper = network_wrapper.wrap(
|
||||||
osclients.Clients(user["credential"]), self,
|
osclients.Clients(user["credential"]), self,
|
||||||
config=self.config)
|
config=self.config)
|
||||||
|
@ -14,17 +14,17 @@
|
|||||||
|
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", admin=True)
|
@validation.add("required_platform", platform="openstack", admin=True)
|
||||||
@context.configure(name="networking_agents", platform="openstack", order=349)
|
@context.configure(name="networking_agents", platform="openstack", order=349)
|
||||||
class NetworkingAgents(context.Context):
|
class NetworkingAgents(context.OpenStackContext):
|
||||||
"""This context supports querying Neutron agents in Rally."""
|
"""This context supports querying Neutron agents in Rally."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
|
@ -14,12 +14,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
|
from rally_openstack.task import context
|
||||||
from rally_openstack.wrappers import network as network_wrapper
|
from rally_openstack.wrappers import network as network_wrapper
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
@validation.add("required_platform", platform="openstack", admin=True,
|
@validation.add("required_platform", platform="openstack", admin=True,
|
||||||
users=True)
|
users=True)
|
||||||
@context.configure(name="network", platform="openstack", order=350)
|
@context.configure(name="network", platform="openstack", order=350)
|
||||||
class Network(context.Context):
|
class Network(context.OpenStackContext):
|
||||||
"""Create networking resources.
|
"""Create networking resources.
|
||||||
|
|
||||||
This creates networks for all tenants, and optionally creates
|
This creates networks for all tenants, and optionally creates
|
||||||
@ -107,8 +106,7 @@ class Network(context.Context):
|
|||||||
kwargs = {}
|
kwargs = {}
|
||||||
if self.config["dns_nameservers"] is not None:
|
if self.config["dns_nameservers"] is not None:
|
||||||
kwargs["dns_nameservers"] = self.config["dns_nameservers"]
|
kwargs["dns_nameservers"] = self.config["dns_nameservers"]
|
||||||
for user, tenant_id in (utils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context.get("users", []))):
|
|
||||||
self.context["tenants"][tenant_id]["networks"] = []
|
self.context["tenants"][tenant_id]["networks"] = []
|
||||||
for i in range(self.config["networks_per_tenant"]):
|
for i in range(self.config["networks_per_tenant"]):
|
||||||
# NOTE(amaretskiy): router_create_args and subnets_num take
|
# NOTE(amaretskiy): router_create_args and subnets_num take
|
||||||
|
@ -13,19 +13,18 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.neutron import utils as neutron_utils
|
from rally_openstack.scenarios.neutron import utils as neutron_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", admin=True,
|
@validation.add("required_platform", platform="openstack", admin=True,
|
||||||
users=True)
|
users=True)
|
||||||
@context.configure(name="router", platform="openstack", order=351)
|
@context.configure(name="router", platform="openstack", order=351)
|
||||||
class Router(context.Context):
|
class Router(context.OpenStackContext):
|
||||||
"""Create networking resources.
|
"""Create networking resources.
|
||||||
|
|
||||||
This creates router for all tenants.
|
This creates router for all tenants.
|
||||||
@ -96,8 +95,7 @@ class Router(context.Context):
|
|||||||
for parameter in parameters:
|
for parameter in parameters:
|
||||||
if parameter in self.config:
|
if parameter in self.config:
|
||||||
kwargs[parameter] = self.config[parameter]
|
kwargs[parameter] = self.config[parameter]
|
||||||
for user, tenant_id in (utils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context.get("users", []))):
|
|
||||||
self.context["tenants"][tenant_id]["routers"] = []
|
self.context["tenants"][tenant_id]["routers"] = []
|
||||||
scenario = neutron_utils.NeutronScenario(
|
scenario = neutron_utils.NeutronScenario(
|
||||||
context={"user": user, "task": self.context["task"],
|
context={"user": user, "task": self.context["task"],
|
||||||
|
@ -11,13 +11,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
|
||||||
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
|
from rally_openstack.task import context
|
||||||
from rally_openstack.wrappers import network as network_wrapper
|
from rally_openstack.wrappers import network as network_wrapper
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +25,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
@validation.add("required_platform", platform="openstack", admin=True,
|
@validation.add("required_platform", platform="openstack", admin=True,
|
||||||
users=True)
|
users=True)
|
||||||
@context.configure(name="lbaas", platform="openstack", order=360)
|
@context.configure(name="lbaas", platform="openstack", order=360)
|
||||||
class Lbaas(context.Context):
|
class Lbaas(context.OpenStackContext):
|
||||||
"""Creates a lb-pool for every subnet created in network context."""
|
"""Creates a lb-pool for every subnet created in network context."""
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -64,8 +62,7 @@ class Lbaas(context.Context):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Creates a lb-pool for every subnet created in network context.
|
# Creates a lb-pool for every subnet created in network context.
|
||||||
for user, tenant_id in (utils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context.get("users", []))):
|
|
||||||
for network in self.context["tenants"][tenant_id]["networks"]:
|
for network in self.context["tenants"][tenant_id]["networks"]:
|
||||||
for subnet in network.get("subnets", []):
|
for subnet in network.get("subnets", []):
|
||||||
if self.config["lbaas_version"] == 1:
|
if self.config["lbaas_version"] == 1:
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", admin=True)
|
@validation.add("required_platform", platform="openstack", admin=True)
|
||||||
@context.configure(name="flavors", platform="openstack", order=340)
|
@context.configure(name="flavors", platform="openstack", order=340)
|
||||||
class FlavorsGenerator(context.Context):
|
class FlavorsGenerator(context.OpenStackContext):
|
||||||
"""Context creates a list of flavors."""
|
"""Context creates a list of flavors."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
|
@ -14,15 +14,15 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="keypair", platform="openstack", order=310)
|
@context.configure(name="keypair", platform="openstack", order=310)
|
||||||
class Keypair(context.Context):
|
class Keypair(context.OpenStackContext):
|
||||||
"""Create Nova KeyPair for each user."""
|
"""Create Nova KeyPair for each user."""
|
||||||
|
|
||||||
# NOTE(andreykurilin): "type" != "null", since we need to support backward
|
# NOTE(andreykurilin): "type" != "null", since we need to support backward
|
||||||
|
@ -13,12 +13,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack.scenarios.nova import utils as nova_utils
|
from rally_openstack.scenarios.nova import utils as nova_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
from rally_openstack import types
|
from rally_openstack import types
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="servers", platform="openstack", order=430)
|
@context.configure(name="servers", platform="openstack", order=430)
|
||||||
class ServerGenerator(context.Context):
|
class ServerGenerator(context.OpenStackContext):
|
||||||
"""Creates specified amount of Nova Servers per each tenant."""
|
"""Creates specified amount of Nova Servers per each tenant."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -105,8 +104,7 @@ class ServerGenerator(context.Context):
|
|||||||
flavor_id = types.Flavor(self.context).pre_process(
|
flavor_id = types.Flavor(self.context).pre_process(
|
||||||
resource_spec=flavor, config={})
|
resource_spec=flavor, config={})
|
||||||
|
|
||||||
for iter_, (user, tenant_id) in enumerate(rutils.iterate_per_tenants(
|
for iter_, (user, tenant_id) in enumerate(self._iterate_per_tenants()):
|
||||||
self.context["users"])):
|
|
||||||
LOG.debug("Booting servers for user tenant %s" % user["tenant_id"])
|
LOG.debug("Booting servers for user tenant %s" % user["tenant_id"])
|
||||||
tmp_context = {"user": user,
|
tmp_context = {"user": user,
|
||||||
"tenant": self.context["tenants"][tenant_id],
|
"tenant": self.context["tenants"][tenant_id],
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.contexts.quotas import cinder_quotas
|
from rally_openstack.contexts.quotas import cinder_quotas
|
||||||
@ -24,6 +23,7 @@ from rally_openstack.contexts.quotas import manila_quotas
|
|||||||
from rally_openstack.contexts.quotas import neutron_quotas
|
from rally_openstack.contexts.quotas import neutron_quotas
|
||||||
from rally_openstack.contexts.quotas import nova_quotas
|
from rally_openstack.contexts.quotas import nova_quotas
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -31,7 +31,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", admin=True)
|
@validation.add("required_platform", platform="openstack", admin=True)
|
||||||
@context.configure(name="quotas", platform="openstack", order=300)
|
@context.configure(name="quotas", platform="openstack", order=300)
|
||||||
class Quotas(context.Context):
|
class Quotas(context.OpenStackContext):
|
||||||
"""Sets OpenStack Tenants quotas."""
|
"""Sets OpenStack Tenants quotas."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
|
@ -14,15 +14,14 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import cfg
|
from rally.common import cfg
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
from rally.task import utils as bench_utils
|
from rally.task import utils as bench_utils
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.sahara import utils
|
from rally_openstack.scenarios.sahara import utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
@ -30,7 +29,7 @@ CONF = cfg.CONF
|
|||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="sahara_cluster", platform="openstack", order=441)
|
@context.configure(name="sahara_cluster", platform="openstack", order=441)
|
||||||
class SaharaCluster(context.Context):
|
class SaharaCluster(context.OpenStackContext):
|
||||||
"""Context class for setting up the Cluster an EDP job."""
|
"""Context class for setting up the Cluster an EDP job."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -105,8 +104,7 @@ class SaharaCluster(context.Context):
|
|||||||
|
|
||||||
wait_dict = {}
|
wait_dict = {}
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
|
|
||||||
image_id = self.context["tenants"][tenant_id]["sahara"]["image"]
|
image_id = self.context["tenants"][tenant_id]["sahara"]["image"]
|
||||||
|
|
||||||
|
@ -12,21 +12,20 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.scenarios.sahara import utils
|
from rally_openstack.scenarios.sahara import utils
|
||||||
from rally_openstack.services.image import image as image_services
|
from rally_openstack.services.image import image as image_services
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="sahara_image", platform="openstack", order=440)
|
@context.configure(name="sahara_image", platform="openstack", order=440)
|
||||||
class SaharaImage(context.Context):
|
class SaharaImage(context.OpenStackContext):
|
||||||
"""Context class for adding and tagging Sahara images."""
|
"""Context class for adding and tagging Sahara images."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -103,13 +102,11 @@ class SaharaImage(context.Context):
|
|||||||
)
|
)
|
||||||
image_id = image_uuid
|
image_id = image_uuid
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
self.context["tenants"][tenant_id]["sahara"]["image"] = (
|
self.context["tenants"][tenant_id]["sahara"]["image"] = (
|
||||||
image_id)
|
image_id)
|
||||||
else:
|
else:
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
|
|
||||||
image_id = self._create_image(
|
image_id = self._create_image(
|
||||||
hadoop_version=self.config["hadoop_version"],
|
hadoop_version=self.config["hadoop_version"],
|
||||||
|
@ -17,21 +17,20 @@ from urllib.parse import urlparse
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.scenarios.sahara import utils
|
from rally_openstack.scenarios.sahara import utils
|
||||||
from rally_openstack.scenarios.swift import utils as swift_utils
|
from rally_openstack.scenarios.swift import utils as swift_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="sahara_input_data_sources", platform="openstack",
|
@context.configure(name="sahara_input_data_sources", platform="openstack",
|
||||||
order=443)
|
order=443)
|
||||||
class SaharaInputDataSources(context.Context):
|
class SaharaInputDataSources(context.OpenStackContext):
|
||||||
"""Context class for setting up Input Data Sources for an EDP job."""
|
"""Context class for setting up Input Data Sources for an EDP job."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -70,8 +69,7 @@ class SaharaInputDataSources(context.Context):
|
|||||||
self.context["sahara"]["swift_objects"] = []
|
self.context["sahara"]["swift_objects"] = []
|
||||||
self.context["sahara"]["container_name"] = None
|
self.context["sahara"]["container_name"] = None
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
clients = osclients.Clients(user["credential"])
|
clients = osclients.Clients(user["credential"])
|
||||||
if self.config["input_type"] == "swift":
|
if self.config["input_type"] == "swift":
|
||||||
self.setup_inputs_swift(clients, tenant_id,
|
self.setup_inputs_swift(clients, tenant_id,
|
||||||
|
@ -15,20 +15,19 @@
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.scenarios.sahara import utils
|
from rally_openstack.scenarios.sahara import utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="sahara_job_binaries", platform="openstack", order=442)
|
@context.configure(name="sahara_job_binaries", platform="openstack", order=442)
|
||||||
class SaharaJobBinaries(context.Context):
|
class SaharaJobBinaries(context.OpenStackContext):
|
||||||
"""Context class for setting up Job Binaries for an EDP job."""
|
"""Context class for setting up Job Binaries for an EDP job."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -77,8 +76,7 @@ class SaharaJobBinaries(context.Context):
|
|||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
utils.init_sahara_context(self)
|
utils.init_sahara_context(self)
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
|
|
||||||
clients = osclients.Clients(user["credential"])
|
clients = osclients.Clients(user["credential"])
|
||||||
sahara = clients.sahara()
|
sahara = clients.sahara()
|
||||||
|
@ -13,21 +13,20 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.scenarios.sahara import utils
|
from rally_openstack.scenarios.sahara import utils
|
||||||
from rally_openstack.scenarios.swift import utils as swift_utils
|
from rally_openstack.scenarios.swift import utils as swift_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="sahara_output_data_sources", platform="openstack",
|
@context.configure(name="sahara_output_data_sources", platform="openstack",
|
||||||
order=444)
|
order=444)
|
||||||
class SaharaOutputDataSources(context.Context):
|
class SaharaOutputDataSources(context.OpenStackContext):
|
||||||
"""Context class for setting up Output Data Sources for an EDP job."""
|
"""Context class for setting up Output Data Sources for an EDP job."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -47,8 +46,7 @@ class SaharaOutputDataSources(context.Context):
|
|||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
utils.init_sahara_context(self)
|
utils.init_sahara_context(self)
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
|
|
||||||
clients = osclients.Clients(user["credential"])
|
clients = osclients.Clients(user["credential"])
|
||||||
sahara = clients.sahara()
|
sahara = clients.sahara()
|
||||||
|
@ -10,17 +10,16 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.senlin import utils as senlin_utils
|
from rally_openstack.scenarios.senlin import utils as senlin_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="profiles", platform="openstack", order=190)
|
@context.configure(name="profiles", platform="openstack", order=190)
|
||||||
class ProfilesGenerator(context.Context):
|
class ProfilesGenerator(context.OpenStackContext):
|
||||||
"""Context creates a temporary profile for Senlin test."""
|
"""Context creates a temporary profile for Senlin test."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -44,8 +43,7 @@ class ProfilesGenerator(context.Context):
|
|||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Create test profiles."""
|
"""Create test profiles."""
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
|
|
||||||
senlin_scenario = senlin_utils.SenlinScenario({
|
senlin_scenario = senlin_utils.SenlinScenario({
|
||||||
"user": user,
|
"user": user,
|
||||||
@ -57,8 +55,7 @@ class ProfilesGenerator(context.Context):
|
|||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Delete created test profiles."""
|
"""Delete created test profiles."""
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
self.context["users"]):
|
|
||||||
|
|
||||||
senlin_scenario = senlin_utils.SenlinScenario({
|
senlin_scenario = senlin_utils.SenlinScenario({
|
||||||
"user": user,
|
"user": user,
|
||||||
|
@ -16,17 +16,18 @@
|
|||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.contexts.swift import utils as swift_utils
|
from rally_openstack.contexts.swift import utils as swift_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
@context.configure(name="swift_objects", platform="openstack", order=360)
|
@context.configure(name="swift_objects", platform="openstack", order=360)
|
||||||
class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
class SwiftObjectGenerator(swift_utils.SwiftObjectMixin,
|
||||||
|
context.OpenStackContext):
|
||||||
"""Create containers and objects in each tenant."""
|
"""Create containers and objects in each tenant."""
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -67,8 +68,7 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
|||||||
containers_num = len(self.context["tenants"]) * containers_per_tenant
|
containers_num = len(self.context["tenants"]) * containers_per_tenant
|
||||||
LOG.debug("Creating %d containers using %d threads."
|
LOG.debug("Creating %d containers using %d threads."
|
||||||
% (containers_num, threads))
|
% (containers_num, threads))
|
||||||
containers_count = len(self._create_containers(self.context,
|
containers_count = len(self._create_containers(containers_per_tenant,
|
||||||
containers_per_tenant,
|
|
||||||
threads))
|
threads))
|
||||||
if containers_count != containers_num:
|
if containers_count != containers_num:
|
||||||
raise exceptions.ContextSetupFailure(
|
raise exceptions.ContextSetupFailure(
|
||||||
@ -81,8 +81,7 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
|||||||
objects_num = containers_num * objects_per_container
|
objects_num = containers_num * objects_per_container
|
||||||
LOG.debug("Creating %d objects using %d threads."
|
LOG.debug("Creating %d objects using %d threads."
|
||||||
% (objects_num, threads))
|
% (objects_num, threads))
|
||||||
objects_count = len(self._create_objects(self.context,
|
objects_count = len(self._create_objects(objects_per_container,
|
||||||
objects_per_container,
|
|
||||||
self.config["object_size"],
|
self.config["object_size"],
|
||||||
threads))
|
threads))
|
||||||
if objects_count != objects_num:
|
if objects_count != objects_num:
|
||||||
@ -96,5 +95,5 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
|||||||
"""Delete containers and objects, using the broker pattern."""
|
"""Delete containers and objects, using the broker pattern."""
|
||||||
threads = self.config["resource_management_workers"]
|
threads = self.config["resource_management_workers"]
|
||||||
|
|
||||||
self._delete_objects(self.context, threads)
|
self._delete_objects(threads)
|
||||||
self._delete_containers(self.context, threads)
|
self._delete_containers(threads)
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from rally.common import broker
|
from rally.common import broker
|
||||||
from rally.common import utils as rutils
|
|
||||||
|
|
||||||
from rally_openstack.scenarios.swift import utils as swift_utils
|
from rally_openstack.scenarios.swift import utils as swift_utils
|
||||||
|
|
||||||
@ -24,10 +23,9 @@ from rally_openstack.scenarios.swift import utils as swift_utils
|
|||||||
class SwiftObjectMixin(object):
|
class SwiftObjectMixin(object):
|
||||||
"""Mix-in method for Swift Object Context."""
|
"""Mix-in method for Swift Object Context."""
|
||||||
|
|
||||||
def _create_containers(self, context, containers_per_tenant, threads):
|
def _create_containers(self, containers_per_tenant, threads):
|
||||||
"""Create containers and store results in Rally context.
|
"""Create containers and store results in Rally context.
|
||||||
|
|
||||||
:param context: dict, Rally context environment
|
|
||||||
:param containers_per_tenant: int, number of containers to create
|
:param containers_per_tenant: int, number of containers to create
|
||||||
per tenant
|
per tenant
|
||||||
:param threads: int, number of threads to use for broker pattern
|
:param threads: int, number of threads to use for broker pattern
|
||||||
@ -37,18 +35,18 @@ class SwiftObjectMixin(object):
|
|||||||
containers = []
|
containers = []
|
||||||
|
|
||||||
def publish(queue):
|
def publish(queue):
|
||||||
for user, tenant_id in (rutils.iterate_per_tenants(
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
context.get("users", []))):
|
self.context["tenants"][tenant_id]["containers"] = []
|
||||||
context["tenants"][tenant_id]["containers"] = []
|
|
||||||
for i in range(containers_per_tenant):
|
for i in range(containers_per_tenant):
|
||||||
args = (user, context["tenants"][tenant_id]["containers"])
|
args = (user,
|
||||||
|
self.context["tenants"][tenant_id]["containers"])
|
||||||
queue.append(args)
|
queue.append(args)
|
||||||
|
|
||||||
def consume(cache, args):
|
def consume(cache, args):
|
||||||
user, tenant_containers = args
|
user, tenant_containers = args
|
||||||
if user["id"] not in cache:
|
if user["id"] not in cache:
|
||||||
cache[user["id"]] = swift_utils.SwiftScenario(
|
cache[user["id"]] = swift_utils.SwiftScenario(
|
||||||
{"user": user, "task": context.get("task", {})})
|
{"user": user, "task": self.context.get("task", {})})
|
||||||
container_name = cache[user["id"]]._create_container()
|
container_name = cache[user["id"]]._create_container()
|
||||||
tenant_containers.append({"user": user,
|
tenant_containers.append({"user": user,
|
||||||
"container": container_name,
|
"container": container_name,
|
||||||
@ -59,11 +57,9 @@ class SwiftObjectMixin(object):
|
|||||||
|
|
||||||
return containers
|
return containers
|
||||||
|
|
||||||
def _create_objects(self, context, objects_per_container, object_size,
|
def _create_objects(self, objects_per_container, object_size, threads):
|
||||||
threads):
|
|
||||||
"""Create objects and store results in Rally context.
|
"""Create objects and store results in Rally context.
|
||||||
|
|
||||||
:param context: dict, Rally context environment
|
|
||||||
:param objects_per_container: int, number of objects to create
|
:param objects_per_container: int, number of objects to create
|
||||||
per container
|
per container
|
||||||
:param object_size: int, size of created swift objects in byte
|
:param object_size: int, size of created swift objects in byte
|
||||||
@ -78,9 +74,9 @@ class SwiftObjectMixin(object):
|
|||||||
dummy_file.truncate(object_size)
|
dummy_file.truncate(object_size)
|
||||||
|
|
||||||
def publish(queue):
|
def publish(queue):
|
||||||
for tenant_id in context["tenants"]:
|
for tenant_id in self.context["tenants"]:
|
||||||
containers = context["tenants"][tenant_id]["containers"]
|
items = self.context["tenants"][tenant_id]["containers"]
|
||||||
for container in containers:
|
for container in items:
|
||||||
for i in range(objects_per_container):
|
for i in range(objects_per_container):
|
||||||
queue.append(container)
|
queue.append(container)
|
||||||
|
|
||||||
@ -88,7 +84,7 @@ class SwiftObjectMixin(object):
|
|||||||
user = container["user"]
|
user = container["user"]
|
||||||
if user["id"] not in cache:
|
if user["id"] not in cache:
|
||||||
cache[user["id"]] = swift_utils.SwiftScenario(
|
cache[user["id"]] = swift_utils.SwiftScenario(
|
||||||
{"user": user, "task": context.get("task", {})})
|
{"user": user, "task": self.context.get("task", {})})
|
||||||
dummy_file.seek(0)
|
dummy_file.seek(0)
|
||||||
object_name = cache[user["id"]]._upload_object(
|
object_name = cache[user["id"]]._upload_object(
|
||||||
container["container"],
|
container["container"],
|
||||||
@ -101,15 +97,14 @@ class SwiftObjectMixin(object):
|
|||||||
|
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
def _delete_containers(self, context, threads):
|
def _delete_containers(self, threads):
|
||||||
"""Delete containers created by Swift context and update Rally context.
|
"""Delete containers created by Swift context and update Rally context.
|
||||||
|
|
||||||
:param context: dict, Rally context environment
|
|
||||||
:param threads: int, number of threads to use for broker pattern
|
:param threads: int, number of threads to use for broker pattern
|
||||||
"""
|
"""
|
||||||
def publish(queue):
|
def publish(queue):
|
||||||
for tenant_id in context["tenants"]:
|
for tenant_id in self.context["tenants"]:
|
||||||
containers = context["tenants"][tenant_id]["containers"]
|
containers = self.context["tenants"][tenant_id]["containers"]
|
||||||
for container in containers[:]:
|
for container in containers[:]:
|
||||||
args = container, containers
|
args = container, containers
|
||||||
queue.append(args)
|
queue.append(args)
|
||||||
@ -119,21 +114,20 @@ class SwiftObjectMixin(object):
|
|||||||
user = container["user"]
|
user = container["user"]
|
||||||
if user["id"] not in cache:
|
if user["id"] not in cache:
|
||||||
cache[user["id"]] = swift_utils.SwiftScenario(
|
cache[user["id"]] = swift_utils.SwiftScenario(
|
||||||
{"user": user, "task": context.get("task", {})})
|
{"user": user, "task": self.context.get("task", {})})
|
||||||
cache[user["id"]]._delete_container(container["container"])
|
cache[user["id"]]._delete_container(container["container"])
|
||||||
tenant_containers.remove(container)
|
tenant_containers.remove(container)
|
||||||
|
|
||||||
broker.run(publish, consume, threads)
|
broker.run(publish, consume, threads)
|
||||||
|
|
||||||
def _delete_objects(self, context, threads):
|
def _delete_objects(self, threads):
|
||||||
"""Delete objects created by Swift context and update Rally context.
|
"""Delete objects created by Swift context and update Rally context.
|
||||||
|
|
||||||
:param context: dict, Rally context environment
|
|
||||||
:param threads: int, number of threads to use for broker pattern
|
:param threads: int, number of threads to use for broker pattern
|
||||||
"""
|
"""
|
||||||
def publish(queue):
|
def publish(queue):
|
||||||
for tenant_id in context["tenants"]:
|
for tenant_id in self.context["tenants"]:
|
||||||
containers = context["tenants"][tenant_id]["containers"]
|
containers = self.context["tenants"][tenant_id]["containers"]
|
||||||
for container in containers:
|
for container in containers:
|
||||||
for object_name in container["objects"][:]:
|
for object_name in container["objects"][:]:
|
||||||
args = object_name, container
|
args = object_name, container
|
||||||
@ -144,7 +138,7 @@ class SwiftObjectMixin(object):
|
|||||||
user = container["user"]
|
user = container["user"]
|
||||||
if user["id"] not in cache:
|
if user["id"] not in cache:
|
||||||
cache[user["id"]] = swift_utils.SwiftScenario(
|
cache[user["id"]] = swift_utils.SwiftScenario(
|
||||||
{"user": user, "task": context.get("task", {})})
|
{"user": user, "task": self.context.get("task", {})})
|
||||||
cache[user["id"]]._delete_object(container["container"],
|
cache[user["id"]]._delete_object(container["container"],
|
||||||
object_name)
|
object_name)
|
||||||
container["objects"].remove(object_name)
|
container["objects"].remove(object_name)
|
||||||
|
@ -18,19 +18,20 @@ import abc
|
|||||||
from rally.common import broker
|
from rally.common import broker
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack import osclients
|
from rally_openstack import osclients
|
||||||
from rally_openstack.scenarios.vm import vmtasks
|
from rally_openstack.scenarios.vm import vmtasks
|
||||||
from rally_openstack.services.image import image
|
from rally_openstack.services.image import image
|
||||||
|
from rally_openstack.task import context
|
||||||
from rally_openstack import types
|
from rally_openstack import types
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class BaseCustomImageGenerator(context.Context, metaclass=abc.ABCMeta):
|
class BaseCustomImageGenerator(context.OpenStackContext,
|
||||||
|
metaclass=abc.ABCMeta):
|
||||||
"""Base plugin for the contexts providing customized image with.
|
"""Base plugin for the contexts providing customized image with.
|
||||||
|
|
||||||
Every context plugin for the specific customization must implement
|
Every context plugin for the specific customization must implement
|
||||||
@ -131,8 +132,7 @@ class BaseCustomImageGenerator(context.Context, metaclass=abc.ABCMeta):
|
|||||||
tenant["custom_image"] = custom_image
|
tenant["custom_image"] = custom_image
|
||||||
else:
|
else:
|
||||||
def publish(queue):
|
def publish(queue):
|
||||||
users = self.context.get("users", [])
|
for user, tenant_id in self._iterate_per_tenants():
|
||||||
for user, tenant_id in utils.iterate_per_tenants(users):
|
|
||||||
queue.append((user, tenant_id))
|
queue.append((user, tenant_id))
|
||||||
|
|
||||||
def consume(cache, args):
|
def consume(cache, args):
|
||||||
|
@ -17,10 +17,10 @@ import copy
|
|||||||
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
import rally.task.context as context
|
|
||||||
|
|
||||||
from rally_openstack.contexts.vm import custom_image
|
from rally_openstack.contexts.vm import custom_image
|
||||||
from rally_openstack.scenarios.vm import utils as vm_utils
|
from rally_openstack.scenarios.vm import utils as vm_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", users=True)
|
@validation.add("required_platform", platform="openstack", users=True)
|
||||||
|
@ -15,17 +15,17 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally.task import context
|
|
||||||
|
|
||||||
from rally_openstack.cleanup import manager as resource_manager
|
from rally_openstack.cleanup import manager as resource_manager
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
from rally_openstack.scenarios.watcher import utils as watcher_utils
|
from rally_openstack.scenarios.watcher import utils as watcher_utils
|
||||||
|
from rally_openstack.task import context
|
||||||
from rally_openstack import types
|
from rally_openstack import types
|
||||||
|
|
||||||
|
|
||||||
@validation.add("required_platform", platform="openstack", admin=True)
|
@validation.add("required_platform", platform="openstack", admin=True)
|
||||||
@context.configure(name="audit_templates", platform="openstack", order=550)
|
@context.configure(name="audit_templates", platform="openstack", order=550)
|
||||||
class AuditTemplateGenerator(context.Context):
|
class AuditTemplateGenerator(context.OpenStackContext):
|
||||||
"""Creates Watcher audit templates for tenants."""
|
"""Creates Watcher audit templates for tenants."""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
|
0
rally_openstack/task/__init__.py
Normal file
0
rally_openstack/task/__init__.py
Normal file
37
rally_openstack/task/context.py
Normal file
37
rally_openstack/task/context.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import functools
|
||||||
|
|
||||||
|
from rally.task import context
|
||||||
|
|
||||||
|
|
||||||
|
configure = functools.partial(context.configure, platform="openstack")
|
||||||
|
|
||||||
|
|
||||||
|
class OpenStackContext(context.Context):
|
||||||
|
"""A base class for all OpenStack context classes."""
|
||||||
|
|
||||||
|
def _iterate_per_tenants(self, users=None):
|
||||||
|
"""Iterate of a single arbitrary user from each tenant
|
||||||
|
|
||||||
|
:type users: list of users
|
||||||
|
:return: iterator of a single user from each tenant
|
||||||
|
"""
|
||||||
|
if users is None:
|
||||||
|
users = self.context.get("users", [])
|
||||||
|
|
||||||
|
processed_tenants = set()
|
||||||
|
for user in users:
|
||||||
|
if user["tenant_id"] not in processed_tenants:
|
||||||
|
processed_tenants.add(user["tenant_id"])
|
||||||
|
yield user, user["tenant_id"]
|
@ -292,10 +292,8 @@ class UserGeneratorForNewUsersTestCase(test.ScenarioTestCase):
|
|||||||
net_wrapper.supports_extension.assert_called_once_with(
|
net_wrapper.supports_extension.assert_called_once_with(
|
||||||
"security-group")
|
"security-group")
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.iterate_per_tenants")
|
|
||||||
@mock.patch("%s.network" % CTX)
|
@mock.patch("%s.network" % CTX)
|
||||||
def test__remove_default_security_group(
|
def test__remove_default_security_group(self, mock_network):
|
||||||
self, mock_network, mock_iterate_per_tenants):
|
|
||||||
net_wrapper = mock.Mock(SERVICE_IMPL=consts.Service.NEUTRON)
|
net_wrapper = mock.Mock(SERVICE_IMPL=consts.Service.NEUTRON)
|
||||||
net_wrapper.supports_extension.return_value = (True, None)
|
net_wrapper.supports_extension.return_value = (True, None)
|
||||||
mock_network.wrap.return_value = net_wrapper
|
mock_network.wrap.return_value = net_wrapper
|
||||||
@ -317,20 +315,22 @@ class UserGeneratorForNewUsersTestCase(test.ScenarioTestCase):
|
|||||||
user_clients = [user1, user2]
|
user_clients = [user1, user2]
|
||||||
self.osclients.Clients.side_effect = [admin_clients] + user_clients
|
self.osclients.Clients.side_effect = [admin_clients] + user_clients
|
||||||
|
|
||||||
mock_iterate_per_tenants.return_value = [
|
user_generator._iterate_per_tenants = mock.MagicMock(
|
||||||
|
return_value=[
|
||||||
(mock.MagicMock(), "t1"),
|
(mock.MagicMock(), "t1"),
|
||||||
(mock.MagicMock(), "t2")]
|
(mock.MagicMock(), "t2")
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
user_generator._remove_default_security_group()
|
user_generator._remove_default_security_group()
|
||||||
|
|
||||||
mock_network.wrap.assert_called_once_with(admin_clients,
|
mock_network.wrap.assert_called_once_with(admin_clients,
|
||||||
user_generator)
|
user_generator)
|
||||||
|
|
||||||
mock_iterate_per_tenants.assert_called_once_with(
|
user_generator._iterate_per_tenants.assert_called_once_with()
|
||||||
user_generator.context["users"])
|
|
||||||
expected = [mock.call(user_generator.credential)] + [
|
expected = [mock.call(user_generator.credential)] + [
|
||||||
mock.call(u["credential"])
|
mock.call(u["credential"])
|
||||||
for u, t in mock_iterate_per_tenants.return_value]
|
for u, t in user_generator._iterate_per_tenants.return_value]
|
||||||
self.osclients.Clients.assert_has_calls(expected, any_order=True)
|
self.osclients.Clients.assert_has_calls(expected, any_order=True)
|
||||||
|
|
||||||
user_net = user1.neutron.return_value
|
user_net = user1.neutron.return_value
|
||||||
|
@ -66,20 +66,20 @@ class NetworkTestCase(test.TestCase):
|
|||||||
{"dns_nameservers": ["1.2.3.4", "5.6.7.8"]})
|
{"dns_nameservers": ["1.2.3.4", "5.6.7.8"]})
|
||||||
@ddt.unpack
|
@ddt.unpack
|
||||||
@mock.patch(NET + "wrap")
|
@mock.patch(NET + "wrap")
|
||||||
@mock.patch("rally_openstack.contexts.network.networks.utils")
|
|
||||||
@mock.patch("rally_openstack.osclients.Clients")
|
@mock.patch("rally_openstack.osclients.Clients")
|
||||||
def test_setup(self, mock_clients, mock_utils, mock_wrap, **dns_kwargs):
|
def test_setup(self, mock_clients, mock_wrap, **dns_kwargs):
|
||||||
mock_utils.iterate_per_tenants.return_value = [
|
|
||||||
("foo_user", "foo_tenant"),
|
|
||||||
("bar_user", "bar_tenant")]
|
|
||||||
mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
|
mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
|
||||||
mock_utils.generate_random_name = mock.Mock()
|
|
||||||
mock_wrap.return_value = mock.Mock(create_network=mock_create)
|
mock_wrap.return_value = mock.Mock(create_network=mock_create)
|
||||||
nets_per_tenant = 2
|
nets_per_tenant = 2
|
||||||
net_context = network_context.Network(
|
net_context = network_context.Network(
|
||||||
self.get_context(networks_per_tenant=nets_per_tenant,
|
self.get_context(networks_per_tenant=nets_per_tenant,
|
||||||
network_create_args={"fakearg": "fake"},
|
network_create_args={"fakearg": "fake"},
|
||||||
**dns_kwargs))
|
**dns_kwargs))
|
||||||
|
net_context._iterate_per_tenants = mock.MagicMock(
|
||||||
|
return_value=[
|
||||||
|
("foo_user", "foo_tenant"),
|
||||||
|
("bar_user", "bar_tenant")]
|
||||||
|
)
|
||||||
|
|
||||||
net_context.setup()
|
net_context.setup()
|
||||||
|
|
||||||
@ -91,11 +91,10 @@ class NetworkTestCase(test.TestCase):
|
|||||||
subnets_num=1, network_create_args={"fakearg": "fake"},
|
subnets_num=1, network_create_args={"fakearg": "fake"},
|
||||||
router_create_args={"external": True},
|
router_create_args={"external": True},
|
||||||
**dns_kwargs)
|
**dns_kwargs)
|
||||||
for user, tenant in mock_utils.iterate_per_tenants.return_value]
|
for user, tenant in net_context._iterate_per_tenants.return_value]
|
||||||
mock_create.assert_has_calls(create_calls)
|
mock_create.assert_has_calls(create_calls)
|
||||||
|
|
||||||
mock_utils.iterate_per_tenants.assert_called_once_with(
|
net_context._iterate_per_tenants.assert_called_once_with()
|
||||||
net_context.context["users"])
|
|
||||||
expected_networks = ["bar_tenant-net",
|
expected_networks = ["bar_tenant-net",
|
||||||
"foo_tenant-net"] * nets_per_tenant
|
"foo_tenant-net"] * nets_per_tenant
|
||||||
actual_networks = []
|
actual_networks = []
|
||||||
|
@ -57,12 +57,8 @@ class LbaasTestCase(test.TestCase):
|
|||||||
"LEAST_CONNECTIONS")
|
"LEAST_CONNECTIONS")
|
||||||
|
|
||||||
@mock.patch(NET + "wrap")
|
@mock.patch(NET + "wrap")
|
||||||
@mock.patch("rally_openstack.contexts.neutron.lbaas.utils")
|
|
||||||
@mock.patch("rally_openstack.osclients.Clients")
|
@mock.patch("rally_openstack.osclients.Clients")
|
||||||
def test_setup_with_lbaas(self, mock_clients, mock_utils, mock_wrap):
|
def test_setup_with_lbaas(self, mock_clients, mock_wrap):
|
||||||
mock_utils.iterate_per_tenants.return_value = [
|
|
||||||
("foo_user", "foo_tenant"),
|
|
||||||
("bar_user", "bar_tenant")]
|
|
||||||
foo_net = {"id": "foo_net",
|
foo_net = {"id": "foo_net",
|
||||||
"tenant_id": "foo_tenant",
|
"tenant_id": "foo_tenant",
|
||||||
"subnets": ["foo_subnet"],
|
"subnets": ["foo_subnet"],
|
||||||
@ -83,10 +79,17 @@ class LbaasTestCase(test.TestCase):
|
|||||||
net_wrapper = mock_wrap(mock_clients.return_value)
|
net_wrapper = mock_wrap(mock_clients.return_value)
|
||||||
net_wrapper.supports_extension.return_value = (True, None)
|
net_wrapper.supports_extension.return_value = (True, None)
|
||||||
fake_args = {"lbaas_version": 1}
|
fake_args = {"lbaas_version": 1}
|
||||||
|
|
||||||
lb_context = lbaas_context.Lbaas(self.get_context(**fake_args))
|
lb_context = lbaas_context.Lbaas(self.get_context(**fake_args))
|
||||||
|
lb_context._iterate_per_tenants = mock.MagicMock(
|
||||||
|
return_value=[
|
||||||
|
("foo_user", "foo_tenant"),
|
||||||
|
("bar_user", "bar_tenant")]
|
||||||
|
)
|
||||||
|
|
||||||
lb_context.setup()
|
lb_context.setup()
|
||||||
mock_utils.iterate_per_tenants.assert_called_once_with(
|
|
||||||
lb_context.context["users"])
|
lb_context._iterate_per_tenants.assert_called_once_with()
|
||||||
net_wrapper.supports_extension.assert_called_once_with("lbaas")
|
net_wrapper.supports_extension.assert_called_once_with("lbaas")
|
||||||
for tenant_id, tenant_ctx in (
|
for tenant_id, tenant_ctx in (
|
||||||
sorted(lb_context.context["tenants"].items())):
|
sorted(lb_context.context["tenants"].items())):
|
||||||
@ -95,33 +98,35 @@ class LbaasTestCase(test.TestCase):
|
|||||||
self.assertEqual(expected_net, actual_net)
|
self.assertEqual(expected_net, actual_net)
|
||||||
|
|
||||||
@mock.patch(NET + "wrap")
|
@mock.patch(NET + "wrap")
|
||||||
@mock.patch("rally_openstack.contexts.neutron.lbaas.utils")
|
|
||||||
@mock.patch("rally_openstack.osclients.Clients")
|
@mock.patch("rally_openstack.osclients.Clients")
|
||||||
def test_setup_with_no_lbaas(self, mock_clients, mock_utils, mock_wrap):
|
def test_setup_with_no_lbaas(self, mock_clients, mock_wrap):
|
||||||
mock_utils.iterate_per_tenants.return_value = [
|
|
||||||
("bar_user", "bar_tenant")]
|
|
||||||
mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
|
mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
|
||||||
mock_wrap.return_value = mock.Mock(create_v1_pool=mock_create)
|
mock_wrap.return_value = mock.Mock(create_v1_pool=mock_create)
|
||||||
fake_args = {"lbaas_version": 1}
|
fake_args = {"lbaas_version": 1}
|
||||||
lb_context = lbaas_context.Lbaas(self.get_context(**fake_args))
|
lb_context = lbaas_context.Lbaas(self.get_context(**fake_args))
|
||||||
net_wrapper = mock_wrap(mock_clients.return_value)
|
net_wrapper = mock_wrap(mock_clients.return_value)
|
||||||
net_wrapper.supports_extension.return_value = (False, None)
|
net_wrapper.supports_extension.return_value = (False, None)
|
||||||
|
|
||||||
|
lb_context._iterate_per_tenants = mock.MagicMock(
|
||||||
|
return_value=[("bar_user", "bar_tenant")]
|
||||||
|
)
|
||||||
lb_context.setup()
|
lb_context.setup()
|
||||||
mock_utils.iterate_per_tenants.assert_not_called()
|
|
||||||
|
lb_context._iterate_per_tenants.assert_not_called()
|
||||||
net_wrapper.supports_extension.assert_called_once_with("lbaas")
|
net_wrapper.supports_extension.assert_called_once_with("lbaas")
|
||||||
assert not net_wrapper.create_v1_pool.called
|
assert not net_wrapper.create_v1_pool.called
|
||||||
|
|
||||||
@mock.patch(NET + "wrap")
|
@mock.patch(NET + "wrap")
|
||||||
@mock.patch("rally_openstack.contexts.neutron.lbaas.utils")
|
|
||||||
@mock.patch("rally_openstack.osclients.Clients")
|
@mock.patch("rally_openstack.osclients.Clients")
|
||||||
def test_setup_with_lbaas_version_not_one(self, mock_clients,
|
def test_setup_with_lbaas_version_not_one(self, mock_clients, mock_wrap):
|
||||||
mock_utils, mock_wrap):
|
|
||||||
mock_utils.iterate_per_tenants.return_value = [
|
|
||||||
("bar_user", "bar_tenant")]
|
|
||||||
mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
|
mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
|
||||||
mock_wrap.return_value = mock.Mock(create_v1_pool=mock_create)
|
mock_wrap.return_value = mock.Mock(create_v1_pool=mock_create)
|
||||||
fake_args = {"lbaas_version": 2}
|
fake_args = {"lbaas_version": 2}
|
||||||
|
|
||||||
lb_context = lbaas_context.Lbaas(self.get_context(**fake_args))
|
lb_context = lbaas_context.Lbaas(self.get_context(**fake_args))
|
||||||
|
lb_context._iterate_per_tenants = mock.MagicMock(
|
||||||
|
return_value=[("bar_user", "bar_tenant")]
|
||||||
|
)
|
||||||
net_wrapper = mock_wrap(mock_clients.return_value)
|
net_wrapper = mock_wrap(mock_clients.return_value)
|
||||||
net_wrapper.supports_extension.return_value = (True, None)
|
net_wrapper.supports_extension.return_value = (True, None)
|
||||||
self.assertRaises(NotImplementedError, lb_context.setup)
|
self.assertRaises(NotImplementedError, lb_context.setup)
|
||||||
|
@ -16,9 +16,21 @@
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from rally_openstack.contexts.swift import utils
|
from rally_openstack.contexts.swift import utils
|
||||||
|
from rally_openstack.task import context
|
||||||
from tests.unit import test
|
from tests.unit import test
|
||||||
|
|
||||||
|
|
||||||
|
class SwiftContext(utils.SwiftObjectMixin, context.OpenStackContext):
|
||||||
|
def __init__(self, context):
|
||||||
|
self.context = context
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SwiftObjectMixinTestCase(test.TestCase):
|
class SwiftObjectMixinTestCase(test.TestCase):
|
||||||
|
|
||||||
@mock.patch("rally_openstack.osclients.Clients")
|
@mock.patch("rally_openstack.osclients.Clients")
|
||||||
@ -38,9 +50,8 @@ class SwiftObjectMixinTestCase(test.TestCase):
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
mixin = utils.SwiftObjectMixin()
|
mixin = SwiftContext(context)
|
||||||
containers = mixin._create_containers(context, containers_per_tenant,
|
containers = mixin._create_containers(containers_per_tenant, 15)
|
||||||
15)
|
|
||||||
|
|
||||||
self.assertEqual(tenants * containers_per_tenant, len(containers))
|
self.assertEqual(tenants * containers_per_tenant, len(containers))
|
||||||
for index, container in enumerate(sorted(containers)):
|
for index, container in enumerate(sorted(containers)):
|
||||||
@ -87,9 +98,8 @@ class SwiftObjectMixinTestCase(test.TestCase):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mixin = utils.SwiftObjectMixin()
|
mixin = SwiftContext(context)
|
||||||
objects_list = mixin._create_objects(context, objects_per_container,
|
objects_list = mixin._create_objects(objects_per_container, 1024, 25)
|
||||||
1024, 25)
|
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
tenants * containers_per_tenant * objects_per_container,
|
tenants * containers_per_tenant * objects_per_container,
|
||||||
@ -133,8 +143,7 @@ class SwiftObjectMixinTestCase(test.TestCase):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mixin = utils.SwiftObjectMixin()
|
SwiftContext(context)._delete_containers(1)
|
||||||
mixin._delete_containers(context, 1)
|
|
||||||
|
|
||||||
mock_swift = mock_clients.return_value.swift.return_value
|
mock_swift = mock_clients.return_value.swift.return_value
|
||||||
expected_containers = ["c1", "c2"]
|
expected_containers = ["c1", "c2"]
|
||||||
@ -173,8 +182,7 @@ class SwiftObjectMixinTestCase(test.TestCase):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mixin = utils.SwiftObjectMixin()
|
SwiftContext(context)._delete_objects(1)
|
||||||
mixin._delete_objects(context, 1)
|
|
||||||
|
|
||||||
mock_swift = mock_clients.return_value.swift.return_value
|
mock_swift = mock_clients.return_value.swift.return_value
|
||||||
expected_objects = [("c1", "o1"), ("c1", "o2"), ("c1", "o3"),
|
expected_objects = [("c1", "o1"), ("c1", "o2"), ("c1", "o3"),
|
||||||
|
0
tests/unit/task/__init__.py
Normal file
0
tests/unit/task/__init__.py
Normal file
47
tests/unit/task/test_context.py
Normal file
47
tests/unit/task/test_context.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Copyright 2013: Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
from rally_openstack.task import context
|
||||||
|
from tests.unit import test
|
||||||
|
|
||||||
|
|
||||||
|
class TenantIteratorTestCase(test.TestCase):
|
||||||
|
|
||||||
|
def test__iterate_per_tenant(self):
|
||||||
|
|
||||||
|
class DummyContext(context.OpenStackContext):
|
||||||
|
def __init__(self, ctx):
|
||||||
|
self.context = ctx
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
users = []
|
||||||
|
tenants_count = 2
|
||||||
|
users_per_tenant = 5
|
||||||
|
for tenant_id in range(tenants_count):
|
||||||
|
for user_id in range(users_per_tenant):
|
||||||
|
users.append({"id": str(user_id),
|
||||||
|
"tenant_id": str(tenant_id)})
|
||||||
|
|
||||||
|
expected_result = [
|
||||||
|
({"id": "0", "tenant_id": str(i)}, str(i)) for i in range(
|
||||||
|
tenants_count)]
|
||||||
|
real_result = [
|
||||||
|
i for i in DummyContext({"users": users})._iterate_per_tenants()]
|
||||||
|
|
||||||
|
self.assertEqual(expected_result, real_result)
|
Loading…
x
Reference in New Issue
Block a user