Merge "Improve Rally Logging (part 3)"

This commit is contained in:
Jenkins 2017-10-06 02:15:11 +00:00 committed by Gerrit Code Review
commit c7336d055a
41 changed files with 216 additions and 263 deletions

View File

@ -16,7 +16,6 @@
import time import time
from rally.common import broker from rally.common import broker
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally.common.plugin import discover from rally.common.plugin import discover
from rally.common.plugin import plugin from rally.common.plugin import plugin
@ -79,19 +78,19 @@ class SeekAndDestroy(object):
} }
LOG.debug( LOG.debug(
"Deleting %(service)s %(resource)s object %(name)s (%(uuid)s)", "Deleting %(service)s.%(resource)s object %(name)s (%(uuid)s)"
msg_kw) % msg_kw)
try: try:
rutils.retry(resource._max_attempts, resource.delete) rutils.retry(resource._max_attempts, resource.delete)
except Exception as e: except Exception as e:
msg_kw["reason"] = e msg = ("Resource deletion failed, max retries exceeded for "
LOG.warning( "%(service)s.%(resource)s: %(uuid)s.") % msg_kw
_("Resource deletion failed, max retries exceeded for "
"%(service)s.%(resource)s: %(uuid)s. Reason: %(reason)s")
% msg_kw)
if logging.is_debug(): if logging.is_debug():
LOG.exception(e) LOG.exception(msg)
else:
LOG.warning("%(msg)s Reason: %(e)s" % {"msg": msg, "e": e})
else: else:
started = time.time() started = time.time()
failures_count = 0 failures_count = 0
@ -100,11 +99,10 @@ class SeekAndDestroy(object):
if resource.is_deleted(): if resource.is_deleted():
return return
except Exception as e: except Exception as e:
LOG.warning( LOG.exception(
_("Seems like %s.%s.is_deleted(self) method is broken " "Seems like %s.%s.is_deleted(self) method is broken "
"It shouldn't raise any exceptions.") "It shouldn't raise any exceptions."
% (resource.__module__, type(resource).__name__)) % (resource.__module__, type(resource).__name__))
LOG.exception(e)
# NOTE(boris-42): Avoid LOG spamming in case of bad # NOTE(boris-42): Avoid LOG spamming in case of bad
# is_deleted() method # is_deleted() method
@ -115,9 +113,8 @@ class SeekAndDestroy(object):
finally: finally:
rutils.interruptable_sleep(resource._interval) rutils.interruptable_sleep(resource._interval)
LOG.warning(_("Resource deletion failed, timeout occurred for " LOG.warning("Resource deletion failed, timeout occurred for "
"%(service)s.%(resource)s: %(uuid)s.") "%(service)s.%(resource)s: %(uuid)s." % msg_kw)
% msg_kw)
def _publisher(self, queue): def _publisher(self, queue):
"""Publisher for deletion jobs. """Publisher for deletion jobs.
@ -135,12 +132,11 @@ class SeekAndDestroy(object):
try: try:
for raw_resource in rutils.retry(3, manager.list): for raw_resource in rutils.retry(3, manager.list):
queue.append((admin, user, raw_resource)) queue.append((admin, user, raw_resource))
except Exception as e: except Exception:
LOG.warning( LOG.exception(
_("Seems like %s.%s.list(self) method is broken. " "Seems like %s.%s.list(self) method is broken. "
"It shouldn't raise any exceptions.") "It shouldn't raise any exceptions."
% (manager.__module__, type(manager).__name__)) % (manager.__module__, type(manager).__name__))
LOG.exception(e)
if self.admin and (not self.users if self.admin and (not self.users
or self.manager_cls._perform_for_admin_only): or self.manager_cls._perform_for_admin_only):
@ -280,9 +276,9 @@ def cleanup(names=None, admin_required=None, admin=None, users=None,
rutils.RandomNameGeneratorMixin): rutils.RandomNameGeneratorMixin):
resource_classes.append(superclass) resource_classes.append(superclass)
for manager in find_resource_managers(names, admin_required): for manager in find_resource_managers(names, admin_required):
LOG.debug("Cleaning up %(service)s %(resource)s objects", LOG.debug("Cleaning up %(service)s %(resource)s objects"
{"service": manager._service, % {"service": manager._service,
"resource": manager._resource}) "resource": manager._resource})
SeekAndDestroy(manager, admin, users, SeekAndDestroy(manager, admin, users,
api_versions=api_versions, api_versions=api_versions,
resource_classes=resource_classes, resource_classes=resource_classes,

View File

@ -446,8 +446,7 @@ class NeutronPort(NeutronMixin):
except neutron_exceptions.PortNotFoundClient: except neutron_exceptions.PortNotFoundClient:
# Port can be already auto-deleted, skip silently # Port can be already auto-deleted, skip silently
LOG.debug("Port %s was not deleted. Skip silently because " LOG.debug("Port %s was not deleted. Skip silently because "
"port can be already auto-deleted.", "port can be already auto-deleted." % self.id())
self.id())
@base.resource("neutron", "subnet", order=next(_neutron_order), @base.resource("neutron", "subnet", order=next(_neutron_order),

View File

@ -12,7 +12,6 @@
import random import random
from rally.common.i18n import _
from rally.common import validation from rally.common import validation
from rally import consts from rally import consts
from rally import exceptions from rally import exceptions
@ -239,23 +238,22 @@ class OpenStackAPIVersions(context.Context):
services_from_admin = None services_from_admin = None
for client_name, conf in self.config.items(): for client_name, conf in self.config.items():
if "service_type" in conf and conf["service_type"] not in services: if "service_type" in conf and conf["service_type"] not in services:
raise exceptions.ValidationError(_( raise exceptions.ValidationError(
"There is no service with '%s' type in your environment.") "There is no service with '%s' type in your environment."
% conf["service_type"]) % conf["service_type"])
elif "service_name" in conf: elif "service_name" in conf:
if not self.context.get("admin", {}).get("credential"): if not self.context.get("admin", {}).get("credential"):
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), ctx_name=self.get_name(),
msg=_("Setting 'service_name' is allowed" msg="Setting 'service_name' is admin only operation.")
" only for 'admin' user."))
if not services_from_admin: if not services_from_admin:
services_from_admin = dict( services_from_admin = dict(
[(s.name, s.type) [(s.name, s.type)
for s in admin_clients.keystone().services.list()]) for s in admin_clients.keystone().services.list()])
if conf["service_name"] not in services_from_admin: if conf["service_name"] not in services_from_admin:
raise exceptions.ValidationError( raise exceptions.ValidationError(
_("There is no '%s' service in your environment") % "There is no '%s' service in your environment"
conf["service_name"]) % conf["service_name"])
# TODO(boris-42): Use separate key ["openstack"]["versions"] # TODO(boris-42): Use separate key ["openstack"]["versions"]
self.context["config"]["api_versions@openstack"][client_name][ self.context["config"]["api_versions@openstack"][client_name][

View File

@ -16,7 +16,6 @@ import time
from six import moves from six import moves
from rally.common.i18n import _
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
@ -111,12 +110,12 @@ class CeilometerSampleGenerator(context.Context):
samples = scenario._create_samples(batch) samples = scenario._create_samples(batch)
except Exception: except Exception:
unsuccess += 1 unsuccess += 1
LOG.warning(_("Failed to store batch %d of Ceilometer samples" LOG.warning("Failed to store batch %d of Ceilometer samples"
" during context creation") % i) " during context creation" % i)
if unsuccess > batches_allow_lose: if unsuccess > batches_allow_lose:
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), ctx_name=self.get_name(),
msg=_("Context failed to store too many batches of samples")) msg="Context failed to store too many batches of samples")
return samples return samples

View File

@ -44,7 +44,7 @@ class VolumeTypeGenerator(context.Context):
admin_clients, name_generator=self.generate_random_name) admin_clients, name_generator=self.generate_random_name)
self.context["volume_types"] = [] self.context["volume_types"] = []
for vtype_name in self.config: for vtype_name in self.config:
LOG.debug("Creating Cinder volume type %s", vtype_name) LOG.debug("Creating Cinder volume type %s" % vtype_name)
vtype = cinder_service.create_volume_type(vtype_name) vtype = cinder_service.create_volume_type(vtype_name)
self.context["volume_types"].append({"id": vtype.id, self.context["volume_types"].append({"id": vtype.id,
"name": vtype_name}) "name": vtype_name})

View File

