Fix parentheses in log translation
Translate string before formating Change-Id: Idef92bde8d873c0455dd97147f7924e8f0cfd432
This commit is contained in:
parent
e1f34fdfe8
commit
d0d965642b
@ -74,9 +74,9 @@ def _get_filters(query_params):
|
||||
|
||||
def _validate_body(body):
|
||||
if len(body.keys()) != 2:
|
||||
msg = "'multipart/form-data' request body should contain " \
|
||||
"2 parts: json string and zip archivel. Current body consist " \
|
||||
"of {0} parts".format(len(body.keys()))
|
||||
msg = _("'multipart/form-data' request body should contain "
|
||||
"2 parts: json string and zip archivel. Current body consist "
|
||||
"of {0} part(s)").format(len(body.keys()))
|
||||
LOG.error(msg)
|
||||
raise exc.HTTPBadRequest(msg)
|
||||
file_obj = None
|
||||
|
@ -71,7 +71,7 @@ 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:
|
||||
@ -83,12 +83,12 @@ 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'
|
||||
' in environment {1}'.format(deployment_id,
|
||||
environment_id)))
|
||||
' in environment {1}').format(deployment_id,
|
||||
environment_id))
|
||||
raise exc.HTTPBadRequest
|
||||
return deployment
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Controller(object):
|
||||
|
||||
@request_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,14 +55,14 @@ class Controller(object):
|
||||
|
||||
@request_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'
|
||||
.format(environment_id))
|
||||
LOG.info(_('Environment <EnvId {0}> is not found').format(
|
||||
environment_id))
|
||||
raise exc.HTTPNotFound
|
||||
|
||||
if environment.tenant_id != request.context.tenant:
|
||||
@ -86,14 +86,14 @@ class Controller(object):
|
||||
@request_statistics.stats_count(API_NAME, 'Update')
|
||||
def update(self, request, environment_id, body):
|
||||
LOG.debug(_('Environments:Update <Id: {0}, '
|
||||
'Body: {1}>'.format(environment_id, body)))
|
||||
'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 '
|
||||
'found'.format(environment_id)))
|
||||
'found').format(environment_id))
|
||||
raise exc.HTTPNotFound
|
||||
|
||||
if environment.tenant_id != request.context.tenant:
|
||||
@ -108,14 +108,14 @@ class Controller(object):
|
||||
|
||||
@request_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}> '
|
||||
'is not found'.format(environment_id)))
|
||||
'is not found').format(environment_id))
|
||||
raise exc.HTTPNotFound
|
||||
|
||||
if environment.tenant_id != request.context.tenant:
|
||||
|
@ -49,7 +49,7 @@ class Controller(object):
|
||||
@normalize_path
|
||||
def get(self, request, environment_id, path):
|
||||
LOG.debug(_('Services:Get <EnvId: {0}, '
|
||||
'Path: {1}>'.format(environment_id, path)))
|
||||
'Path: {1}>').format(environment_id, path))
|
||||
|
||||
session_id = None
|
||||
if hasattr(request, 'context') and request.context.session:
|
||||
@ -70,7 +70,7 @@ class Controller(object):
|
||||
def post(self, request, environment_id, path, body):
|
||||
secure_data = token_sanitizer.TokenSanitizer().sanitize(body)
|
||||
LOG.debug(_('Services:Post <EnvId: {0}, Path: {2}, '
|
||||
'Body: {1}>'.format(environment_id, secure_data, path)))
|
||||
'Body: {1}>').format(environment_id, secure_data, path))
|
||||
|
||||
post_data = core_services.CoreServices.post_data
|
||||
session_id = request.context.session
|
||||
@ -86,7 +86,7 @@ class Controller(object):
|
||||
@normalize_path
|
||||
def put(self, request, environment_id, path, body):
|
||||
LOG.debug(_('Services:Put <EnvId: {0}, Path: {2}, '
|
||||
'Body: {1}>'.format(environment_id, body, path)))
|
||||
'Body: {1}>').format(environment_id, body, path))
|
||||
|
||||
put_data = core_services.CoreServices.put_data
|
||||
session_id = request.context.session
|
||||
@ -103,7 +103,7 @@ class Controller(object):
|
||||
@normalize_path
|
||||
def delete(self, request, environment_id, path):
|
||||
LOG.debug(_('Services:Put <EnvId: {0}, '
|
||||
'Path: {1}>'.format(environment_id, path)))
|
||||
'Path: {1}>').format(environment_id, path))
|
||||
|
||||
delete_data = core_services.CoreServices.delete_data
|
||||
session_id = request.context.session
|
||||
|
@ -32,14 +32,14 @@ API_NAME = 'Sessions'
|
||||
class Controller(object):
|
||||
@request_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}> '
|
||||
'is not found'.format(environment_id)))
|
||||
'is not found').format(environment_id))
|
||||
raise exc.HTTPNotFound
|
||||
|
||||
if environment.tenant_id != request.context.tenant:
|
||||
@ -52,7 +52,7 @@ class Controller(object):
|
||||
if env_status == envs.EnvironmentStatus.deploying:
|
||||
LOG.info(_('Could not open session for environment <EnvId: {0}>,'
|
||||
'environment has deploying '
|
||||
'status.'.format(environment_id)))
|
||||
'status.').format(environment_id))
|
||||
raise exc.HTTPForbidden()
|
||||
|
||||
user_id = request.context.user
|
||||
@ -62,60 +62,60 @@ class Controller(object):
|
||||
|
||||
@request_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}> '
|
||||
'is not found'.format(session_id)))
|
||||
'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 '
|
||||
'<EnvId {1}>'.format(session_id, environment_id)))
|
||||
'<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'
|
||||
'<SessionId {1}>.'.format(user_id, session_id)))
|
||||
'<SessionId {1}>.').format(user_id, session_id))
|
||||
raise exc.HTTPUnauthorized()
|
||||
|
||||
if not sessions.SessionServices.validate(session):
|
||||
LOG.error(_('Session <SessionId {0}> '
|
||||
'is invalid'.format(session_id)))
|
||||
'is invalid').format(session_id))
|
||||
raise exc.HTTPForbidden()
|
||||
|
||||
return session.to_dict()
|
||||
|
||||
@request_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}> '
|
||||
'is not found'.format(session_id)))
|
||||
'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 '
|
||||
'<EnvId {1}>'.format(session_id, environment_id)))
|
||||
'<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'
|
||||
'<SessionId {1}>.'.format(user_id, session_id)))
|
||||
'<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 '
|
||||
'could not be deleted'.format(session_id)))
|
||||
'could not be deleted').format(session_id))
|
||||
raise exc.HTTPForbidden()
|
||||
|
||||
with unit.begin():
|
||||
@ -125,29 +125,29 @@ class Controller(object):
|
||||
|
||||
@request_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}> '
|
||||
'is not found'.format(session_id)))
|
||||
'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 '
|
||||
'<EnvId {1}>'.format(session_id, environment_id)))
|
||||
'<EnvId {1}>').format(session_id, environment_id))
|
||||
raise exc.HTTPNotFound()
|
||||
|
||||
if not sessions.SessionServices.validate(session):
|
||||
LOG.error(_('Session <SessionId {0}> '
|
||||
'is invalid'.format(session_id)))
|
||||
'is invalid').format(session_id))
|
||||
raise exc.HTTPForbidden()
|
||||
|
||||
if session.state != sessions.SessionState.open:
|
||||
LOG.error(_('Session <SessionId {0}> is already deployed or '
|
||||
'deployment is in progress'.format(session_id)))
|
||||
'deployment is in progress').format(session_id))
|
||||
raise exc.HTTPForbidden()
|
||||
|
||||
sessions.SessionServices.deploy(session,
|
||||
|
@ -39,7 +39,8 @@ class TaskProcessingEndpoint(object):
|
||||
@staticmethod
|
||||
def handle_task(context, task):
|
||||
s_task = token_sanitizer.TokenSanitizer().sanitize(task)
|
||||
log.info('Starting processing task: {0}'.format(anyjson.dumps(s_task)))
|
||||
log.info(_('Starting processing task: {0}').format(
|
||||
anyjson.dumps(s_task)))
|
||||
|
||||
env = environment.Environment()
|
||||
env.token = task['token']
|
||||
|
@ -41,13 +41,13 @@ class ResultEndpoint(object):
|
||||
def process_result(context, result):
|
||||
secure_result = token_sanitizer.TokenSanitizer().sanitize(result)
|
||||
LOG.debug(_('Got result from orchestration '
|
||||
'engine:\n{0}'.format(secure_result)))
|
||||
'engine:\n{0}').format(secure_result))
|
||||
|
||||
result_id = result['Objects']['?']['id']
|
||||
|
||||
if 'deleted' in result:
|
||||
LOG.debug(_('Result for environment {0} is dropped. Environment '
|
||||
'is deleted'.format(result_id)))
|
||||
'is deleted').format(result_id))
|
||||
return
|
||||
|
||||
unit = session.get_session()
|
||||
@ -113,7 +113,7 @@ def notification_endpoint_wrapper(priority='info'):
|
||||
@notification_endpoint_wrapper()
|
||||
def track_instance(payload):
|
||||
LOG.debug(_('Got track instance request from orchestration '
|
||||
'engine:\n{0}'.format(payload)))
|
||||
'engine:\n{0}').format(payload))
|
||||
instance_id = payload['instance']
|
||||
instance_type = payload.get('instance_type', 0)
|
||||
environment_id = payload['environment']
|
||||
@ -124,7 +124,7 @@ def track_instance(payload):
|
||||
@notification_endpoint_wrapper()
|
||||
def untrack_instance(payload):
|
||||
LOG.debug(_('Got untrack instance request from orchestration '
|
||||
'engine:\n{0}'.format(payload)))
|
||||
'engine:\n{0}').format(payload))
|
||||
instance_id = payload['instance']
|
||||
environment_id = payload['environment']
|
||||
instances.InstanceStatsServices.destroy_instance(
|
||||
@ -134,7 +134,7 @@ def untrack_instance(payload):
|
||||
@notification_endpoint_wrapper()
|
||||
def report_notification(report):
|
||||
LOG.debug(_('Got report from orchestration '
|
||||
'engine:\n{0}'.format(report)))
|
||||
'engine:\n{0}').format(report))
|
||||
|
||||
report['entity_id'] = report['id']
|
||||
del report['id']
|
||||
|
@ -189,7 +189,7 @@ def retry(ExceptionToCheck, tries=4, delay=3, backoff=2):
|
||||
except ExceptionToCheck as e:
|
||||
|
||||
LOG.exception(e)
|
||||
LOG.info(_("Retrying in {0} seconds...".format(mdelay)))
|
||||
LOG.info(_("Retrying in {0} seconds...").format(mdelay))
|
||||
|
||||
eventlet.sleep(mdelay)
|
||||
|
||||
|
@ -38,7 +38,7 @@ def category_get_names():
|
||||
def _package_get(package_id, session):
|
||||
package = session.query(models.Package).get(package_id)
|
||||
if not package:
|
||||
msg = _("Package id '{0}' is not found".format(package_id))
|
||||
msg = _("Package id '{0}' is not found").format(package_id)
|
||||
LOG.error(msg)
|
||||
raise exc.HTTPNotFound(msg)
|
||||
|
||||
@ -52,12 +52,12 @@ def _authorize_package(package, context, allow_public=False):
|
||||
if package.owner_id != context.tenant:
|
||||
if not allow_public:
|
||||
msg = _("Package '{0}' is not owned by "
|
||||
"tenant '{1}'".format(package.id, context.tenant))
|
||||
"tenant '{1}'").format(package.id, context.tenant)
|
||||
LOG.error(msg)
|
||||
raise exc.HTTPForbidden(msg)
|
||||
if not package.is_public:
|
||||
msg = _("Package '{0}' is not public and not owned by "
|
||||
"tenant '{1}' ".format(package.id, context.tenant))
|
||||
"tenant '{1}' ").format(package.id, context.tenant)
|
||||
LOG.error(msg)
|
||||
raise exc.HTTPForbidden(msg)
|
||||
|
||||
@ -87,7 +87,7 @@ def _get_categories(category_names, session=None):
|
||||
ctg_obj = session.query(models.Category).filter_by(
|
||||
name=ctg_name).first()
|
||||
if not ctg_obj:
|
||||
msg = _("Category '{name}' doesn't exist".format(name=ctg_name))
|
||||
msg = _("Category '{name}' doesn't exist").format(name=ctg_name)
|
||||
LOG.error(msg)
|
||||
# it's not allowed to specify non-existent categories
|
||||
raise exc.HTTPBadRequest(msg)
|
||||
|
@ -32,7 +32,7 @@ def verify_env(func):
|
||||
environment = unit.query(models.Environment).get(environment_id)
|
||||
if environment is None:
|
||||
LOG.info(_("Environment with id '{0}'"
|
||||
" not found".format(environment_id)))
|
||||
" not found").format(environment_id))
|
||||
raise exc.HTTPNotFound()
|
||||
|
||||
if hasattr(request, 'context'):
|
||||
@ -59,17 +59,17 @@ def verify_session(func):
|
||||
|
||||
if session is None:
|
||||
LOG.info(_('Session <SessionId {0}> '
|
||||
'is not found'.format(session_id)))
|
||||
'is not found').format(session_id))
|
||||
raise exc.HTTPForbidden()
|
||||
|
||||
if not sessions.SessionServices.validate(session):
|
||||
LOG.info(_('Session <SessionId {0}> '
|
||||
'is invalid'.format(session_id)))
|
||||
'is invalid').format(session_id))
|
||||
raise exc.HTTPForbidden()
|
||||
|
||||
if session.state == sessions.SessionState.deploying:
|
||||
LOG.info(_('Session <SessionId {0}> is already in '
|
||||
'deployment state'.format(session_id)))
|
||||
'deployment state').format(session_id))
|
||||
raise exc.HTTPForbidden()
|
||||
return func(self, request, *args, **kwargs)
|
||||
return __inner
|
||||
|
Loading…
Reference in New Issue
Block a user