diff --git a/muranoapi/api/v1/catalog.py b/muranoapi/api/v1/catalog.py index c36f6f851..6f25d2f4c 100644 --- a/muranoapi/api/v1/catalog.py +++ b/muranoapi/api/v1/catalog.py @@ -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 diff --git a/muranoapi/api/v1/deployments.py b/muranoapi/api/v1/deployments.py index 8f066fa6f..6c7ae8482 100644 --- a/muranoapi/api/v1/deployments.py +++ b/muranoapi/api/v1/deployments.py @@ -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 diff --git a/muranoapi/api/v1/environments.py b/muranoapi/api/v1/environments.py index 80068254c..f1b5ffab3 100644 --- a/muranoapi/api/v1/environments.py +++ b/muranoapi/api/v1/environments.py @@ -46,7 +46,7 @@ class Controller(object): @request_statistics.stats_count(API_NAME, 'Create') def create(self, request, body): - LOG.debug(_('Environments:Create '.format(body))) + LOG.debug(_('Environments:Create ').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 '.format(environment_id))) + LOG.debug(_('Environments:Show ').format(environment_id)) session = db_session.get_session() environment = session.query(models.Environment).get(environment_id) if environment is None: - LOG.info('Environment is not found' - .format(environment_id)) + LOG.info(_('Environment 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 '.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 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 '.format(environment_id))) + LOG.debug(_('Environments:Delete ').format(environment_id)) unit = db_session.get_session() environment = unit.query(models.Environment).get(environment_id) if environment is None: LOG.info(_('Environment ' - 'is not found'.format(environment_id))) + 'is not found').format(environment_id)) raise exc.HTTPNotFound if environment.tenant_id != request.context.tenant: diff --git a/muranoapi/api/v1/services.py b/muranoapi/api/v1/services.py index c01264f1a..70a158656 100644 --- a/muranoapi/api/v1/services.py +++ b/muranoapi/api/v1/services.py @@ -49,7 +49,7 @@ class Controller(object): @normalize_path def get(self, request, environment_id, path): LOG.debug(_('Services:Get '.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 '.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 '.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 '.format(environment_id, path))) + 'Path: {1}>').format(environment_id, path)) delete_data = core_services.CoreServices.delete_data session_id = request.context.session diff --git a/muranoapi/api/v1/sessions.py b/muranoapi/api/v1/sessions.py index 25889b430..77ede814b 100644 --- a/muranoapi/api/v1/sessions.py +++ b/muranoapi/api/v1/sessions.py @@ -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 '.format(environment_id))) + LOG.debug(_('Session:Configure ').format(environment_id)) unit = db_session.get_session() environment = unit.query(models.Environment).get(environment_id) if environment is None: LOG.info(_('Environment ' - '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 ,' '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 '.format(session_id))) + LOG.debug(_('Session:Show ').format(session_id)) unit = db_session.get_session() session = unit.query(models.Session).get(session_id) if session is None: LOG.error(_('Session ' - 'is not found'.format(session_id))) + 'is not found').format(session_id)) raise exc.HTTPNotFound() if session.environment_id != environment_id: LOG.error(_('Session is not tied with Environment ' - ''.format(session_id, environment_id))) + '').format(session_id, environment_id)) raise exc.HTTPNotFound() user_id = request.context.user if session.user_id != user_id: LOG.error(_('User is not authorized to access session' - '.'.format(user_id, session_id))) + '.').format(user_id, session_id)) raise exc.HTTPUnauthorized() if not sessions.SessionServices.validate(session): LOG.error(_('Session ' - '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 '.format(session_id))) + LOG.debug(_('Session:Delete ').format(session_id)) unit = db_session.get_session() session = unit.query(models.Session).get(session_id) if session is None: LOG.error(_('Session ' - 'is not found'.format(session_id))) + 'is not found').format(session_id)) raise exc.HTTPNotFound() if session.environment_id != environment_id: LOG.error(_('Session is not tied with Environment ' - ''.format(session_id, environment_id))) + '').format(session_id, environment_id)) raise exc.HTTPNotFound() user_id = request.context.user if session.user_id != user_id: LOG.error(_('User is not authorized to access session' - '.'.format(user_id, session_id))) + '.').format(user_id, session_id)) raise exc.HTTPUnauthorized() if session.state == sessions.SessionState.deploying: LOG.error(_('Session 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 '.format(session_id))) + LOG.debug(_('Session:Deploy ').format(session_id)) unit = db_session.get_session() session = unit.query(models.Session).get(session_id) if session is None: LOG.error(_('Session ' - 'is not found'.format(session_id))) + 'is not found').format(session_id)) raise exc.HTTPNotFound() if session.environment_id != environment_id: LOG.error(_('Session is not tied with Environment ' - ''.format(session_id, environment_id))) + '').format(session_id, environment_id)) raise exc.HTTPNotFound() if not sessions.SessionServices.validate(session): LOG.error(_('Session ' - 'is invalid'.format(session_id))) + 'is invalid').format(session_id)) raise exc.HTTPForbidden() if session.state != sessions.SessionState.open: LOG.error(_('Session 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, diff --git a/muranoapi/common/engine.py b/muranoapi/common/engine.py index 0f41f5afe..0acba0f09 100644 --- a/muranoapi/common/engine.py +++ b/muranoapi/common/engine.py @@ -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'] diff --git a/muranoapi/common/server.py b/muranoapi/common/server.py index a0cb32299..2828392ec 100644 --- a/muranoapi/common/server.py +++ b/muranoapi/common/server.py @@ -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'] diff --git a/muranoapi/common/utils.py b/muranoapi/common/utils.py index d2a821af1..92c9979d0 100644 --- a/muranoapi/common/utils.py +++ b/muranoapi/common/utils.py @@ -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) diff --git a/muranoapi/db/catalog/api.py b/muranoapi/db/catalog/api.py index e0fec118b..9dbc8f523 100644 --- a/muranoapi/db/catalog/api.py +++ b/muranoapi/db/catalog/api.py @@ -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) diff --git a/muranoapi/utils.py b/muranoapi/utils.py index c7e473843..2467ddd70 100644 --- a/muranoapi/utils.py +++ b/muranoapi/utils.py @@ -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 ' - 'is not found'.format(session_id))) + 'is not found').format(session_id)) raise exc.HTTPForbidden() if not sessions.SessionServices.validate(session): LOG.info(_('Session ' - 'is invalid'.format(session_id))) + 'is invalid').format(session_id)) raise exc.HTTPForbidden() if session.state == sessions.SessionState.deploying: LOG.info(_('Session is already in ' - 'deployment state'.format(session_id))) + 'deployment state').format(session_id)) raise exc.HTTPForbidden() return func(self, request, *args, **kwargs) return __inner