@ -68,8 +68,7 @@ class EC2ServerGenerator(context.Context):
for user, tenant_id in rutils.iterate_per_tenants( for user, tenant_id in rutils.iterate_per_tenants(
self.context["users"]): self.context["users"]):
LOG.debug("Booting servers for tenant %s ", LOG.debug("Booting servers for tenant %s " % user["tenant_id"])
(user["tenant_id"]))
ec2_scenario = ec2_utils.EC2Scenario({ ec2_scenario = ec2_utils.EC2Scenario({
"user": user, "user": user,
"task": self.context["task"], "task": self.context["task"],
@ -77,10 +76,11 @@ class EC2ServerGenerator(context.Context):
LOG.debug( LOG.debug(
"Calling _boot_servers with " "Calling _boot_servers with "
"image_id={image_id} flavor_name={flavor_name} " "image_id=%(image_id)s flavor_name=%(flavor_name)s "
"servers_per_tenant={servers_per_tenant}".format( "servers_per_tenant=%(servers_per_tenant)s"
image_id=image_id, flavor_name=flavor["name"], % {"image_id": image_id,
servers_per_tenant=self.config["servers_per_tenant"])) "flavor_name": flavor["name"],
"servers_per_tenant": self.config["servers_per_tenant"]})
servers = ec2_scenario._boot_servers( servers = ec2_scenario._boot_servers(
image_id, flavor["name"], self.config["servers_per_tenant"]) image_id, flavor["name"], self.config["servers_per_tenant"])

View File

@ -14,7 +14,6 @@
from oslo_config import cfg from oslo_config import cfg
from rally.common.i18n import _
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
@ -132,23 +131,21 @@ class ImageGenerator(context.Context):
image_args = self.config.get("image_args", {}) image_args = self.config.get("image_args", {})
if "image_type" in self.config: if "image_type" in self.config:
LOG.warning(_("The 'image_type' argument is deprecated " LOG.warning("The 'image_type' argument is deprecated since "
"since Rally 0.10.0, use disk_format " "Rally 0.10.0, use disk_format argument instead")
"arguments instead."))
if not disk_format: if not disk_format:
disk_format = self.config["image_type"] disk_format = self.config["image_type"]
if "image_container" in self.config: if "image_container" in self.config:
LOG.warning(_("The 'image_container' argument is deprecated " LOG.warning("The 'image_container' argument is deprecated since "
"since Rally 0.10.0; use container_format " "Rally 0.10.0; use container_format argument instead")
"arguments instead"))
if not container_format: if not container_format:
container_format = self.config["image_container"] container_format = self.config["image_container"]
if image_args: if image_args:
LOG.warning(_("The 'image_args' argument is deprecated since " LOG.warning(
"Rally 0.10.0; specify exact arguments in a root " "The 'image_args' argument is deprecated since Rally 0.10.0; "
"section of context instead.")) "specify arguments in a root section of context instead")
if "is_public" in image_args: if "is_public" in image_args:
if "visibility" not in self.config: if "visibility" not in self.config:

View File

@ -16,7 +16,6 @@
from oslo_config import cfg from oslo_config import cfg
from rally.common import broker from rally.common import broker
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally.common import validation from rally.common import validation
from rally import consts from rally import consts
@ -61,8 +60,8 @@ class RoleGenerator(context.Context):
if str(def_role.name) == context_role: if str(def_role.name) == context_role:
return def_role return def_role
else: else:
raise exceptions.NotFoundException(_( raise exceptions.NotFoundException(
"There is no role with name `%s`") % context_role) "There is no role with name `%s`" % context_role)
def _get_consumer(self, func_name): def _get_consumer(self, func_name):
def consume(cache, args): def consume(cache, args):
@ -85,10 +84,10 @@ class RoleGenerator(context.Context):
role = self._get_role_object(context_role) role = self._get_role_object(context_role)
roles_dict[role.id] = role.name roles_dict[role.id] = role.name
LOG.debug("Adding role %(role_name)s having ID %(role_id)s " LOG.debug("Adding role %(role_name)s having ID %(role_id)s "
"to all users using %(threads)s threads", "to all users using %(threads)s threads"
{"role_name": role.name, % {"role_name": role.name,
"role_id": role.id, "role_id": role.id,
"threads": threads}) "threads": threads})
for user in self.context["users"]: for user in self.context["users"]:
args = (role.id, user["id"], user["tenant_id"]) args = (role.id, user["id"], user["tenant_id"])
queue.append(args) queue.append(args)
@ -102,7 +101,7 @@ class RoleGenerator(context.Context):
def publish(queue): def publish(queue):
for role_id in self.context["roles"]: for role_id in self.context["roles"]:
LOG.debug("Removing role %s from all users", role_id) LOG.debug("Removing role %s from all users" % role_id)
for user in self.context["users"]: for user in self.context["users"]:
args = (role_id, user["id"], user["tenant_id"]) args = (role_id, user["id"], user["tenant_id"])
queue.append(args) queue.append(args)

View File

@ -19,7 +19,6 @@ import uuid
from oslo_config import cfg from oslo_config import cfg
from rally.common import broker from rally.common import broker
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally.common import objects from rally.common import objects
from rally.common import utils as rutils from rally.common import utils as rutils
@ -139,13 +138,13 @@ class UserGenerator(context.Context):
use_sg, msg = network.wrap(clients, self).supports_extension( use_sg, msg = network.wrap(clients, self).supports_extension(
"security-group") "security-group")
if not use_sg: if not use_sg:
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 rutils.iterate_per_tenants(
self.context["users"]): 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"])
security_groups = uclients.neutron().list_security_groups() security_groups = uclients.neutron().list_security_groups()
default = [sg for sg in security_groups["security_groups"] default = [sg for sg in security_groups["security_groups"]
@ -264,18 +263,18 @@ class UserGenerator(context.Context):
"""Create tenants and users, using the broker pattern.""" """Create tenants and users, using the broker pattern."""
threads = self.config["resource_management_workers"] threads = self.config["resource_management_workers"]
LOG.debug("Creating %(tenants)d tenants using %(threads)s threads", LOG.debug("Creating %(tenants)d tenants using %(threads)s threads"
{"tenants": self.config["tenants"], "threads": threads}) % {"tenants": self.config["tenants"], "threads": threads})
self.context["tenants"] = self._create_tenants() self.context["tenants"] = self._create_tenants()
if len(self.context["tenants"]) < self.config["tenants"]: if len(self.context["tenants"]) < self.config["tenants"]:
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), ctx_name=self.get_name(),
msg=_("Failed to create the requested number of tenants.")) msg="Failed to create the requested number of tenants.")
users_num = self.config["users_per_tenant"] * self.config["tenants"] users_num = self.config["users_per_tenant"] * self.config["tenants"]
LOG.debug("Creating %(users)d users using %(threads)s threads", LOG.debug("Creating %(users)d users using %(threads)s threads"
{"users": users_num, "threads": threads}) % {"users": users_num, "threads": threads})
self.context["users"] = self._create_users() self.context["users"] = self._create_users()
for user in self.context["users"]: for user in self.context["users"]:
self.context["tenants"][user["tenant_id"]]["users"].append(user) self.context["tenants"][user["tenant_id"]]["users"].append(user)
@ -283,7 +282,7 @@ class UserGenerator(context.Context):
if len(self.context["users"]) < users_num: if len(self.context["users"]) < users_num:
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), ctx_name=self.get_name(),
msg=_("Failed to create the requested number of users.")) msg="Failed to create the requested number of users.")
def use_existing_users(self): def use_existing_users(self):
LOG.debug("Using existing users") LOG.debug("Using existing users")

View File

@ -15,7 +15,6 @@
from oslo_config import cfg from oslo_config import cfg
from rally.common.i18n import _
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
@ -89,9 +88,9 @@ class ShareNetworks(context.Context):
def _setup_for_existing_users(self): def _setup_for_existing_users(self):
if (self.config["use_share_networks"] and if (self.config["use_share_networks"] and
not self.config["share_networks"]): not self.config["share_networks"]):
msg = _("Usage of share networks was enabled but for deployment " msg = ("Usage of share networks was enabled but for deployment "
"with existing users share networks also should be " "with existing users share networks also should be "
"specified via arg 'share_networks'") "specified via arg 'share_networks'")
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), msg=msg) ctx_name=self.get_name(), msg=msg)
@ -108,8 +107,8 @@ class ShareNetworks(context.Context):
break break
break break
else: else:
msg = _("Provided tenant Name or ID '%s' was not found in " msg = ("Provided tenant Name or ID '%s' was not found in "
"existing tenants.") % tenant_name_or_id "existing tenants.") % tenant_name_or_id
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), msg=msg) ctx_name=self.get_name(), msg=msg)
self.context["tenants"][tenant_id][CONTEXT_NAME] = {} self.context["tenants"][tenant_id][CONTEXT_NAME] = {}
@ -131,9 +130,9 @@ class ShareNetworks(context.Context):
if sn_name_or_id in (sn.id, sn.name): if sn_name_or_id in (sn.id, sn.name):
break break
else: else:
msg = _("Specified share network '%(sn)s' does not " msg = ("Specified share network '%(sn)s' does not "
"exist for tenant '%(tenant_id)s'") % { "exist for tenant '%(tenant_id)s'"
"sn": sn_name_or_id, "tenant_id": tenant_id} % {"sn": sn_name_or_id, "tenant_id": tenant_id})
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), msg=msg) ctx_name=self.get_name(), msg=msg)
@ -178,9 +177,8 @@ class ShareNetworks(context.Context):
data["neutron_net_id"] = network["id"] data["neutron_net_id"] = network["id"]
data["neutron_subnet_id"] = network["subnets"][0] data["neutron_subnet_id"] = network["subnets"][0]
else: else:
LOG.warning(_( LOG.warning("Can't determine network service provider."
"Can not determine network service provider. " " Share network will have no data.")
"Share network will have no data."))
_setup_share_network(tenant_id, data) _setup_share_network(tenant_id, data)
else: else:
_setup_share_network(tenant_id, data) _setup_share_network(tenant_id, data)

