Logging audit for trove/common module
Adjust log messages to conform to logging standards. Cleanup some messages that were unclear. Change-Id: I0bed14a98477d7e2b83e43ce020b6b41e5ac8fa8 Partial-Bug: #1324206
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
"""Routines for configuring Trove."""
|
||||
|
||||
from oslo.config import cfg
|
||||
from trove.openstack.common import log as logging
|
||||
|
||||
import os.path
|
||||
|
||||
@@ -29,8 +28,6 @@ path_opts = [
|
||||
help='Directory where the trove python module is installed.'),
|
||||
]
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
common_opts = [
|
||||
cfg.StrOpt('sql_connection',
|
||||
default='sqlite:///trove_test.sqlite',
|
||||
@@ -365,7 +362,7 @@ cassandra_opts = [
|
||||
help='Timeout to wait for a guest to become active.'),
|
||||
]
|
||||
|
||||
#Couchbase
|
||||
# Couchbase
|
||||
couchbase_group = cfg.OptGroup(
|
||||
'couchbase', title='Couchbase options',
|
||||
help="Oslo option group designed for Couchbase datastore")
|
||||
|
||||
@@ -39,8 +39,8 @@ def do_configs_require_restart(overrides, datastore_manager='mysql'):
|
||||
LOG.debug("rules?: %s" % rules)
|
||||
for key in overrides.keys():
|
||||
rule = _get_item(key, rules['configuration-parameters'])
|
||||
LOG.debug("checking the rule: %s" % rule)
|
||||
if rule.get('restart_required'):
|
||||
LOG.debug("rule requires restart: %s" % rule)
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -51,7 +51,7 @@ def get_validation_rules(datastore_manager='mysql'):
|
||||
template = ENV.get_template(config_location)
|
||||
return json.loads(template.render())
|
||||
except Exception:
|
||||
msg = "This operation is not supported for this datastore at this time"
|
||||
msg = "This operation is not supported by this datastore at this time."
|
||||
LOG.exception(msg)
|
||||
raise exception.UnprocessableEntity(message=msg)
|
||||
|
||||
@@ -81,7 +81,6 @@ class MySQLConfParser(object):
|
||||
elif line_clean.startswith('[') and line_clean.endswith(']'):
|
||||
ret.append(line_clean)
|
||||
elif line_clean and "=" not in line_clean:
|
||||
LOG.debug("fixing line without '=' in it: %s" % line_clean)
|
||||
ret.append(line_clean + " = 1")
|
||||
else:
|
||||
ret.append(line_clean)
|
||||
|
||||
@@ -100,8 +100,8 @@ def __setup_remote_pydev_debug_safe(pydev_debug_host=None,
|
||||
pydev_debug_port=pydev_debug_port,
|
||||
pydev_path=pydev_path)
|
||||
except Exception as e:
|
||||
LOG.info("Cann't connect to remote debug server. Continue working in "
|
||||
"standard mode. Error: %s", e)
|
||||
LOG.warn(_("Can't connect to remote debug server. Continuing to "
|
||||
"work in standard mode. Error: %s."), e)
|
||||
return False
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ def __setup_remote_pydev_debug(pydev_debug_host=None, pydev_debug_port=None,
|
||||
import pydevd
|
||||
LOG.debug("pydevd module was imported from system path")
|
||||
except ImportError:
|
||||
LOG.debug("Cann't load pydevd module from system path. Try load it "
|
||||
LOG.debug("Can't load pydevd module from system path. Try loading it "
|
||||
"from pydev_path: %s", pydev_path)
|
||||
assert pydev_path, "pydev_path is not set"
|
||||
if pydev_path not in sys.path:
|
||||
|
||||
@@ -52,17 +52,17 @@ class TroveError(openstack_exception.OpenstackException):
|
||||
|
||||
class DBConstraintError(TroveError):
|
||||
|
||||
message = _("Failed to save %(model_name)s because: %(error)s")
|
||||
message = _("Failed to save %(model_name)s because: %(error)s.")
|
||||
|
||||
|
||||
class InvalidRPCConnectionReuse(TroveError):
|
||||
|
||||
message = _("Invalid RPC Connection Reuse")
|
||||
message = _("Invalid RPC Connection Reuse.")
|
||||
|
||||
|
||||
class NotFound(TroveError):
|
||||
|
||||
message = _("Resource %(uuid)s cannot be found")
|
||||
message = _("Resource %(uuid)s cannot be found.")
|
||||
|
||||
|
||||
class CapabilityNotFound(NotFound):
|
||||
@@ -77,7 +77,7 @@ class CapabilityDisabled(TroveError):
|
||||
|
||||
class FlavorNotFound(TroveError):
|
||||
|
||||
message = _("Resource %(uuid)s cannot be found")
|
||||
message = _("Resource %(uuid)s cannot be found.")
|
||||
|
||||
|
||||
class UserNotFound(NotFound):
|
||||
@@ -146,7 +146,7 @@ class DatastoreOperationNotSupported(TroveError):
|
||||
|
||||
class NoUniqueMatch(TroveError):
|
||||
|
||||
message = _("Multiple matches found for '%(name)s', i"
|
||||
message = _("Multiple matches found for '%(name)s', "
|
||||
"use an UUID to be more specific.")
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ class OverLimit(TroveError):
|
||||
|
||||
class QuotaExceeded(TroveError):
|
||||
|
||||
message = _("Quota exceeded for resources: %(overs)s")
|
||||
message = _("Quota exceeded for resources: %(overs)s.")
|
||||
|
||||
|
||||
class VolumeQuotaExceeded(QuotaExceeded):
|
||||
@@ -185,7 +185,7 @@ class BadRequest(TroveError):
|
||||
|
||||
class MissingKey(BadRequest):
|
||||
|
||||
message = _("Required element/key - %(key)s was not specified")
|
||||
message = _("Required element/key - %(key)s was not specified.")
|
||||
|
||||
|
||||
class DatabaseAlreadyExists(BadRequest):
|
||||
@@ -208,18 +208,18 @@ class InstanceAssignedToConfiguration(BadRequest):
|
||||
|
||||
class UnprocessableEntity(TroveError):
|
||||
|
||||
message = _("Unable to process the contained request")
|
||||
message = _("Unable to process the contained request.")
|
||||
|
||||
|
||||
class CannotResizeToSameSize(TroveError):
|
||||
|
||||
message = _("When resizing, instances must change size!")
|
||||
message = _("No change was requested in the size of the instance.")
|
||||
|
||||
|
||||
class VolumeAttachmentsNotFound(NotFound):
|
||||
|
||||
message = _("Cannot find the volumes attached to compute "
|
||||
"instance %(server_id)")
|
||||
"instance %(server_id).")
|
||||
|
||||
|
||||
class VolumeCreationFailure(TroveError):
|
||||
@@ -255,7 +255,7 @@ class TaskManagerError(TroveError):
|
||||
|
||||
class BadValue(TroveError):
|
||||
|
||||
message = _("Value could not be converted: %(msg)s")
|
||||
message = _("Value could not be converted: %(msg)s.")
|
||||
|
||||
|
||||
class PollTimeOut(TroveError):
|
||||
@@ -270,22 +270,22 @@ class Forbidden(TroveError):
|
||||
|
||||
class InvalidModelError(TroveError):
|
||||
|
||||
message = _("The following values are invalid: %(errors)s")
|
||||
message = _("The following values are invalid: %(errors)s.")
|
||||
|
||||
|
||||
class ModelNotFoundError(NotFound):
|
||||
|
||||
message = _("Not Found")
|
||||
message = _("Not Found.")
|
||||
|
||||
|
||||
class UpdateGuestError(TroveError):
|
||||
|
||||
message = _("Failed to update instances")
|
||||
message = _("Failed to update instances.")
|
||||
|
||||
|
||||
class ConfigNotFound(NotFound):
|
||||
|
||||
message = _("Config file not found")
|
||||
message = _("Config file not found.")
|
||||
|
||||
|
||||
class PasteAppNotFound(NotFound):
|
||||
@@ -294,7 +294,7 @@ class PasteAppNotFound(NotFound):
|
||||
|
||||
|
||||
class QuotaNotFound(NotFound):
|
||||
message = _("Quota could not be found")
|
||||
message = _("Quota could not be found.")
|
||||
|
||||
|
||||
class TenantQuotaNotFound(QuotaNotFound):
|
||||
@@ -306,7 +306,7 @@ class QuotaResourceUnknown(QuotaNotFound):
|
||||
|
||||
|
||||
class BackupUploadError(TroveError):
|
||||
message = _("Unable to upload Backup onto swift")
|
||||
message = _("Unable to upload Backup to swift.")
|
||||
|
||||
|
||||
class BackupDownloadError(TroveError):
|
||||
@@ -314,11 +314,11 @@ class BackupDownloadError(TroveError):
|
||||
|
||||
|
||||
class BackupCreationError(TroveError):
|
||||
message = _("Unable to create Backup")
|
||||
message = _("Unable to create Backup.")
|
||||
|
||||
|
||||
class BackupUpdateError(TroveError):
|
||||
message = _("Unable to update Backup table in db")
|
||||
message = _("Unable to update Backup table in database.")
|
||||
|
||||
|
||||
class SecurityGroupCreationError(TroveError):
|
||||
@@ -344,14 +344,14 @@ class SecurityGroupRuleDeletionError(TroveError):
|
||||
class MalformedSecurityGroupRuleError(TroveError):
|
||||
|
||||
message = _("Error creating security group rules."
|
||||
" Malformed port(s). Port(s) is not integer."
|
||||
" FromPort = %(from)s greater than ToPort = %(to)s")
|
||||
" Malformed port(s). Port must be an integer."
|
||||
" FromPort = %(from)s greater than ToPort = %(to)s.")
|
||||
|
||||
|
||||
class BackupNotCompleteError(TroveError):
|
||||
|
||||
message = _("Unable to create instance because backup %(backup_id)s is "
|
||||
"not completed")
|
||||
"not completed.")
|
||||
|
||||
|
||||
class BackupFileNotFound(NotFound):
|
||||
@@ -362,7 +362,7 @@ class BackupFileNotFound(NotFound):
|
||||
class BackupDatastoreMismatchError(TroveError):
|
||||
message = _("The datastore from which the backup was taken, "
|
||||
"%(datastore1)s, does not match the destination"
|
||||
" datastore of %(datastore2)s")
|
||||
" datastore of %(datastore2)s.")
|
||||
|
||||
|
||||
class SwiftAuthError(TroveError):
|
||||
@@ -393,12 +393,12 @@ class RestoreBackupIntegrityError(TroveError):
|
||||
|
||||
|
||||
class ConfigKeyNotFound(NotFound):
|
||||
message = _("%(key)s is not a supported configuration parameter")
|
||||
message = _("%(key)s is not a supported configuration parameter.")
|
||||
|
||||
|
||||
class NoConfigParserFound(NotFound):
|
||||
message = _("No configuration parser found for datastore "
|
||||
"%(datastore_manager)s")
|
||||
"%(datastore_manager)s.")
|
||||
|
||||
|
||||
class ConfigurationDatastoreNotMatchInstance(TroveError):
|
||||
@@ -410,7 +410,7 @@ class ConfigurationDatastoreNotMatchInstance(TroveError):
|
||||
|
||||
class ConfigurationParameterDeleted(TroveError):
|
||||
message = _("%(parameter_name)s parameter can no longer be "
|
||||
" set as of %(parameter_deleted_at)s")
|
||||
" set as of %(parameter_deleted_at)s.")
|
||||
|
||||
|
||||
class ConfigurationAlreadyAttached(TroveError):
|
||||
@@ -420,7 +420,7 @@ class ConfigurationAlreadyAttached(TroveError):
|
||||
|
||||
class InvalidInstanceState(TroveError):
|
||||
message = _("The operation you have requested cannot be executed because "
|
||||
"the instance status is currently: %(status)s")
|
||||
"the instance status is currently: %(status)s.")
|
||||
|
||||
|
||||
class RegionAmbiguity(TroveError):
|
||||
@@ -432,11 +432,11 @@ class RegionAmbiguity(TroveError):
|
||||
|
||||
class NoServiceEndpoint(TroveError):
|
||||
"""Could not find requested endpoint in Service Catalog."""
|
||||
message = ("Endpoint not found for service_type=%(service_type)s, "
|
||||
"endpoint_type=%(endpoint_type)s, "
|
||||
"endpoint_region=%(endpoint_region)s")
|
||||
message = _("Endpoint not found for service_type=%(service_type)s, "
|
||||
"endpoint_type=%(endpoint_type)s, "
|
||||
"endpoint_region=%(endpoint_region)s.")
|
||||
|
||||
|
||||
class EmptyCatalog(NoServiceEndpoint):
|
||||
"""The service catalog is empty."""
|
||||
message = 'Empty catalog'
|
||||
message = _("Empty catalog.")
|
||||
|
||||
@@ -98,7 +98,7 @@ def factory(global_config, **local_config):
|
||||
def _factory(app):
|
||||
extensions.DEFAULT_XMLNS = "http://docs.openstack.org/trove"
|
||||
if not os.path.exists(CONF.api_extensions_path):
|
||||
LOG.warning(_('API extensions path does not exist: %s'),
|
||||
LOG.warning(_('API extensions path does not exist: %s.'),
|
||||
CONF.api_extensions_path)
|
||||
ext_mgr = extensions.ExtensionManager(CONF.api_extensions_path)
|
||||
return TroveExtensionMiddleware(app, ext_mgr)
|
||||
|
||||
@@ -15,13 +15,9 @@
|
||||
|
||||
"""Model classes that form the core of instances functionality."""
|
||||
|
||||
from trove.openstack.common import log as logging
|
||||
from trove.common import remote
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ModelBase(object):
|
||||
"""
|
||||
An object which can be stored in the database.
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
from trove.common import cfg
|
||||
from trove.common import exception
|
||||
from trove.openstack.common.importutils import import_class
|
||||
from trove.openstack.common import log as logging
|
||||
|
||||
from cinderclient.v2 import client as CinderClient
|
||||
from heatclient.v1 import client as HeatClient
|
||||
@@ -29,8 +28,6 @@ CONF = cfg.CONF
|
||||
PROXY_AUTH_URL = CONF.trove_auth_url
|
||||
USE_SNET = CONF.backup_use_snet
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def normalize_url(url):
|
||||
"""Adds trailing slash if necessary."""
|
||||
|
||||
@@ -20,6 +20,7 @@ from trove.common import configurations
|
||||
from trove.common import exception
|
||||
from trove.common import utils
|
||||
from trove.openstack.common import log as logging
|
||||
from trove.openstack.common.gettextutils import _
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -53,10 +54,10 @@ class SingleInstanceConfigTemplate(object):
|
||||
"""
|
||||
self.flavor_dict = flavor_dict
|
||||
self.datastore_version = datastore_version
|
||||
#TODO(tim.simpson): The current definition of datastore_version is a
|
||||
# bit iffy and I believe will change soon, so I'm
|
||||
# creating a dictionary here for jinja to consume
|
||||
# rather than pass in the datastore version object.
|
||||
# TODO(tim.simpson): The current definition of datastore_version is a
|
||||
# bit iffy and I believe will change soon, so I'm
|
||||
# creating a dictionary here for jinja to consume
|
||||
# rather than pass in the datastore version object.
|
||||
self.datastore_dict = {
|
||||
'name': self.datastore_version.datastore_name,
|
||||
'manager': self.datastore_version.manager,
|
||||
@@ -118,6 +119,7 @@ def load_heat_template(datastore_manager):
|
||||
template_obj = ENV.get_template(template_filename)
|
||||
return template_obj
|
||||
except jinja2.TemplateNotFound:
|
||||
msg = "Missing heat template for %s" % datastore_manager
|
||||
msg = _("Missing heat template for %(s_datastore_manager)s.") % (
|
||||
{"s_datastore_manager": datastore_manager})
|
||||
LOG.error(msg)
|
||||
raise exception.TroveError(msg)
|
||||
|
||||
@@ -218,7 +218,7 @@ class LoopingCall(object):
|
||||
self.stop()
|
||||
done.send(e.retvalue)
|
||||
except Exception:
|
||||
LOG.exception(_('in looping call'))
|
||||
LOG.exception(_('In looping call.'))
|
||||
done.send_exception(*sys.exc_info())
|
||||
return
|
||||
else:
|
||||
@@ -273,26 +273,18 @@ def get_id_from_href(href):
|
||||
def execute_with_timeout(*args, **kwargs):
|
||||
time = kwargs.pop('timeout', 30)
|
||||
|
||||
def cb_timeout():
|
||||
msg = (_("Time out after waiting"
|
||||
" %(time)s seconds when running proc: %(args)s"
|
||||
" %(kwargs)s") % {'time': time, 'args': args,
|
||||
'kwargs': kwargs})
|
||||
LOG.error(msg)
|
||||
raise exception.ProcessExecutionError(msg)
|
||||
|
||||
timeout = Timeout(time)
|
||||
try:
|
||||
return execute(*args, **kwargs)
|
||||
except Timeout as t:
|
||||
if t is not timeout:
|
||||
LOG.error("Timeout reached but not from our timeout. This is bad!")
|
||||
LOG.error(_("Got a timeout but not the one expected."))
|
||||
raise
|
||||
else:
|
||||
msg = (_("Time out after waiting "
|
||||
"%(time)s seconds when running proc: %(args)s"
|
||||
" %(kwargs)s") % {'time': time, 'args': args,
|
||||
'kwargs': kwargs})
|
||||
" %(kwargs)s.") % {'time': time, 'args': args,
|
||||
'kwargs': kwargs})
|
||||
LOG.error(msg)
|
||||
raise exception.ProcessExecutionError(msg)
|
||||
finally:
|
||||
|
||||
@@ -267,7 +267,7 @@ class Resource(openstack_wsgi.Resource):
|
||||
LOG.exception(exception_uuid + ": " + str(error))
|
||||
return Fault(webob.exc.HTTPInternalServerError(
|
||||
"Internal Server Error. Please keep this ID to help us "
|
||||
"figure out what went wrong: (%s)" % exception_uuid,
|
||||
"figure out what went wrong: (%s)." % exception_uuid,
|
||||
request=request))
|
||||
|
||||
def _get_http_error(self, error):
|
||||
@@ -301,7 +301,7 @@ class Resource(openstack_wsgi.Resource):
|
||||
# If action_result is not a Fault then there really was a
|
||||
# serialization error which we log. Otherwise return the Fault.
|
||||
if not isinstance(action_result, Fault):
|
||||
LOG.exception("unserializable result detected.")
|
||||
LOG.exception(_("Unserializable result detected."))
|
||||
raise
|
||||
return action_result
|
||||
|
||||
@@ -467,7 +467,8 @@ class Fault(webob.exc.HTTPException):
|
||||
name = exc.__class__.__name__
|
||||
if name in named_exceptions:
|
||||
return named_exceptions[name]
|
||||
# If the exception isn't in our list, at least strip off the
|
||||
|
||||
# If the exception isn't in our list, at least strip off the
|
||||
# HTTP from the name, and then drop the case on the first letter.
|
||||
name = name.split("HTTP").pop()
|
||||
name = name[:1].lower() + name[1:]
|
||||
@@ -561,7 +562,7 @@ class FaultWrapper(openstack_wsgi.Middleware):
|
||||
return resp
|
||||
return resp
|
||||
except Exception as ex:
|
||||
LOG.exception(_("Caught error: %s"), unicode(ex))
|
||||
LOG.exception(_("Caught error: %s."), unicode(ex))
|
||||
exc = webob.exc.HTTPInternalServerError()
|
||||
return Fault(exc)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user