Lead log spelling to the one style

Since log is a constant it should be in uppercase everywhere

Change-Id: Ideee9dd5a3f22962b7d53c5790de93bf26f2ea64
This commit is contained in:
Ekaterina Fedorova 2014-03-18 14:49:04 +04:00
parent 8e6a40e647
commit 9940c2f571
11 changed files with 74 additions and 76 deletions

View File

@ -18,8 +18,8 @@ import muranoapi.context
import muranoapi.openstack.common.log as logging
from muranoapi.openstack.common import wsgi
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
class ContextMiddleware(wsgi.Middleware):

View File

@ -23,8 +23,7 @@ from muranoapi.openstack.common.gettextutils import _ # noqa
from muranoapi.openstack.common import log as logging
from muranoapi.openstack.common import wsgi
log = logging.getLogger(__name__)
LOG = logging.getLogger(__name__)
API_NAME = 'Deployments'
@ -72,11 +71,11 @@ class Controller(object):
def verify_and_get_env(db_session, environment_id, request):
environment = db_session.query(models.Environment).get(environment_id)
if not environment:
log.info(_('Environment with id {0} not found'.format(environment_id)))
LOG.info(_('Environment with id {0} not found'.format(environment_id)))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
log.info(_('User is not authorized to access this tenant resources.'))
LOG.info(_('User is not authorized to access this tenant resources.'))
raise exc.HTTPUnauthorized
return environment
@ -84,10 +83,10 @@ def verify_and_get_env(db_session, environment_id, request):
def verify_and_get_deployment(db_session, environment_id, deployment_id):
deployment = db_session.query(models.Deployment).get(deployment_id)
if not deployment:
log.info(_('Deployment with id {0} not found'.format(deployment_id)))
LOG.info(_('Deployment with id {0} not found'.format(deployment_id)))
raise exc.HTTPNotFound
if deployment.environment_id != environment_id:
log.info(_('Deployment with id {0} not found'
LOG.info(_('Deployment with id {0} not found'
' in environment {1}'.format(deployment_id,
environment_id)))
raise exc.HTTPBadRequest

View File

@ -26,8 +26,8 @@ from muranoapi.openstack.common.gettextutils import _ # noqa
from muranoapi.openstack.common import log as logging
from muranoapi.openstack.common import wsgi
LOG = logging.getLogger(__name__)
log = logging.getLogger(__name__)
API_NAME = 'Environments'
@ -35,7 +35,7 @@ class Controller(object):
@statistics.stats_count(API_NAME, 'Index')
def index(self, request):
log.debug(_('Environments:List'))
LOG.debug(_('Environments:List'))
#Only environments from same tenant as user should be returned
filters = {'tenant_id': request.context.tenant}
@ -46,7 +46,7 @@ class Controller(object):
@statistics.stats_count(API_NAME, 'Create')
def create(self, request, body):
log.debug(_('Environments:Create <Body {0}>'.format(body)))
LOG.debug(_('Environments:Create <Body {0}>'.format(body)))
environment = envs.EnvironmentServices.create(body.copy(),
request.context.tenant)
@ -55,18 +55,18 @@ class Controller(object):
@statistics.stats_count(API_NAME, 'Show')
def show(self, request, environment_id):
log.debug(_('Environments:Show <Id: {0}>'.format(environment_id)))
LOG.debug(_('Environments:Show <Id: {0}>'.format(environment_id)))
session = db_session.get_session()
environment = session.query(models.Environment).get(environment_id)
if environment is None:
log.info('Environment <EnvId {0}> is not found'
LOG.info('Environment <EnvId {0}> is not found'
.format(environment_id))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
log.info(_('User is not authorized to access '
LOG.info(_('User is not authorized to access '
'this tenant resources.'))
raise exc.HTTPUnauthorized
@ -85,19 +85,19 @@ class Controller(object):
@statistics.stats_count(API_NAME, 'Update')
def update(self, request, environment_id, body):
log.debug(_('Environments:Update <Id: {0}, '
LOG.debug(_('Environments:Update <Id: {0}, '
'Body: {1}>'.format(environment_id, body)))
session = db_session.get_session()
environment = session.query(models.Environment).get(environment_id)
if environment is None:
log.info(_('Environment <EnvId {0}> is not '
LOG.info(_('Environment <EnvId {0}> is not '
'found'.format(environment_id)))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
log.info(_('User is not authorized to access '
LOG.info(_('User is not authorized to access '
'this tenant resources.'))
raise exc.HTTPUnauthorized
@ -108,18 +108,18 @@ class Controller(object):
@statistics.stats_count(API_NAME, 'Delete')
def delete(self, request, environment_id):
log.debug(_('Environments:Delete <Id: {0}>'.format(environment_id)))
LOG.debug(_('Environments:Delete <Id: {0}>'.format(environment_id)))
unit = db_session.get_session()
environment = unit.query(models.Environment).get(environment_id)
if environment is None:
log.info(_('Environment <EnvId {0}> '
LOG.info(_('Environment <EnvId {0}> '
'is not found'.format(environment_id)))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
log.info(_('User is not authorized to access '
LOG.info(_('User is not authorized to access '
'this tenant resources.'))
raise exc.HTTPUnauthorized

View File

@ -25,7 +25,7 @@ from muranoapi.openstack.common import wsgi
from muranoapi import utils
from muranocommon.helpers import token_sanitizer
log = logging.getLogger(__name__)
LOG = logging.getLogger(__name__)
API_NAME = 'Services'
@ -48,7 +48,7 @@ class Controller(object):
@utils.verify_env
@normalize_path
def get(self, request, environment_id, path):
log.debug(_('Services:Get <EnvId: {0}, '
LOG.debug(_('Services:Get <EnvId: {0}, '
'Path: {1}>'.format(environment_id, path)))
session_id = None
@ -69,7 +69,7 @@ class Controller(object):
@normalize_path
def post(self, request, environment_id, path, body):
secure_data = token_sanitizer.TokenSanitizer().sanitize(body)
log.debug(_('Services:Post <EnvId: {0}, Path: {2}, '
LOG.debug(_('Services:Post <EnvId: {0}, Path: {2}, '
'Body: {1}>'.format(environment_id, secure_data, path)))
post_data = core_services.CoreServices.post_data
@ -85,7 +85,7 @@ class Controller(object):
@utils.verify_env
@normalize_path
def put(self, request, environment_id, path, body):
log.debug(_('Services:Put <EnvId: {0}, Path: {2}, '
LOG.debug(_('Services:Put <EnvId: {0}, Path: {2}, '
'Body: {1}>'.format(environment_id, body, path)))
put_data = core_services.CoreServices.put_data
@ -102,7 +102,7 @@ class Controller(object):
@utils.verify_env
@normalize_path
def delete(self, request, environment_id, path):
log.debug(_('Services:Put <EnvId: {0}, '
LOG.debug(_('Services:Put <EnvId: {0}, '
'Path: {1}>'.format(environment_id, path)))
delete_data = core_services.CoreServices.delete_data

View File

@ -25,32 +25,32 @@ from muranoapi.openstack.common import log as logging
from muranoapi.openstack.common import wsgi
log = logging.getLogger(__name__)
LOG = logging.getLogger(__name__)
API_NAME = 'Sessions'
class Controller(object):
@statistics.stats_count(API_NAME, 'Create')
def configure(self, request, environment_id):
log.debug(_('Session:Configure <EnvId: {0}>'.format(environment_id)))
LOG.debug(_('Session:Configure <EnvId: {0}>'.format(environment_id)))
unit = db_session.get_session()
environment = unit.query(models.Environment).get(environment_id)
if environment is None:
log.info(_('Environment <EnvId {0}> '
LOG.info(_('Environment <EnvId {0}> '
'is not found'.format(environment_id)))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
log.info(_('User is not authorized to access '
LOG.info(_('User is not authorized to access '
'this tenant resources.'))
raise exc.HTTPUnauthorized
# no new session can be opened if environment has deploying status
env_status = envs.EnvironmentServices.get_status(environment_id)
if env_status == envs.EnvironmentStatus.deploying:
log.info(_('Could not open session for environment <EnvId: {0}>,'
LOG.info(_('Could not open session for environment <EnvId: {0}>,'
'environment has deploying '
'status.'.format(environment_id)))
raise exc.HTTPForbidden()
@ -62,29 +62,29 @@ class Controller(object):
@statistics.stats_count(API_NAME, 'Index')
def show(self, request, environment_id, session_id):
log.debug(_('Session:Show <SessionId: {0}>'.format(session_id)))
LOG.debug(_('Session:Show <SessionId: {0}>'.format(session_id)))
unit = db_session.get_session()
session = unit.query(models.Session).get(session_id)
if session is None:
log.error(_('Session <SessionId {0}> '
LOG.error(_('Session <SessionId {0}> '
'is not found'.format(session_id)))
raise exc.HTTPNotFound()
if session.environment_id != environment_id:
log.error(_('Session <SessionId {0}> is not tied with Environment '
LOG.error(_('Session <SessionId {0}> is not tied with Environment '
'<EnvId {1}>'.format(session_id, environment_id)))
raise exc.HTTPNotFound()
user_id = request.context.user
if session.user_id != user_id:
log.error(_('User <UserId {0}> is not authorized to access session'
LOG.error(_('User <UserId {0}> is not authorized to access session'
'<SessionId {1}>.'.format(user_id, session_id)))
raise exc.HTTPUnauthorized()
if not sessions.SessionServices.validate(session):
log.error(_('Session <SessionId {0}> '
LOG.error(_('Session <SessionId {0}> '
'is invalid'.format(session_id)))
raise exc.HTTPForbidden()
@ -92,29 +92,29 @@ class Controller(object):
@statistics.stats_count(API_NAME, 'Delete')
def delete(self, request, environment_id, session_id):
log.debug(_('Session:Delete <SessionId: {0}>'.format(session_id)))
LOG.debug(_('Session:Delete <SessionId: {0}>'.format(session_id)))
unit = db_session.get_session()
session = unit.query(models.Session).get(session_id)
if session is None:
log.error(_('Session <SessionId {0}> '
LOG.error(_('Session <SessionId {0}> '
'is not found'.format(session_id)))
raise exc.HTTPNotFound()
if session.environment_id != environment_id:
log.error(_('Session <SessionId {0}> is not tied with Environment '
LOG.error(_('Session <SessionId {0}> is not tied with Environment '
'<EnvId {1}>'.format(session_id, environment_id)))
raise exc.HTTPNotFound()
user_id = request.context.user
if session.user_id != user_id:
log.error(_('User <UserId {0}> is not authorized to access session'
LOG.error(_('User <UserId {0}> is not authorized to access session'
'<SessionId {1}>.'.format(user_id, session_id)))
raise exc.HTTPUnauthorized()
if session.state == sessions.SessionState.deploying:
log.error(_('Session <SessionId: {0}> is in deploying state and '
LOG.error(_('Session <SessionId: {0}> is in deploying state and '
'could not be deleted'.format(session_id)))
raise exc.HTTPForbidden()
@ -125,28 +125,28 @@ class Controller(object):
@statistics.stats_count(API_NAME, 'Deploy')
def deploy(self, request, environment_id, session_id):
log.debug(_('Session:Deploy <SessionId: {0}>'.format(session_id)))
LOG.debug(_('Session:Deploy <SessionId: {0}>'.format(session_id)))
unit = db_session.get_session()
session = unit.query(models.Session).get(session_id)
if session is None:
log.error(_('Session <SessionId {0}> '
LOG.error(_('Session <SessionId {0}> '
'is not found'.format(session_id)))
raise exc.HTTPNotFound()
if session.environment_id != environment_id:
log.error(_('Session <SessionId {0}> is not tied with Environment '
LOG.error(_('Session <SessionId {0}> is not tied with Environment '
'<EnvId {1}>'.format(session_id, environment_id)))
raise exc.HTTPNotFound()
if not sessions.SessionServices.validate(session):
log.error(_('Session <SessionId {0}> '
LOG.error(_('Session <SessionId {0}> '
'is invalid'.format(session_id)))
raise exc.HTTPForbidden()
if session.state != sessions.SessionState.open:
log.error(_('Session <SessionId {0}> is already deployed or '
LOG.error(_('Session <SessionId {0}> is already deployed or '
'deployment is in progress'.format(session_id)))
raise exc.HTTPForbidden()

View File

@ -17,7 +17,7 @@ import time
from muranoapi.api import v1
from muranoapi.openstack.common import log as logging
log = logging.getLogger(__name__)
LOG = logging.getLogger(__name__)
class StatisticsCollection(object):
@ -67,7 +67,7 @@ def stats_count(api, method):
def update_count(api, method, ex_time, tenant=None):
log.debug("Updating count stats for %s, %s on object %s" % (api,
LOG.debug("Updating count stats for %s, %s on object %s" % (api,
method,
v1.stats))
v1.stats.add_api_request(tenant, ex_time)
@ -75,7 +75,7 @@ def update_count(api, method, ex_time, tenant=None):
def update_error_count(api, method, ex_time, tenant=None):
log.debug("Updating count stats for %s, %s on object %s" % (api,
LOG.debug("Updating count stats for %s, %s on object %s" % (api,
method,
v1.stats))
v1.stats.add_api_error(tenant, ex_time)

View File

@ -32,18 +32,18 @@ from muranocommon.helpers import token_sanitizer
RPC_SERVICE = None
NOTIFICATION_SERVICE = None
log = logging.getLogger(__name__)
LOG = logging.getLogger(__name__)
class ResultEndpoint(object):
@staticmethod
def process_result(context, result):
secure_result = token_sanitizer.TokenSanitizer().sanitize(result)
log.debug(_('Got result from orchestration '
LOG.debug(_('Got result from orchestration '
'engine:\n{0}'.format(secure_result)))
if 'deleted' in result:
log.debug(_('Result for environment {0} is dropped. Environment '
LOG.debug(_('Result for environment {0} is dropped. Environment '
'is deleted'.format(result['id'])))
return
@ -51,7 +51,7 @@ class ResultEndpoint(object):
environment = unit.query(models.Environment).get(result['id'])
if not environment:
log.warning(_('Environment result could not be handled, specified '
LOG.warning(_('Environment result could not be handled, specified '
'environment was not found in database'))
return
@ -93,7 +93,7 @@ class ResultEndpoint(object):
class ReportNotificationEndpoint(object):
@staticmethod
def report_notification(context, report):
log.debug(_('Got report from orchestration '
LOG.debug(_('Got report from orchestration '
'engine:\n{0}'.format(report)))
report['entity_id'] = report['id']

View File

@ -27,8 +27,8 @@ from muranoapi.openstack.common import log as logging
from muranoapi.openstack.common import service
conf = config.CONF.stats
log = logging.getLogger(__name__)
CONF_STATS = config.CONF.stats
LOG = logging.getLogger(__name__)
class StatsCollectingService(service.Service):
@ -47,15 +47,15 @@ class StatsCollectingService(service.Service):
self(StatsCollectingService, self).stop()
def _collect_stats_loop(self):
period = conf.period * 60
period = CONF_STATS.period * 60
while True:
self.update_stats()
eventlet.sleep(period)
def update_stats(self):
log.debug(_("Updating statistic information."))
log.debug("Stats object: %s" % v1.stats)
log.debug("Stats: Requests:%s Errors: %s Ave.Res.Time %2.4f\n"
LOG.debug(_("Updating statistic information."))
LOG.debug("Stats object: %s" % v1.stats)
LOG.debug("Stats: Requests:%s Errors: %s Ave.Res.Time %2.4f\n"
"Per tenant: %s" %
(v1.stats.request_count,
v1.stats.error_count,
@ -87,5 +87,5 @@ class StatsCollectingService(service.Service):
stats.errors_per_second = errors_per_second
self._stats_db.update(self._hostname, stats)
except Exception as e:
log.error(_("Failed to get statistics object "
LOG.error(_("Failed to get statistics object "
"form a database. %s" % e))

View File

@ -23,7 +23,7 @@ from muranoapi.openstack.common.gettextutils import _ # noqa
from muranoapi.openstack.common import log as logging
log = logging.getLogger(__name__)
LOG = logging.getLogger(__name__)
class TraverseHelper(object):
@ -183,8 +183,8 @@ def retry(ExceptionToCheck, tries=4, delay=3, backoff=2):
return f(*args, **kwargs)
except ExceptionToCheck as e:
log.exception(e)
log.info(_("Retrying in {0} seconds...".format(mdelay)))
LOG.exception(e)
LOG.info(_("Retrying in {0} seconds...".format(mdelay)))
eventlet.sleep(mdelay)
@ -201,14 +201,14 @@ def retry(ExceptionToCheck, tries=4, delay=3, backoff=2):
def handle(f):
"""Handles exception in wrapped function and writes to log."""
"""Handles exception in wrapped function and writes to LOG."""
@func.wraps(f)
def f_handle(*args, **kwargs):
try:
return f(*args, **kwargs)
except Exception as e:
log.exception(e)
LOG.exception(e)
return f_handle

View File

@ -30,8 +30,7 @@ from muranoapi.openstack.common.db.sqlalchemy import session as db_session
from muranoapi.openstack.common.gettextutils import _ # noqa
from muranoapi.openstack.common import log as logging
log = logging.getLogger(__name__)
LOG = logging.getLogger(__name__)
CONF = config.CONF
@ -40,10 +39,10 @@ def get_session(autocommit=True, expire_on_commit=False):
expire_on_commit=expire_on_commit)
if s:
if CONF.database.auto_create:
log.info(_('auto-creating DB'))
LOG.info(_('auto-creating DB'))
_auto_create_db()
else:
log.info(_('not auto-creating DB'))
LOG.info(_('not auto-creating DB'))
return s

View File

@ -13,7 +13,6 @@
# under the License.
import functools
import logging
from webob import exc
@ -21,8 +20,9 @@ from muranoapi.db import models
from muranoapi.db.services import sessions
from muranoapi.db import session as db_session
from muranoapi.openstack.common.gettextutils import _ # noqa
from muranoapi.openstack.common import log as logging
log = logging.getLogger(__name__)
LOG = logging.getLogger(__name__)
def verify_env(func):
@ -31,13 +31,13 @@ def verify_env(func):
unit = db_session.get_session()
environment = unit.query(models.Environment).get(environment_id)
if environment is None:
log.info(_("Environment with id '{0}'"
LOG.info(_("Environment with id '{0}'"
" not found".format(environment_id)))
raise exc.HTTPNotFound()
if hasattr(request, 'context'):
if environment.tenant_id != request.context.tenant:
log.info(_('User is not authorized to access'
LOG.info(_('User is not authorized to access'
' this tenant resources'))
raise exc.HTTPUnauthorized()
@ -49,7 +49,7 @@ def verify_session(func):
@functools.wraps(func)
def __inner(self, request, *args, **kwargs):
if hasattr(request, 'context') and not request.context.session:
log.info(_('Session is required for this call'))
LOG.info(_('Session is required for this call'))
raise exc.HTTPForbidden()
session_id = request.context.session
@ -58,17 +58,17 @@ def verify_session(func):
session = unit.query(models.Session).get(session_id)
if session is None:
log.info(_('Session <SessionId {0}> '
LOG.info(_('Session <SessionId {0}> '
'is not found'.format(session_id)))
raise exc.HTTPForbidden()
if not sessions.SessionServices.validate(session):
log.info(_('Session <SessionId {0}> '
LOG.info(_('Session <SessionId {0}> '
'is invalid'.format(session_id)))
raise exc.HTTPForbidden()
if session.state == sessions.SessionState.deploying:
log.info(_('Session <SessionId {0}> is already in '
LOG.info(_('Session <SessionId {0}> is already in '
'deployment state'.format(session_id)))
raise exc.HTTPForbidden()
return func(self, request, *args, **kwargs)