View File

@ -13,7 +13,6 @@
# 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.i18n import _
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
@ -97,7 +96,7 @@ class AllowSSH(context.Context):
self, config=self.config) self, config=self.config)
use_sg, msg = net_wrapper.supports_extension("security-group") use_sg, msg = net_wrapper.supports_extension("security-group")
if not use_sg: if not use_sg:
LOG.info(_("Security group context is disabled: %s") % msg) LOG.info("Security group context is disabled: %s" % msg)
return return
secgroup_name = self.generate_random_name() secgroup_name = self.generate_random_name()
@ -109,7 +108,8 @@ class AllowSSH(context.Context):
for user, tenant_id in utils.iterate_per_tenants( for user, tenant_id in utils.iterate_per_tenants(
self.context["users"]): self.context["users"]):
with logging.ExceptionLogger( with logging.ExceptionLogger(
LOG, _("Unable to delete secgroup: %s.") % LOG,
user["secgroup"]["name"]): "Unable to delete security group: %s."
% user["secgroup"]["name"]):
clients = osclients.Clients(user["credential"]) clients = osclients.Clients(user["credential"])
clients.neutron().delete_security_group(user["secgroup"]["id"]) clients.neutron().delete_security_group(user["secgroup"]["id"])

View File

@ -13,7 +13,6 @@
# 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.i18n import _
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
@ -107,6 +106,5 @@ class Network(context.Context):
for network in tenant_ctx.get("networks", []): for network in tenant_ctx.get("networks", []):
with logging.ExceptionLogger( with logging.ExceptionLogger(
LOG, LOG,
_("Failed to delete network for tenant %s") "Failed to delete network for tenant %s" % tenant_id):
% tenant_id):
net_wrapper.delete_network(network) net_wrapper.delete_network(network)

View File

@ -10,7 +10,6 @@
# 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.i18n import _
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
@ -86,8 +85,8 @@ class Lbaas(context.Context):
for pool in network.get("lb_pools", []): for pool in network.get("lb_pools", []):
with logging.ExceptionLogger( with logging.ExceptionLogger(
LOG, LOG,
_("Failed to delete pool %(pool)s for tenant " "Failed to delete pool %(pool)s for tenant "
"%(tenant)s") % {"pool": pool["pool"]["id"], "%(tenant)s" % {"pool": pool["pool"]["id"],
"tenant": tenant_id}): "tenant": tenant_id}):
if self.config["lbaas_version"] == 1: if self.config["lbaas_version"] == 1:
net_wrapper.delete_v1_pool(pool["pool"]["id"]) net_wrapper.delete_v1_pool(pool["pool"]["id"])

View File

@ -84,18 +84,19 @@ class FlavorsGenerator(context.Context):
flavor_config = FlavorConfig(**flavor_config) flavor_config = FlavorConfig(**flavor_config)
try: try:
flavor = clients.nova().flavors.create(**flavor_config) flavor = clients.nova().flavors.create(**flavor_config)
except nova_exceptions.Conflict as e: except nova_exceptions.Conflict:
LOG.warning("Using already existing flavor %s" % msg = "Using existing flavor %s" % flavor_config["name"]
flavor_config["name"])
if logging.is_debug(): if logging.is_debug():
LOG.exception(e) LOG.exception(msg)
else:
LOG.warning(msg)
continue continue
if extra_specs: if extra_specs:
flavor.set_keys(extra_specs) flavor.set_keys(extra_specs)
self.context["flavors"][flavor_config["name"]] = flavor.to_dict() self.context["flavors"][flavor_config["name"]] = flavor.to_dict()
LOG.debug("Created flavor with id '%s'", flavor.id) LOG.debug("Created flavor with id '%s'" % flavor.id)
def cleanup(self): def cleanup(self):
"""Delete created flavors.""" """Delete created flavors."""

View File

@ -99,8 +99,7 @@ class ServerGenerator(context.Context):
for iter_, (user, tenant_id) in enumerate(rutils.iterate_per_tenants( for iter_, (user, tenant_id) in enumerate(rutils.iterate_per_tenants(
self.context["users"])): self.context["users"])):
LOG.debug("Booting servers for user tenant %s ", LOG.debug("Booting servers for user tenant %s" % user["tenant_id"])
(user["tenant_id"]))
tmp_context = {"user": user, tmp_context = {"user": user,
"tenant": self.context["tenants"][tenant_id], "tenant": self.context["tenants"][tenant_id],
"task": self.context["task"], "task": self.context["task"],
@ -110,10 +109,10 @@ class ServerGenerator(context.Context):
LOG.debug("Calling _boot_servers with image_id=%(image_id)s " LOG.debug("Calling _boot_servers with image_id=%(image_id)s "
"flavor_id=%(flavor_id)s " "flavor_id=%(flavor_id)s "
"servers_per_tenant=%(servers_per_tenant)s", "servers_per_tenant=%(servers_per_tenant)s"
{"image_id": image_id, % {"image_id": image_id,
"flavor_id": flavor_id, "flavor_id": flavor_id,
"servers_per_tenant": servers_per_tenant}) "servers_per_tenant": servers_per_tenant})
servers = nova_scenario._boot_servers(image_id, flavor_id, servers = nova_scenario._boot_servers(image_id, flavor_id,
requests=servers_per_tenant, requests=servers_per_tenant,
@ -122,8 +121,7 @@ class ServerGenerator(context.Context):
current_servers = [server.id for server in servers] current_servers = [server.id for server in servers]
LOG.debug("Adding booted servers %s to context", LOG.debug("Adding booted servers %s to context" % current_servers)
current_servers)
self.context["tenants"][tenant_id][ self.context["tenants"][tenant_id][
"servers"] = current_servers "servers"] = current_servers

View File

@ -95,11 +95,10 @@ class Quotas(context.Context):
try: try:
self.manager[service].delete(tenant_id) self.manager[service].delete(tenant_id)
except Exception as e: except Exception as e:
LOG.warning("Failed to remove quotas for tenant " LOG.warning(
"%(tenant_id)s in service %(service)s " "Failed to remove quotas for tenant %(tenant)s "
"\n reason: %(exc)s" "in service %(service)s reason: %(e)s" %
% {"tenant_id": tenant_id, {"tenant": tenant_id, "service": service, "e": e})
"service": service, "exc": e})
def cleanup(self): def cleanup(self):
if self.original_quotas: if self.original_quotas:

View File

@ -15,7 +15,6 @@
from oslo_config import cfg from oslo_config import cfg
from rally.common.i18n import _
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 consts from rally import consts
@ -167,13 +166,12 @@ class SaharaCluster(context.Context):
for cluster, client in dct.items(): for cluster, client in dct.items():
cluster_status = cluster.status.lower() cluster_status = cluster.status.lower()
if cluster_status == "error": if cluster_status == "error":
msg = _("Sahara cluster %(name)s has failed to" msg = ("Sahara cluster %(name)s has failed to"
" %(action)s. Reason: '%(reason)s'") % { " %(action)s. Reason: '%(reason)s'"
"name": cluster.name, "action": "start", % {"name": cluster.name, "action": "start",
"reason": cluster.status_description} "reason": cluster.status_description})
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(ctx_name=self.get_name(),
ctx_name=self.get_name(), msg=msg)
msg=msg)
elif cluster_status != "active": elif cluster_status != "active":
return False return False
return True return True

View File

@ -12,7 +12,6 @@
# 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.i18n import _
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 consts from rally import consts
@ -101,8 +100,7 @@ class SaharaImage(context.Context):
if visibility != "public": if visibility != "public":
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), ctx_name=self.get_name(),
msg=_("Image provided in the Sahara context" msg="Use only public image for sahara_image context"
" should be public.")
) )
image_id = image_uuid image_id = image_uuid

