本文整理汇总了Python中murano.common.i18n._LE函数的典型用法代码示例。如果您正苦于以下问题:Python _LE函数的具体用法?Python _LE怎么用?Python _LE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_LE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
test_runner = MuranoTestRunner()
try:
if test_runner.args.config_file:
default_config_files = [test_runner.args.config_file]
else:
default_config_files = cfg.find_config_files('murano')
if not default_config_files:
murano_conf = os.path.join(os.path.dirname(__file__),
os.pardir,
os.pardir,
'etc', 'murano',
'murano.conf')
if os.path.exists(murano_conf):
default_config_files = [murano_conf]
sys.argv = [sys.argv[0]]
config.parse_args(default_config_files=default_config_files)
logging.setup(CONF, 'murano')
except RuntimeError as e:
LOG.exception(_LE("Failed to initialize murano-test-runner: %s") % e)
sys.exit("ERROR: %s" % e)
try:
exit_code = test_runner.run_tests()
sys.exit(exit_code)
except Exception as e:
tb = traceback.format_exc()
err_msg = _LE("Command failed: {0}\n{1}").format(e, tb)
LOG.error(err_msg)
sys.exit(err_msg)
示例2: verify_and_get_deployment
def verify_and_get_deployment(db_session, environment_id, deployment_id):
deployment = db_session.query(models.Task).get(deployment_id)
if not deployment:
LOG.error(_LE('Deployment with id {id} not found')
.format(id=deployment_id))
raise exc.HTTPNotFound
if deployment.environment_id != environment_id:
LOG.error(_LE('Deployment with id {d_id} not found in environment '
'{env_id}').format(d_id=deployment_id,
env_id=environment_id))
raise exc.HTTPBadRequest
deployment.description = _patch_description(deployment.description)
return deployment
示例3: __inner
def __inner(self, request, env_template_id, *args, **kwargs):
unit = db_session.get_session()
template = unit.query(models.EnvironmentTemplate).get(env_template_id)
if template is None:
LOG.error(_LE("Environment Template with id '{id}' not found").
format(id=env_template_id))
raise exc.HTTPNotFound()
if hasattr(request, 'context'):
if template.tenant_id != request.context.tenant:
LOG.error(_LE('User is not authorized to access '
'this tenant resources'))
raise exc.HTTPUnauthorized()
return func(self, request, env_template_id, *args, **kwargs)
示例4: _validate_keystone_opts
def _validate_keystone_opts(self, args):
ks_opts_to_config = {
'auth_url': 'auth_uri',
'username': 'admin_user',
'password': 'admin_password',
'project_name': 'admin_tenant_name'}
ks_opts = {'auth_url': getattr(args, 'os_auth_url', None),
'username': getattr(args, 'os_username', None),
'password': getattr(args, 'os_password', None),
'project_name': getattr(args, 'os_project_name', None)}
if None in ks_opts.values() and not CONF.default_config_files:
msg = _LE('Please provide murano config file or credentials for '
'authorization: {0}').format(
', '.join(['--os-auth-url', '--os-username', '--os-password',
'--os-project-name', '--os-tenant-id']))
LOG.error(msg)
self.error(msg)
# Load keystone configuration parameters from config
importutils.import_module('keystonemiddleware.auth_token')
for param, value in six.iteritems(ks_opts):
if not value:
ks_opts[param] = getattr(CONF.keystone_authtoken,
ks_opts_to_config[param])
if param == 'auth_url':
ks_opts[param] = ks_opts[param].replace('v2.0', 'v3')
return ks_opts
示例5: finish
def finish(self):
for delegate in self._tear_down_list:
try:
delegate()
except Exception:
LOG.exception(_LE("Unhandled exception on invocation of " "post-execution hook"))
self._tear_down_list = []
示例6: start
def start(self):
for delegate in self._set_up_list:
try:
delegate()
except Exception:
LOG.exception(_LE("Unhandled exception on invocation of " "pre-execution hook"))
self._set_up_list = []
示例7: _check_enabled
def _check_enabled(self):
if CONF.engine.disable_murano_agent:
LOG.error(_LE("Use of murano-agent is disallowed " "by the server configuration"))
raise exceptions.PolicyViolationException(
"Use of murano-agent is disallowed " "by the server configuration"
)
示例8: _migrate_up
def _migrate_up(self, engine, version, with_data=False):
"""Migrate up to a new version of the db.
We allow for data insertion and post checks at every
migration version with special _pre_upgrade_### and
_check_### functions in the main test.
"""
# NOTE(sdague): try block is here because it's impossible to debug
# where a failed data migration happens otherwise
check_version = version
try:
if with_data:
data = None
pre_upgrade = getattr(
self, "_pre_upgrade_%s" % check_version, None)
if pre_upgrade:
data = pre_upgrade(engine)
self._migrate(engine, version, 'upgrade')
self.assertEqual(version, self._get_version_from_db(engine))
if with_data:
check = getattr(self, "_check_%s" % check_version, None)
if check:
check(engine, data)
except Exception:
LOG.error(_LE("Failed to migrate to version {ver} on engine {eng}")
.format(ver=version, eng=engine))
raise
示例9: _validate_change
def _validate_change(self, change):
change_path = change['path'][0]
change_op = change['op']
allowed_methods = self.allowed_operations.get(change_path)
if not allowed_methods:
msg = _("Attribute '{0}' is invalid").format(change_path)
raise webob.exc.HTTPForbidden(explanation=six.text_type(msg))
if change_op not in allowed_methods:
msg = _("Method '{method}' is not allowed for a path with name "
"'{name}'. Allowed operations are: "
"'{ops}'").format(method=change_op,
name=change_path,
ops=', '.join(allowed_methods))
raise webob.exc.HTTPForbidden(explanation=six.text_type(msg))
property_to_update = {change_path: change['value']}
try:
jsonschema.validate(property_to_update, schemas.PKG_UPDATE_SCHEMA)
except jsonschema.ValidationError as e:
LOG.error(_LE("Schema validation error occured: {error}")
.format(error=e))
raise webob.exc.HTTPBadRequest(explanation=e.message)
示例10: clone
def clone(self, request, env_template_id, body):
"""Clones env template from another tenant
It clones the env template from another env template
from other tenant.
:param request: the operation request.
:param env_template_id: the env template ID.
:param body: the request body.
:return: the description of the created template.
"""
LOG.debug('EnvTemplates:Clone <Env Template {0} for body {1}>'.
format(body, env_template_id))
policy.check('clone_env_template', request.context)
old_env_template = self._validate_exists(env_template_id)
if not old_env_template.get('is_public'):
msg = _LE('User has no access to these resources.')
LOG.error(msg)
raise exc.HTTPForbidden(explanation=msg)
self._validate_body_name(body)
LOG.debug('ENV TEMP NAME: {0}'.format(body['name']))
try:
is_public = body.get('is_public', False)
template = env_temps.EnvTemplateServices.clone(
env_template_id, request.context.tenant, body['name'],
is_public)
except db_exc.DBDuplicateEntry:
msg = _('Environment with specified name already exists')
LOG.error(msg)
raise exc.HTTPConflict(explanation=msg)
return template.to_dict()
示例11: execute
def execute(self, request, environment_id, action_id, body):
policy.check("execute_action", request.context, {})
LOG.debug("Action:Execute <ActionId: {0}>".format(action_id))
unit = db_session.get_session()
# no new session can be opened if environment has deploying status
env_status = envs.EnvironmentServices.get_status(environment_id)
if env_status in (states.EnvironmentStatus.DEPLOYING, states.EnvironmentStatus.DELETING):
LOG.info(
_LI(
"Could not open session for environment <EnvId: {0}>," "environment has deploying " "status."
).format(environment_id)
)
raise exc.HTTPForbidden()
user_id = request.context.user
session = sessions.SessionServices.create(environment_id, user_id)
if not sessions.SessionServices.validate(session):
LOG.error(_LE("Session <SessionId {0}> " "is invalid").format(session.id))
raise exc.HTTPForbidden()
task_id = actions.ActionServices.execute(action_id, session, unit, request.context.auth_token, body or {})
return {"task_id": task_id}
示例12: main
def main():
CONF.register_cli_opt(command_opt)
try:
default_config_files = cfg.find_config_files('murano', 'murano')
CONF(sys.argv[1:], project='murano', prog='murano-manage',
version=version.version_string,
default_config_files=default_config_files)
except RuntimeError as e:
LOG.error(_LE("failed to initialize murano-manage: %s") % e)
sys.exit("ERROR: %s" % e)
try:
CONF.command.func()
except Exception as e:
tb = traceback.format_exc()
err_msg = _LE("murano-manage command failed: {0}\n{1}").format(e, tb)
LOG.error(err_msg)
sys.exit(err_msg)
示例13: _validate_request
def _validate_request(self, request, env_template_id):
self._validate_exists(env_template_id)
get_env_template = env_temps.EnvTemplateServices.get_env_template
env_template = get_env_template(env_template_id)
if env_template.is_public or request.context.is_admin:
return
if env_template.tenant_id != request.context.tenant:
msg = _LE('User has no access to these resources.')
LOG.error(msg)
raise exc.HTTPForbidden(explanation=msg)
示例14: _parse_format_string
def _parse_format_string(format_string):
parts = format_string.rsplit('/', 1)
if len(parts) != 2:
LOG.error(_LE("Incorrect format name {name}").format(
name=format_string))
raise ValueError(format_string)
return (
parts[0].strip(),
semantic_version.Version.coerce(parts[1])
)
示例15: execute
def execute(self, request, body):
policy.check("execute_action", request.context, {})
class_name = body.get('className')
method_name = body.get('methodName')
if not class_name or not method_name:
msg = _('Class name and method name must be specified for '
'static action')
LOG.error(msg)
raise exc.HTTPBadRequest(msg)
args = body.get('parameters')
pkg_name = body.get('packageName')
class_version = body.get('classVersion', '=0')
LOG.debug('StaticAction:Execute <MethodName: {0}, '
'ClassName: {1}>'.format(method_name, class_name))
credentials = {
'token': request.context.auth_token,
'tenant_id': request.context.tenant
}
try:
return static_actions.StaticActionServices.execute(
method_name, class_name, pkg_name, class_version, args,
credentials)
except client.RemoteError as e:
LOG.error(_LE('Exception during call of the method {method_name}: '
'{exc}').format(method_name=method_name, exc=str(e)))
if e.exc_type in (
'NoClassFound', 'NoMethodFound', 'NoPackageFound',
'NoPackageForClassFound', 'MethodNotExposed',
'NoMatchingMethodException'):
raise exc.HTTPNotFound(e.value)
elif e.exc_type == 'ContractViolationException':
raise exc.HTTPBadRequest(e.value)
raise exc.HTTPServiceUnavailable(e.value)
except ValueError as e:
LOG.error(_LE('Exception during call of the method {method_name}: '
'{exc}').format(method_name=method_name, exc=str(e)))
raise exc.HTTPBadRequest(e.message)