Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@mock.patch("rally.api.CONF", spec=cfg.CONF)
def test_init_default_config_file(self, mock_conf, mock_version_string,
mock_database_revision, mock_isfile):
mock_isfile.side_effect = lambda f: f == "/etc/rally/rally.conf"
api.API(skip_db_check=True)
mock_conf.assert_called_once_with(
[], default_config_files=["/etc/rally/rally.conf"],
project="rally", version="0.0.0")
import abc
import os
from rally.common import cfg
from rally.common import logging
from rally.common.plugin import plugin
from rally import exceptions
from six.moves.urllib import parse
from rally_openstack import consts
from rally_openstack import credential as oscred
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
class AuthenticationFailed(exceptions.AuthenticationFailed):
error_code = 220
msg_fmt = ("Failed to authenticate to %(url)s for user '%(username)s'"
" in project '%(project)s': %(message)s")
msg_fmt_2 = "%(message)s"
def __init__(self, error, url, username, project):
kwargs = {
"error": error,
"url": url,
"username": username,
"project": project
}
# under the License.
import os
import time
import requests
from rally.common import cfg
from rally.common import utils as rutils
from rally.plugins.openstack import service
from rally.plugins.openstack.services.image import glance_common
from rally.plugins.openstack.services.image import image
from rally.task import atomic
from rally.task import utils
CONF = cfg.CONF
@service.service("glance", service_type="image", version="2")
class GlanceV2Service(service.Service, glance_common.GlanceMixin):
@atomic.action_timer("glance_v2.upload_data")
def upload_data(self, image_id, image_location):
"""Upload the data for an image.
:param image_id: Image ID to upload data to.
:param image_location: Location of the data to upload to.
"""
image_location = os.path.expanduser(image_location)
image_data = None
response = None
try:
# 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.common import cfg
OPTS = {"openstack": [
cfg.FloatOpt(
"ec2_server_boot_prepoll_delay",
default=1.0,
deprecated_group="benchmark",
help="Time to sleep after boot before polling for status"
),
cfg.FloatOpt(
"ec2_server_boot_timeout",
default=300.0,
deprecated_group="benchmark",
help="Server boot timeout"
),
cfg.FloatOpt(
"ec2_server_boot_poll_interval",
default=1.0,
deprecated_group="benchmark",
help="Server boot poll interval"
import copy
import random
from rally.common import cfg
from rally.common import logging
from rally.common.plugin import plugin
from rally.common import utils
from rally.common import validation
from rally import exceptions
from rally.task import atomic
from rally.task import functional
from rally.task.processing import charts
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CONF_OPTS = [
cfg.StrOpt(
"scenario_resource_name_format",
help="Template is used to generate random names of resources. X is "
"replaced with random latter, amount of X can be adjusted")
]
CONF.register_opts(CONF_OPTS)
@logging.log_deprecated_args("Use 'platform' arg instead", "0.10.0",
["namespace"], log_function=LOG.warning)
def configure(name, platform="default", namespace=None, context=None):
"""Configure scenario by setting proper meta data.
This can also transform plain function into scenario plugin, however
this approach is deprecated - now scenarios must be represented by classes
import os
import time
from rally.common import cfg
from rally.common import utils as rutils
from rally.task import atomic
from rally.task import utils
import requests
from rally_openstack import service
from rally_openstack.services.image import glance_common
from rally_openstack.services.image import image
CONF = cfg.CONF
@service.service("glance", service_type="image", version="2")
class GlanceV2Service(service.Service, glance_common.GlanceMixin):
@atomic.action_timer("glance_v2.upload_data")
def upload_data(self, image_id, image_location):
"""Upload the data for an image.
:param image_id: Image ID to upload data to.
:param image_location: Location of the data to upload to.
"""
image_location = os.path.expanduser(image_location)
image_data = None
response = None
try:
#
# 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.common import cfg
from rally.task import atomic
from rally.task import utils
from rally_openstack import scenario
CONF = cfg.CONF
class EC2Scenario(scenario.OpenStackScenario):
"""Base class for EC2 scenarios with basic atomic actions."""
@atomic.action_timer("ec2.list_servers")
def _list_servers(self):
"""Returns user servers list."""
return self.clients("ec2").get_only_instances()
@atomic.action_timer("ec2.boot_servers")
def _boot_servers(self, image_id, flavor_name,
instance_num=1, **kwargs):
"""Boot multiple servers.
Returns when all the servers are actually booted and are in the
# 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 os
from rally.common import cfg
from rally.common import utils as rutils
from rally.plugins.openstack import service
from rally.plugins.openstack.services.image import glance_common
from rally.plugins.openstack.services.image import image
from rally.task import atomic
from rally.task import utils
CONF = cfg.CONF
@service.service("glance", service_type="image", version="1")
class GlanceV1Service(service.Service, glance_common.GlanceMixin):
@atomic.action_timer("glance_v1.create_image")
def create_image(self, image_name=None, container_format=None,
image_location=None, disk_format=None,
is_public=True, min_disk=0, min_ram=0,
properties=None):
"""Creates new image.
:param image_name: Image name for which need to be created
:param container_format: Container format
:param image_location: The new image's location
:param disk_format: Disk format
# 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.common import cfg
OPTS = {"openstack": [
cfg.FloatOpt(
"ec2_server_boot_prepoll_delay",
default=1.0,
deprecated_group="benchmark",
help="Time to sleep after boot before polling for status"
),
cfg.FloatOpt(
"ec2_server_boot_timeout",
default=300.0,
deprecated_group="benchmark",
help="Server boot timeout"
),
cfg.FloatOpt(
"ec2_server_boot_poll_interval",
default=1.0,
deprecated_group="benchmark",
help="Server boot poll interval"
)
from saharaclient.api import base as sahara_base
from rally.common import cfg
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import exceptions
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.sahara import consts as sahara_consts
from rally.task import atomic
from rally.task import utils
from rally.utils import strutils
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
class SaharaScenario(scenario.OpenStackScenario):
"""Base class for Sahara scenarios with basic atomic actions."""
# NOTE(sskripnick): Some sahara resource names are validated as hostnames.
# Since underscores are not allowed in hostnames we should not use them.
RESOURCE_NAME_FORMAT = "rally-sahara-XXXXXX-XXXXXXXXXXXXXXXX"
@atomic.action_timer("sahara.list_node_group_templates")
def _list_node_group_templates(self):
"""Return user Node Group Templates list."""
return self.clients("sahara").node_group_templates.list()
@atomic.action_timer("sahara.create_master_node_group_template")
def _create_master_node_group_template(self, flavor_id, plugin_name,