View File

@ -104,7 +104,7 @@ class SaharaJobBinaries(context.Context):
def setup_inputs(self, sahara, tenant_id, input_type, input_url): def setup_inputs(self, sahara, tenant_id, input_type, input_url):
if input_type == "swift": if input_type == "swift":
raise exceptions.RallyException( raise exceptions.RallyException(
_("Swift Data Sources are not implemented yet")) "Swift Data Sources are not implemented yet")
# Todo(nkonovalov): Add swift credentials parameters and data upload # Todo(nkonovalov): Add swift credentials parameters and data upload
input_ds = sahara.data_sources.create( input_ds = sahara.data_sources.create(
name=self.generate_random_name(), name=self.generate_random_name(),

View File

@ -13,7 +13,6 @@
# 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.i18n import _
from rally.common import logging from rally.common import logging
from rally.common import validation from rally.common import validation
from rally import consts from rally import consts
@ -65,22 +64,22 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
containers_per_tenant = self.config["containers_per_tenant"] containers_per_tenant = self.config["containers_per_tenant"]
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.", (containers_num, LOG.debug("Creating %d containers using %d threads."
threads)) % (containers_num, threads))
containers_count = len(self._create_containers(self.context, containers_count = len(self._create_containers(self.context,
containers_per_tenant, containers_per_tenant,
threads)) threads))
if containers_count != containers_num: if containers_count != containers_num:
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), ctx_name=self.get_name(),
msg=_("Failed to create the requested number of containers, " msg="Failed to create the requested number of containers, "
"expected %(expected)s but got %(actual)s.") "expected %(expected)s but got %(actual)s."
% {"expected": containers_num, "actual": containers_count}) % {"expected": containers_num, "actual": containers_count})
objects_per_container = self.config["objects_per_container"] objects_per_container = self.config["objects_per_container"]
objects_num = containers_num * objects_per_container objects_num = containers_num * objects_per_container
LOG.debug("Creating %d objects using %d threads.", (objects_num, LOG.debug("Creating %d objects using %d threads."
threads)) % (objects_num, threads))
objects_count = len(self._create_objects(self.context, objects_count = len(self._create_objects(self.context,
objects_per_container, objects_per_container,
self.config["object_size"], self.config["object_size"],
@ -88,9 +87,9 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
if objects_count != objects_num: if objects_count != objects_num:
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), ctx_name=self.get_name(),
msg=_("Failed to create the requested number of objects, " msg="Failed to create the requested number of objects, "
"expected %(expected)s but got %(actual)s.") "expected %(expected)s but got %(actual)s."
% {"expected": objects_num, "actual": objects_count}) % {"expected": objects_num, "actual": objects_count})
def cleanup(self): def cleanup(self):
"""Delete containers and objects, using the broker pattern.""" """Delete containers and objects, using the broker pattern."""

View File

@ -18,7 +18,6 @@ import abc
import six import six
from rally.common import broker from rally.common import broker
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally.common import utils from rally.common import utils
from rally import consts from rally import consts
@ -164,13 +163,13 @@ class BaseCustomImageGenerator(context.Context):
**kwargs) **kwargs)
try: try:
LOG.debug("Installing tools on %r %s", server, fip["ip"]) LOG.debug("Installing tools on %r %s" % (server, fip["ip"]))
self.customize_image(server, fip, user) self.customize_image(server, fip, user)
LOG.debug("Stopping server %r", server) LOG.debug("Stopping server %r" % server)
vm_scenario._stop_server(server) vm_scenario._stop_server(server)
LOG.debug("Creating snapshot for %r", server) LOG.debug("Creating snapshot for %r" % server)
custom_image = vm_scenario._create_image(server) custom_image = vm_scenario._create_image(server)
finally: finally:
vm_scenario._delete_server_with_fip(server, fip) vm_scenario._delete_server_with_fip(server, fip)
@ -205,13 +204,12 @@ class BaseCustomImageGenerator(context.Context):
"""Delete the image created for the user and tenant.""" """Delete the image created for the user and tenant."""
with logging.ExceptionLogger( with logging.ExceptionLogger(
LOG, _("Unable to delete image %s") % custom_image.id): LOG, "Unable to delete image %s" % custom_image.id):
glance_service = image.Image(user["credential"].clients()) glance_service = image.Image(user["credential"].clients())
glance_service.delete_image(custom_image.id) glance_service.delete_image(custom_image.id)
@logging.log_task_wrapper(LOG.info, @logging.log_task_wrapper(LOG.info, "Custom image context: customizing")
_("Custom image context: customizing"))
def customize_image(self, server, ip, user): def customize_image(self, server, ip, user):
return self._customize_image(server, ip, user) return self._customize_image(server, ip, user)

View File

@ -75,5 +75,5 @@ class FaultInjectionHook(hook.Hook):
if self.config.get("verify"): if self.config.get("verify"):
injector.verify() injector.verify()
LOG.debug("Injecting fault: %s", self.config["action"]) LOG.debug("Injecting fault: %s" % self.config["action"])
os_faults.human_api(injector, self.config["action"]) os_faults.human_api(injector, self.config["action"])

View File

@ -17,7 +17,6 @@ import random
from oslo_config import cfg from oslo_config import cfg
from rally.common.i18n import _, _LW
from rally.common import logging from rally.common import logging
from rally import exceptions from rally import exceptions
from rally.plugins.openstack import scenario from rally.plugins.openstack import scenario
@ -53,11 +52,11 @@ class CinderScenario(scenario.OpenStackScenario):
def __init__(self, context=None, admin_clients=None, clients=None): def __init__(self, context=None, admin_clients=None, clients=None):
super(CinderScenario, self).__init__(context, admin_clients, clients) super(CinderScenario, self).__init__(context, admin_clients, clients)
LOG.warning(_LW( LOG.warning(
"Class %s is deprecated since Rally 0.10.0 and will be removed " "Class %s is deprecated since Rally 0.10.0 and will be removed "
"soon. Use " "soon. Use "
"rally.plugins.openstack.services.storage.block.BlockStorage " "rally.plugins.openstack.services.storage.block.BlockStorage "
"instead.") % self.__class__) "instead." % self.__class__)
@atomic.action_timer("cinder.list_volumes") @atomic.action_timer("cinder.list_volumes")
def _list_volumes(self, detailed=True): def _list_volumes(self, detailed=True):
@ -504,5 +503,4 @@ class CinderScenario(scenario.OpenStackScenario):
resp = self.admin_clients("cinder").volume_encryption_types.delete( resp = self.admin_clients("cinder").volume_encryption_types.delete(
volume_type) volume_type)
if (resp[0].status_code != 202): if (resp[0].status_code != 202):
raise exceptions.RallyException( raise exceptions.RallyException("EncryptionType Deletion Failed")
_("EncryptionType Deletion Failed"))

View File

@ -15,7 +15,6 @@
from oslo_config import cfg from oslo_config import cfg
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally.plugins.openstack import scenario from rally.plugins.openstack import scenario
from rally.plugins.openstack.wrappers import glance as glance_wrapper from rally.plugins.openstack.wrappers import glance as glance_wrapper
@ -32,11 +31,11 @@ class GlanceScenario(scenario.OpenStackScenario):
def __init__(self, context=None, admin_clients=None, clients=None): def __init__(self, context=None, admin_clients=None, clients=None):
super(GlanceScenario, self).__init__(context, admin_clients, clients) super(GlanceScenario, self).__init__(context, admin_clients, clients)
LOG.warning(_( LOG.warning(
"Class %s is deprecated since Rally 0.10.0 and will be removed " "Class %s is deprecated since Rally 0.10.0 and will be removed "
"soon. Use " "soon. Use "
"rally.plugins.openstack.services.image.image.Image " "rally.plugins.openstack.services.image.image.Image "
"instead.") % self.__class__) "instead." % self.__class__)
@atomic.action_timer("glance.list_images") @atomic.action_timer("glance.list_images")
def _list_images(self): def _list_images(self):

View File

@ -292,8 +292,8 @@ class HeatScenario(scenario.OpenStackScenario):
""" """
num_instances = self._count_instances(stack) num_instances = self._count_instances(stack)
expected_instances = num_instances + delta expected_instances = num_instances + delta
LOG.debug("Scaling stack %s from %s to %s instances with %s", LOG.debug("Scaling stack %s from %s to %s instances with %s"
(stack.id, num_instances, expected_instances, output_key)) % (stack.id, num_instances, expected_instances, output_key))
with atomic.ActionTimer(self, "heat.scale_with_%s" % output_key): with atomic.ActionTimer(self, "heat.scale_with_%s" % output_key):
self._stack_webhook(stack, output_key) self._stack_webhook(stack, output_key)
utils.wait_for( utils.wait_for(

View File

@ -15,7 +15,6 @@
import uuid import uuid
from rally.common.i18n import _LW
from rally.common import logging from rally.common import logging
from rally.plugins.openstack import scenario from rally.plugins.openstack import scenario
from rally.plugins.openstack.wrappers import keystone as keystone_wrapper from rally.plugins.openstack.wrappers import keystone as keystone_wrapper
@ -30,11 +29,11 @@ class KeystoneScenario(scenario.OpenStackScenario):
def __init__(self, context=None, admin_clients=None, clients=None): def __init__(self, context=None, admin_clients=None, clients=None):
super(KeystoneScenario, self).__init__(context, admin_clients, clients) super(KeystoneScenario, self).__init__(context, admin_clients, clients)
LOG.warning(_LW( LOG.warning(
"Class %s is deprecated since Rally 0.8.0 and will be removed " "Class %s is deprecated since Rally 0.8.0 and will be removed "
"soon. Use " "soon. Use "
"rally.plugins.openstack.services.identity.identity.Identity " "rally.plugins.openstack.services.identity.identity.Identity "
"instead.") % self.__class__) "instead." % self.__class__)
@atomic.action_timer("keystone.create_user") @atomic.action_timer("keystone.create_user")
def _user_create(self, email=None, **kwargs): def _user_create(self, email=None, **kwargs):

View File

@ -17,7 +17,6 @@ import random
from oslo_config import cfg from oslo_config import cfg
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally import exceptions from rally import exceptions
from rally.plugins.openstack import scenario from rally.plugins.openstack import scenario
@ -56,8 +55,8 @@ class NeutronScenario(scenario.OpenStackScenario):
for net in networks: for net in networks:
if (net["name"] == network) or (net["id"] == network): if (net["name"] == network) or (net["id"] == network):
return net["id"] return net["id"]
msg = (_("Network %s not found.") % network) raise exceptions.NotFoundException(
raise exceptions.NotFoundException(message=msg) message="Network %s not found." % network)
@property @property
def _ext_gw_mode_enabled(self): def _ext_gw_mode_enabled(self):
@ -302,9 +301,9 @@ class NeutronScenario(scenario.OpenStackScenario):
""" """
self.clients("neutron").delete_port(port["port"]["id"]) self.clients("neutron").delete_port(port["port"]["id"])
@logging.log_deprecated_args(_("network_create_args is deprecated; " @logging.log_deprecated_args(
"use the network context instead"), "network_create_args is deprecated; use the network context instead",
"0.1.0", "network_create_args") "0.1.0", "network_create_args")
def _get_or_create_network(self, network_create_args=None): def _get_or_create_network(self, network_create_args=None):
"""Get a network from context, or create a new one. """Get a network from context, or create a new one.
@ -323,8 +322,8 @@ class NeutronScenario(scenario.OpenStackScenario):
return {"network": return {"network":
random.choice(self.context["tenant"]["networks"])} random.choice(self.context["tenant"]["networks"])}
else: else:
LOG.warning(_("Running this scenario without either the 'network' " LOG.warning("Running this scenario without either the 'network' "
"or 'existing_network' context is deprecated")) "or 'existing_network' context is deprecated")
return self._create_network(network_create_args or {}) return self._create_network(network_create_args or {})
def _create_subnets(self, network, def _create_subnets(self, network,

View File

@ -13,7 +13,6 @@
# 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.i18n import _LW
from rally.common import logging from rally.common import logging
from rally import consts from rally import consts
from rally.plugins.openstack import scenario from rally.plugins.openstack import scenario
@ -81,8 +80,8 @@ class CreateAndListFlavorAccess(utils.NovaScenario):
# NOTE(pirsriva): access rules can be listed # NOTE(pirsriva): access rules can be listed
# only for non-public flavors # only for non-public flavors
if is_public: if is_public:
LOG.warning(_LW("is_public cannot be set to True for listing " LOG.warning("is_public cannot be set to True for listing "
"flavor access rules. Setting is_public to False")) "flavor access rules. Setting is_public to False")
is_public = False is_public = False
flavor = self._create_flavor(ram, vcpus, disk, flavorid=flavorid, flavor = self._create_flavor(ram, vcpus, disk, flavorid=flavorid,
ephemeral=ephemeral, swap=swap, ephemeral=ephemeral, swap=swap,

View File

@ -17,7 +17,6 @@ import random
from oslo_config import cfg from oslo_config import cfg
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally import exceptions from rally import exceptions
from rally.plugins.openstack import scenario from rally.plugins.openstack import scenario
@ -766,9 +765,9 @@ class NovaScenario(scenario.OpenStackScenario):
server_admin = self.admin_clients("nova").servers.get(server.id) server_admin = self.admin_clients("nova").servers.get(server.id)
if (host_pre_migrate == getattr(server_admin, "OS-EXT-SRV-ATTR:host") if (host_pre_migrate == getattr(server_admin, "OS-EXT-SRV-ATTR:host")
and not skip_host_check): and not skip_host_check):
raise exceptions.RallyException(_( raise exceptions.RallyException(
"Live Migration failed: Migration complete " "Live Migration failed: Migration complete "
"but instance did not change host: %s") % host_pre_migrate) "but instance did not change host: %s" % host_pre_migrate)
@atomic.action_timer("nova.find_host_to_migrate") @atomic.action_timer("nova.find_host_to_migrate")
def _find_host_to_migrate(self, server): def _find_host_to_migrate(self, server):
@ -792,7 +791,7 @@ class NovaScenario(scenario.OpenStackScenario):
return new_host return new_host
except IndexError: except IndexError:
raise exceptions.RallyException( raise exceptions.RallyException(
_("Live Migration failed: No valid host found to migrate")) "Live Migration failed: No valid host found to migrate")
@atomic.action_timer("nova.migrate") @atomic.action_timer("nova.migrate")
def _migrate(self, server, skip_host_check=False): def _migrate(self, server, skip_host_check=False):
@ -818,8 +817,8 @@ class NovaScenario(scenario.OpenStackScenario):
host_after_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host") host_after_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
if host_pre_migrate == host_after_migrate: if host_pre_migrate == host_after_migrate:
raise exceptions.RallyException( raise exceptions.RallyException(
_("Migration failed: Migration complete but instance" "Migration failed: Migration complete but instance"
" did not change host: %s") % host_pre_migrate) " did not change host: %s" % host_pre_migrate)
@atomic.action_timer("nova.add_server_secgroups") @atomic.action_timer("nova.add_server_secgroups")
def _add_server_secgroups(self, server, security_group, def _add_server_secgroups(self, server, security_group,

View File

@ -95,7 +95,7 @@ class CreateAndDeleteCluster(utils.SaharaScenario):
image_id = self.context["tenant"]["sahara"]["image"] image_id = self.context["tenant"]["sahara"]["image"]
LOG.debug("Using Image: %s", image_id) LOG.debug("Using Image: %s" % image_id)
cluster = self._launch_cluster( cluster = self._launch_cluster(
flavor_id=flavor, flavor_id=flavor,
@ -194,7 +194,7 @@ class CreateScaleDeleteCluster(utils.SaharaScenario):
image_id = self.context["tenant"]["sahara"]["image"] image_id = self.context["tenant"]["sahara"]["image"]
LOG.debug("Using Image: %s", image_id) LOG.debug("Using Image: %s" % image_id)
cluster = self._launch_cluster( cluster = self._launch_cluster(
flavor_id=flavor, flavor_id=flavor,

View File

@ -92,7 +92,7 @@ class CreateLaunchJobSequence(utils.SaharaScenario):
launch_job = CreateLaunchJob(self.context) launch_job = CreateLaunchJob(self.context)
for idx, job in enumerate(jobs): for idx, job in enumerate(jobs):
LOG.debug("Launching Job. Sequence #%d", idx) LOG.debug("Launching Job. Sequence #%d" % idx)
launch_job.run(job["job_type"], job["configs"], idx) launch_job.run(job["job_type"], job["configs"], idx)
@ -127,8 +127,8 @@ class CreateLaunchJobSequenceWithScaling(utils.SaharaScenario,):
# correct 'count' values. # correct 'count' values.
cluster = self.clients("sahara").clusters.get(cluster_id) cluster = self.clients("sahara").clusters.get(cluster_id)
LOG.debug("Scaling cluster %s with delta %d", LOG.debug("Scaling cluster %s with delta %d"
(cluster.name, delta)) % (cluster.name, delta))
if delta == 0: if delta == 0:
# Zero scaling makes no sense. # Zero scaling makes no sense.
continue continue

View File

@ -19,7 +19,6 @@ from oslo_config import cfg
from oslo_utils import uuidutils from oslo_utils import uuidutils
from saharaclient.api import base as sahara_base from saharaclient.api import base as sahara_base
from rally.common.i18n import _
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 import consts from rally import consts
@ -127,8 +126,8 @@ class SaharaScenario(scenario.OpenStackScenario):
# If the name is not found in the list. Exit with error. # If the name is not found in the list. Exit with error.
raise exceptions.ContextSetupFailure( raise exceptions.ContextSetupFailure(
ctx_name=self.get_name(), ctx_name=self.get_name(),
msg=_("Could not resolve Floating IP Pool" msg="Could not resolve Floating IP Pool name %s to id"
" name %s to id") % name_or_id) % name_or_id)
else: else:
# Pool is not provided. Using the one set as GW for current router. # Pool is not provided. Using the one set as GW for current router.
@ -167,7 +166,7 @@ class SaharaScenario(scenario.OpenStackScenario):
floating_ip_pool) floating_ip_pool)
if floating_ip_pool_value: if floating_ip_pool_value:
LOG.debug("Using floating ip pool %s.", floating_ip_pool_value) LOG.debug("Using floating ip pool %s." % floating_ip_pool_value)
# If the pool is set by any means assign it to all node groups. # If the pool is set by any means assign it to all node groups.
# If the proxy node feature is enabled, Master Node Group and # If the proxy node feature is enabled, Master Node Group and
# Proxy Workers should have a floating ip pool set up # Proxy Workers should have a floating ip pool set up
@ -233,7 +232,7 @@ class SaharaScenario(scenario.OpenStackScenario):
replication_value = min(workers_count, 3) replication_value = min(workers_count, 3)
# 3 is a default Hadoop replication # 3 is a default Hadoop replication
conf = sahara_consts.REPLICATION_CONFIGS[plugin_name][hadoop_version] conf = sahara_consts.REPLICATION_CONFIGS[plugin_name][hadoop_version]
LOG.debug("Using replication factor: %s", replication_value) LOG.debug("Using replication factor: %s" % replication_value)
replication_config = { replication_config = {
conf["target"]: { conf["target"]: {
conf["config_name"]: replication_value conf["config_name"]: replication_value
@ -394,7 +393,7 @@ class SaharaScenario(scenario.OpenStackScenario):
) )
if wait_active: if wait_active:
LOG.debug("Starting cluster `%s`", name) LOG.debug("Starting cluster `%s`" % name)
self._wait_active(cluster_object) self._wait_active(cluster_object)
return self.clients("sahara").clusters.get(cluster_object.id) return self.clients("sahara").clusters.get(cluster_object.id)
@ -454,7 +453,7 @@ class SaharaScenario(scenario.OpenStackScenario):
:param cluster: cluster to delete :param cluster: cluster to delete
""" """
LOG.debug("Deleting cluster `%s`", cluster.name) LOG.debug("Deleting cluster `%s`" % cluster.name)
self.clients("sahara").clusters.delete(cluster.id) self.clients("sahara").clusters.delete(cluster.id)
utils.wait_for( utils.wait_for(
@ -464,8 +463,8 @@ class SaharaScenario(scenario.OpenStackScenario):
is_ready=self._is_cluster_deleted) is_ready=self._is_cluster_deleted)
def _is_cluster_deleted(self, cluster): def _is_cluster_deleted(self, cluster):
LOG.debug("Checking cluster `%s` to be deleted. Status: `%s`", LOG.debug("Checking cluster `%s` to be deleted. Status: `%s`"
(cluster.name, cluster.status)) % (cluster.name, cluster.status))
try: try:
self.clients("sahara").clusters.get(cluster.id) self.clients("sahara").clusters.get(cluster.id)
return False return False
@ -482,7 +481,7 @@ class SaharaScenario(scenario.OpenStackScenario):
if ds_type == "swift": if ds_type == "swift":
raise exceptions.RallyException( raise exceptions.RallyException(
_("Swift Data Sources are not implemented yet")) "Swift Data Sources are not implemented yet")
url = url_prefix.rstrip("/") + "/%s" % self.generate_random_name() url = url_prefix.rstrip("/") + "/%s" % self.generate_random_name()
@ -534,8 +533,8 @@ class SaharaScenario(scenario.OpenStackScenario):
status = self.clients("sahara").job_executions.get(je_id).info[ status = self.clients("sahara").job_executions.get(je_id).info[
"status"].lower() "status"].lower()
LOG.debug("Checking for Job Execution %s to complete. Status: %s", LOG.debug("Checking for Job Execution %s to complete. Status: %s"
(je_id, status)) % (je_id, status))
if status in ("success", "succeeded"): if status in ("success", "succeeded"):
return True return True
elif status in ("failed", "killed"): elif status in ("failed", "killed"):
@ -574,8 +573,8 @@ class SaharaScenario(scenario.OpenStackScenario):
# Taking net id from context. # Taking net id from context.
net = self.context["tenant"]["networks"][0] net = self.context["tenant"]["networks"][0]
neutron_net_id = net["id"] neutron_net_id = net["id"]
LOG.debug("Using neutron network %s.", neutron_net_id) LOG.debug("Using neutron network %s." % neutron_net_id)
LOG.debug("Using neutron router %s.", net["router_id"]) LOG.debug("Using neutron router %s." % net["router_id"])
return neutron_net_id return neutron_net_id

View File

@ -21,7 +21,6 @@ import netaddr
from oslo_config import cfg from oslo_config import cfg
import six import six
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally.common import sshutils from rally.common import sshutils
from rally.plugins.openstack.scenarios.nova import utils as nova_utils from rally.plugins.openstack.scenarios.nova import utils as nova_utils
@ -63,8 +62,8 @@ class Host(object):
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
proc.wait() proc.wait()
LOG.debug("Host %s is ICMP %s", LOG.debug("Host %s is ICMP %s"
(server.ip.format(), proc.returncode and "down" or "up")) % (server.ip.format(), proc.returncode and "down" or "up"))
if proc.returncode == 0: if proc.returncode == 0:
server.status = cls.ICMP_UP_STATUS server.status = cls.ICMP_UP_STATUS
else: else:
@ -178,7 +177,7 @@ class VMScenario(nova_utils.NovaScenario):
@atomic.action_timer("vm.delete_floating_ip") @atomic.action_timer("vm.delete_floating_ip")
def _delete_floating_ip(self, server, fip): def _delete_floating_ip(self, server, fip):
with logging.ExceptionLogger( with logging.ExceptionLogger(
LOG, _("Unable to delete IP: %s") % fip["ip"]): LOG, "Unable to delete IP: %s" % fip["ip"]):
if self.check_ip_address(fip["ip"])(server): if self.check_ip_address(fip["ip"])(server):
self._dissociate_floating_ip(server, fip["ip"]) self._dissociate_floating_ip(server, fip["ip"])
with atomic.ActionTimer(self, "neutron.delete_floating_ip"): with atomic.ActionTimer(self, "neutron.delete_floating_ip"):

View File

@ -266,7 +266,7 @@ class BootRuncommandDelete(vm_utils.VMScenario, cinder_utils.CinderBasic):
exceptions.SSHTimeout): exceptions.SSHTimeout):
console_logs = self._get_server_console_output(server, console_logs = self._get_server_console_output(server,
max_log_length) max_log_length)
LOG.debug("VM console logs:\n%s", console_logs) LOG.debug("VM console logs:\n%s" % console_logs)
raise raise
finally: finally:

View File

@ -14,7 +14,6 @@
import random import random
from rally.common.i18n import _
from rally import exceptions from rally import exceptions
from rally.plugins.openstack.services.image import image from rally.plugins.openstack.services.image import image
from rally.plugins.openstack.services.storage import block from rally.plugins.openstack.services.storage import block
@ -454,7 +453,7 @@ class CinderMixin(object):
volume_type) volume_type)
if (resp[0].status_code != 202): if (resp[0].status_code != 202):
raise exceptions.RallyException( raise exceptions.RallyException(
_("EncryptionType Deletion Failed")) "EncryptionType Deletion Failed")
def update_encryption_type(self, volume_type, specs): def update_encryption_type(self, volume_type, specs):
"""Update the encryption type information for the specified volume type. """Update the encryption type information for the specified volume type.

View File

@ -109,7 +109,7 @@ class TempestConfigfileManager(object):
uri = os.path.join(cropped_auth_url, "v2.0") uri = os.path.join(cropped_auth_url, "v2.0")
else: else:
# Does Keystone released new version of API ?! # Does Keystone released new version of API ?!
LOG.debug("Discovered keystone versions: %s", versions) LOG.debug("Discovered keystone versions: %s" % versions)
raise exceptions.RallyException("Failed to discover keystone " raise exceptions.RallyException("Failed to discover keystone "
"auth urls.") "auth urls.")

View File

@ -19,7 +19,6 @@ import re
import requests import requests
from six.moves import configparser from six.moves import configparser
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally import exceptions from rally import exceptions
from rally.plugins.openstack.services.image import image from rally.plugins.openstack.services.image import image
@ -130,20 +129,20 @@ class TempestContext(context.VerifierContext):
for role in roles: for role in roles:
if role not in existing_roles: if role not in existing_roles:
LOG.debug("Creating role '%s'.", role) LOG.debug("Creating role '%s'." % role)
self._created_roles.append(keystoneclient.roles.create(role)) self._created_roles.append(keystoneclient.roles.create(role))
def _configure_option(self, section, option, value=None, def _configure_option(self, section, option, value=None,
helper_method=None, *args, **kwargs): helper_method=None, *args, **kwargs):
option_value = self.conf.get(section, option) option_value = self.conf.get(section, option)
if not option_value: if not option_value:
LOG.debug("Option '%s' from '%s' section " LOG.debug("Option '%s' from '%s' section is not configured."
"is not configured.", (option, section)) % (option, section))
if helper_method: if helper_method:
res = helper_method(*args, **kwargs) res = helper_method(*args, **kwargs)
if res: if res:
value = res["name"] if "network" in option else res.id value = res["name"] if "network" in option else res.id
LOG.debug("Setting value '%s' to option '%s'.", (value, option)) LOG.debug("Setting value '%s' to option '%s'." % (value, option))
self.conf.set(section, option, value) self.conf.set(section, option, value)
LOG.debug("Option '{opt}' is configured. " LOG.debug("Option '{opt}' is configured. "
"{opt} = {value}".format(opt=option, value=value)) "{opt} = {value}".format(opt=option, value=value))
@ -155,36 +154,36 @@ class TempestContext(context.VerifierContext):
def _discover_image(self): def _discover_image(self):
LOG.debug("Trying to discover a public image with name matching " LOG.debug("Trying to discover a public image with name matching "
"regular expression '%s'. Note that case insensitive " "regular expression '%s'. Note that case insensitive "
"matching is performed.", conf.CONF.tempest.img_name_regex) "matching is performed." % conf.CONF.tempest.img_name_regex)
image_service = image.Image(self.clients) image_service = image.Image(self.clients)
images = image_service.list_images(status="active", images = image_service.list_images(status="active",
visibility="public") visibility="public")
for image_obj in images: for image_obj in images:
if image_obj.name and re.match(conf.CONF.tempest.img_name_regex, if image_obj.name and re.match(conf.CONF.tempest.img_name_regex,
image_obj.name, re.IGNORECASE): image_obj.name, re.IGNORECASE):
LOG.debug("The following public " LOG.debug("The following public image discovered: '%s'."
"image discovered: '%s'.", image_obj.name) % image_obj.name)
return image_obj return image_obj
LOG.debug("There is no public image with name matching regular " LOG.debug("There is no public image with name matching regular "
"expression '%s'.", conf.CONF.tempest.img_name_regex) "expression '%s'." % conf.CONF.tempest.img_name_regex)
def _download_image_from_source(self, target_path, image=None): def _download_image_from_source(self, target_path, image=None):
if image: if image:
LOG.debug("Downloading image '%s' " LOG.debug("Downloading image '%s' from Glance to %s."
"from Glance to %s.", (image.name, target_path)) % (image.name, target_path))
with open(target_path, "wb") as image_file: with open(target_path, "wb") as image_file:
for chunk in self.clients.glance().images.data(image.id): for chunk in self.clients.glance().images.data(image.id):
image_file.write(chunk) image_file.write(chunk)
else: else:
LOG.debug("Downloading image from %s " LOG.debug("Downloading image from %s to %s."
"to %s.", (conf.CONF.tempest.img_url, target_path)) % (conf.CONF.tempest.img_url, target_path))
try: try:
response = requests.get(conf.CONF.tempest.img_url, stream=True) response = requests.get(conf.CONF.tempest.img_url, stream=True)
except requests.ConnectionError as err: except requests.ConnectionError as err:
msg = _("Failed to download image. " msg = ("Failed to download image. Possibly there is no "
"Possibly there is no connection to Internet. " "connection to Internet. Error: %s."
"Error: %s.") % (str(err) or "unknown") % (str(err) or "unknown"))
raise exceptions.RallyException(msg) raise exceptions.RallyException(msg)
if response.status_code == 200: if response.status_code == 200:
@ -195,10 +194,10 @@ class TempestContext(context.VerifierContext):
image_file.flush() image_file.flush()
else: else:
if response.status_code == 404: if response.status_code == 404:
msg = _("Failed to download image. Image was not found.") msg = "Failed to download image. Image was not found."
else: else:
msg = _("Failed to download image. " msg = ("Failed to download image. HTTP error code %d."
"HTTP error code %d.") % response.status_code % response.status_code)
raise exceptions.RallyException(msg) raise exceptions.RallyException(msg)
LOG.debug("The image has been successfully downloaded!") LOG.debug("The image has been successfully downloaded!")
@ -206,7 +205,7 @@ class TempestContext(context.VerifierContext):
def _download_image(self): def _download_image(self):
image_path = os.path.join(self.data_dir, self.image_name) image_path = os.path.join(self.data_dir, self.image_name)
if os.path.isfile(image_path): if os.path.isfile(image_path):
LOG.debug("Image is already downloaded to %s.", image_path) LOG.debug("Image is already downloaded to %s." % image_path)
return return
if conf.CONF.tempest.img_name_regex: if conf.CONF.tempest.img_name_regex:
@ -220,8 +219,8 @@ class TempestContext(context.VerifierContext):
if conf.CONF.tempest.img_name_regex: if conf.CONF.tempest.img_name_regex:
image_obj = self._discover_image() image_obj = self._discover_image()
if image_obj: if image_obj:
LOG.debug("Using image '%s' (ID = %s) " LOG.debug("Using image '%s' (ID = %s) for the tests."
"for the tests.", (image_obj.name, image_obj.id)) % (image_obj.name, image_obj.id))
return image_obj return image_obj
params = { params = {
@ -234,8 +233,8 @@ class TempestContext(context.VerifierContext):
LOG.debug("Creating image '%s'." % params["image_name"]) LOG.debug("Creating image '%s'." % params["image_name"])
image_service = image.Image(self.clients) image_service = image.Image(self.clients)
image_obj = image_service.create_image(**params) image_obj = image_service.create_image(**params)
LOG.debug("Image '%s' (ID = %s) has been " LOG.debug("Image '%s' (ID = %s) has been successfully created!"
"successfully created!", (image_obj.name, image_obj.id)) % (image_obj.name, image_obj.id))
self._created_images.append(image_obj) self._created_images.append(image_obj)
return image_obj return image_obj
@ -244,7 +243,7 @@ class TempestContext(context.VerifierContext):
novaclient = self.clients.nova() novaclient = self.clients.nova()
LOG.debug("Trying to discover a flavor with the following " LOG.debug("Trying to discover a flavor with the following "
"properties: RAM = %dMB, VCPUs = 1, disk = 0GB.", flv_ram) "properties: RAM = %dMB, VCPUs = 1, disk = 0GB." % flv_ram)
for flavor in novaclient.flavors.list(): for flavor in novaclient.flavors.list():
if (flavor.ram == flv_ram and if (flavor.ram == flv_ram and
flavor.vcpus == 1 and flavor.disk == 0): flavor.vcpus == 1 and flavor.disk == 0):
@ -262,10 +261,10 @@ class TempestContext(context.VerifierContext):
"disk": 0 "disk": 0
} }
LOG.debug("Creating flavor '%s' with the following properties: RAM " LOG.debug("Creating flavor '%s' with the following properties: RAM "
"= %dMB, VCPUs = 1, disk = 0GB.", (params["name"], flv_ram)) "= %dMB, VCPUs = 1, disk = 0GB." % (params["name"], flv_ram))
flavor = novaclient.flavors.create(**params) flavor = novaclient.flavors.create(**params)
LOG.debug("Flavor '%s' (ID = %s) has been " LOG.debug("Flavor '%s' (ID = %s) has been successfully created!"
"successfully created!", (flavor.name, flavor.id)) % (flavor.name, flavor.id))
self._created_flavors.append(flavor) self._created_flavors.append(flavor)
return flavor return flavor
@ -285,14 +284,14 @@ class TempestContext(context.VerifierContext):
def _cleanup_tempest_roles(self): def _cleanup_tempest_roles(self):
keystoneclient = self.clients.keystone() keystoneclient = self.clients.keystone()
for role in self._created_roles: for role in self._created_roles:
LOG.debug("Deleting role '%s'.", role.name) LOG.debug("Deleting role '%s'." % role.name)
keystoneclient.roles.delete(role.id) keystoneclient.roles.delete(role.id)
LOG.debug("Role '%s' has been deleted.", role.name) LOG.debug("Role '%s' has been deleted." % role.name)
def _cleanup_images(self): def _cleanup_images(self):
image_service = image.Image(self.clients) image_service = image.Image(self.clients)
for image_obj in self._created_images: for image_obj in self._created_images:
LOG.debug("Deleting image '%s'.", image_obj.name) LOG.debug("Deleting image '%s'." % image_obj.name)
self.clients.glance().images.delete(image_obj.id) self.clients.glance().images.delete(image_obj.id)
task_utils.wait_for_status( task_utils.wait_for_status(
image_obj, ["deleted", "pending_delete"], image_obj, ["deleted", "pending_delete"],
@ -301,15 +300,15 @@ class TempestContext(context.VerifierContext):
timeout=conf.CONF.benchmark.glance_image_delete_timeout, timeout=conf.CONF.benchmark.glance_image_delete_timeout,
check_interval=conf.CONF.benchmark. check_interval=conf.CONF.benchmark.
glance_image_delete_poll_interval) glance_image_delete_poll_interval)
LOG.debug("Image '%s' has been deleted.", image_obj.name) LOG.debug("Image '%s' has been deleted." % image_obj.name)
self._remove_opt_value_from_config("compute", image_obj.id) self._remove_opt_value_from_config("compute", image_obj.id)
def _cleanup_flavors(self): def _cleanup_flavors(self):
novaclient = self.clients.nova() novaclient = self.clients.nova()
for flavor in self._created_flavors: for flavor in self._created_flavors:
LOG.debug("Deleting flavor '%s'.", flavor.name) LOG.debug("Deleting flavor '%s'." % flavor.name)
novaclient.flavors.delete(flavor.id) novaclient.flavors.delete(flavor.id)
LOG.debug("Flavor '%s' has been deleted.", flavor.name) LOG.debug("Flavor '%s' has been deleted." % flavor.name)
self._remove_opt_value_from_config("compute", flavor.id) self._remove_opt_value_from_config("compute", flavor.id)
self._remove_opt_value_from_config("orchestration", flavor.id) self._remove_opt_value_from_config("orchestration", flavor.id)
@ -325,6 +324,6 @@ class TempestContext(context.VerifierContext):
for option, value in self.conf.items(section): for option, value in self.conf.items(section):
if opt_value == value: if opt_value == value:
LOG.debug("Removing value '%s' of option '%s' " LOG.debug("Removing value '%s' of option '%s' "
"from Tempest config file.", (opt_value, option)) "from Tempest config file." % (opt_value, option))
self.conf.set(section, option, "") self.conf.set(section, option, "")
LOG.debug("Value '%s' has been removed.", opt_value) LOG.debug("Value '%s' has been removed." % opt_value)

View File

@ -17,7 +17,6 @@ import re
import shutil import shutil
import subprocess import subprocess
from rally.common.i18n import _LE
from rally.common import yamlutils as yaml from rally.common import yamlutils as yaml
from rally import exceptions from rally import exceptions
from rally.plugins.common.verification import testr from rally.plugins.common.verification import testr
@ -128,8 +127,8 @@ class TempestManager(testr.TestrLauncher):
"""Install a Tempest plugin.""" """Install a Tempest plugin."""
if extra_settings: if extra_settings:
raise NotImplementedError( raise NotImplementedError(
_LE("'%s' verifiers don't support extra installation settings " "'%s' verifiers don't support extra installation settings "
"for extensions.") % self.get_name()) "for extensions." % self.get_name())
version = version or "master" version = version or "master"
egg = re.sub("\.git$", "", os.path.basename(source.strip("/"))) egg = re.sub("\.git$", "", os.path.basename(source.strip("/")))
full_source = "git+{0}@{1}#egg={2}".format(source, version, egg) full_source = "git+{0}@{1}#egg={2}".format(source, version, egg)

View File

@ -18,7 +18,6 @@ import abc
import netaddr import netaddr
import six import six
from rally.common.i18n import _
from rally.common import logging from rally.common import logging
from rally.common import utils from rally.common import utils
from rally import consts from rally import consts
@ -44,13 +43,13 @@ def generate_cidr(start_cidr="10.2.0.0/24"):
:returns: next available CIDR str :returns: next available CIDR str
""" """
cidr = str(netaddr.IPNetwork(start_cidr).next(next(cidr_incr))) cidr = str(netaddr.IPNetwork(start_cidr).next(next(cidr_incr)))
LOG.debug("CIDR generated: %s", cidr) LOG.debug("CIDR generated: %s" % cidr)
return cidr return cidr
class NetworkWrapperException(exceptions.RallyException): class NetworkWrapperException(exceptions.RallyException):
error_code = 532 error_code = 532
msg_fmt = _("%(message)s") msg_fmt = "%(message)s"
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
@ -373,7 +372,7 @@ class NeutronWrapper(NetworkWrapper):
if any(ext.get("alias") == extension for ext in extensions): if any(ext.get("alias") == extension for ext in extensions):
return True, "" return True, ""
return False, _("Neutron driver does not support %s") % (extension) return False, "Neutron driver does not support %s" % extension
def wrap(clients, owner, config=None): def wrap(clients, owner, config=None):
@ -396,4 +395,4 @@ def wrap(clients, owner, config=None):
if consts.Service.NEUTRON in services.values(): if consts.Service.NEUTRON in services.values():
return NeutronWrapper(clients, owner, config=config) return NeutronWrapper(clients, owner, config=config)
LOG.warning(_("NovaNetworkWrapper is deprecated since 0.9.0")) LOG.warning("NovaNetworkWrapper is deprecated since 0.9.0")

View File

@ -92,7 +92,7 @@ class SeekAndDestroyTestCase(test.TestCase):
mock_resource.delete.assert_called_once_with() mock_resource.delete.assert_called_once_with()
self.assertEqual(4, mock_resource.is_deleted.call_count) self.assertEqual(4, mock_resource.is_deleted.call_count)
self.assertEqual(5, mock_log.warning.call_count) self.assertEqual(1, mock_log.warning.call_count)
self.assertEqual(4, mock_log.exception.call_count) self.assertEqual(4, mock_log.exception.call_count)
def _manager(self, list_side_effect, **kw): def _manager(self, list_side_effect, **kw):

View File

@ -169,15 +169,16 @@ class ImageGeneratorTestCase(test.ScenarioTestCase):
min_disk=d_min_disk, min_disk=d_min_disk,
min_ram=d_min_ram min_ram=d_min_ram
) )
self.assertEqual( expected_warns = [
[mock.call("The 'image_type' argument is deprecated since " mock.call("The 'image_type' argument is deprecated since "
"Rally 0.10.0, use disk_format arguments instead."), "Rally 0.10.0, use disk_format argument instead"),
mock.call("The 'image_container' argument is deprecated since " mock.call("The 'image_container' argument is deprecated since "
"Rally 0.10.0; use container_format arguments instead"), "Rally 0.10.0; use container_format argument instead"),
mock.call("The 'image_args' argument is deprecated since " mock.call("The 'image_args' argument is deprecated since "
"Rally 0.10.0; specify exact arguments in a root " "Rally 0.10.0; specify arguments in a root "
"section of context instead.")], "section of context instead")]
mock_log.warning.call_args_list)
self.assertEqual(expected_warns, mock_log.warning.call_args_list)
mock_image.return_value.create_image.reset_mock() mock_image.return_value.create_image.reset_mock()
mock_log.warning.reset_mock() mock_log.warning.reset_mock()
@ -211,15 +212,7 @@ class ImageGeneratorTestCase(test.ScenarioTestCase):
) )
# No matter will be deprecated arguments used or not, if they are # No matter will be deprecated arguments used or not, if they are
# specified, warning message should be printed. # specified, warning message should be printed.
self.assertEqual( self.assertEqual(expected_warns, mock_log.warning.call_args_list)
[mock.call("The 'image_type' argument is deprecated since "
"Rally 0.10.0, use disk_format arguments instead."),
mock.call("The 'image_container' argument is deprecated since "
"Rally 0.10.0; use container_format arguments instead"),
mock.call("The 'image_args' argument is deprecated since "
"Rally 0.10.0; specify exact arguments in a root "
"section of context instead.")],
mock_log.warning.call_args_list)
@ddt.data( @ddt.data(
{"admin": True}, {"admin": True},