本文整理汇总了Python中murano.common.i18n._LI函数的典型用法代码示例。如果您正苦于以下问题:Python _LI函数的具体用法?Python _LI怎么用?Python _LI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_LI函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __inner
def __inner(self, request, *args, **kwargs):
if hasattr(request, 'context') and not request.context.session:
LOG.info(_LI('Session is required for this call'))
raise exc.HTTPForbidden()
session_id = request.context.session
unit = db_session.get_session()
session = unit.query(models.Session).get(session_id)
if session is None:
LOG.info(_LI('Session <SessionId {0}> '
'is not found').format(session_id))
raise exc.HTTPForbidden()
if not sessions.SessionServices.validate(session):
LOG.info(_LI('Session <SessionId {0}> '
'is invalid').format(session_id))
raise exc.HTTPForbidden()
if session.state == states.SessionState.DEPLOYING:
LOG.info(_LI('Session <SessionId {0}> is already in '
'deployment state').format(session_id))
raise exc.HTTPForbidden()
return func(self, request, *args, **kwargs)
开发者ID:bh016088,项目名称:murano,代码行数:25,代码来源:utils.py
示例2: update
def update(self, request, environment_id, body):
LOG.debug('Environments:Update <Id: {0}, '
'Body: {1}>'.format(environment_id, body))
target = {"environment_id": environment_id}
policy.check('update_environment', request.context, target)
session = db_session.get_session()
environment = session.query(models.Environment).get(environment_id)
if environment is None:
LOG.info(_LI('Environment <EnvId {0}> not '
'found').format(environment_id))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
LOG.info(_LI('User is not authorized to access '
'this tenant resources.'))
raise exc.HTTPUnauthorized
LOG.debug('ENV NAME: {0}>'.format(body['name']))
if VALID_NAME_REGEX.match(str(body['name'])):
environment.update(body)
environment.save(session)
else:
msg = _('Environment name must contain only alphanumeric '
'or "_-." characters, must start with alpha')
LOG.error(msg)
raise exc.HTTPClientError(explanation=msg)
return environment.to_dict()
开发者ID:finalbro,项目名称:murano,代码行数:30,代码来源:environments.py
示例3: show
def show(self, request, environment_id):
LOG.debug('Environments:Show <Id: {0}>'.format(environment_id))
target = {"environment_id": environment_id}
policy.check('show_environment', request.context, target)
session = db_session.get_session()
environment = session.query(models.Environment).get(environment_id)
if environment is None:
LOG.info(_LI('Environment <EnvId {0}> is not found').format(
environment_id))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
LOG.info(_LI('User is not authorized to access '
'this tenant resources.'))
raise exc.HTTPUnauthorized
env = environment.to_dict()
env['status'] = envs.EnvironmentServices.get_status(env['id'])
session_id = None
if hasattr(request, 'context') and request.context.session:
session_id = request.context.session
# add services to env
get_data = core_services.CoreServices.get_data
env['services'] = get_data(environment_id, '/services', session_id)
return env
开发者ID:finalbro,项目名称:murano,代码行数:30,代码来源:environments.py
示例4: validate
def validate(self, model, class_loader=None):
"""Validate model using Congress rule engine.
@type model: dict
@param model: Dictionary representation of model starting on
environment level (['Objects'])
@type class_loader: murano.dsl.class_loader.MuranoClassLoader
@param class_loader: Optional. Used for evaluating parent class types
@raises ValidationError in case validation was not successful
"""
if model is None:
return
client = self._client_manager.get_congress_client(self._environment)
if not client:
raise ValueError(_('Congress client is not configured!'))
LOG.info(_LI('Validating model'))
LOG.debug(model)
rules = congress_rules.CongressRulesManager().convert(
model, class_loader, self._environment.tenant_id)
rules_str = map(str, rules)
env_id = model['?']['id']
# cleanup of data populated by murano driver
rules_str.insert(0, 'deleteEnv("{0}")'.format(env_id))
rules_line = " ".join(rules_str)
LOG.debug('Congress rules: \n ' +
'\n '.join(rules_str))
validation_result = client.execute_policy_action(
"murano_system",
"simulate",
False,
False,
{'query': 'predeploy_errors(eid, oid, msg)',
'action_policy': 'murano_action',
'sequence': rules_line})
if validation_result["result"]:
messages = self._parse_messages(env_id,
validation_result["result"])
if messages:
result_str = "\n ".join(map(str, messages))
msg = _("Murano object model validation failed: {0}").format(
"\n " + result_str)
LOG.error(msg)
raise ValidationError(msg)
else:
LOG.info(_LI('Model valid'))
开发者ID:aawm,项目名称:murano,代码行数:55,代码来源:model_policy_enforcer.py
示例5: _execute
def _execute(self, pkg_loader):
class_loader = package_class_loader.PackageClassLoader(pkg_loader)
system_objects.register(class_loader, pkg_loader)
get_plugin_loader().register_in_loader(class_loader)
exc = executor.MuranoDslExecutor(class_loader, self.environment)
obj = exc.load(self.model)
self._validate_model(obj, self.action, class_loader)
action_result = None
exception = None
exception_traceback = None
try:
LOG.info(_LI('Invoking pre-cleanup hooks'))
self.environment.start()
exc.cleanup(self._model)
except Exception as e:
exception = e
exception_traceback = TaskExecutor._log_exception(e, obj, '<GC>')
finally:
LOG.info(_LI('Invoking post-cleanup hooks'))
self.environment.finish()
if exception is None and self.action:
try:
LOG.info(_LI('Invoking pre-execution hooks'))
self.environment.start()
action_result = self._invoke(exc)
except Exception as e:
exception = e
exception_traceback = TaskExecutor._log_exception(
e, obj, self.action['method'])
finally:
LOG.info(_LI('Invoking post-execution hooks'))
self.environment.finish()
model = serializer.serialize_model(obj, exc)
model['SystemData'] = self._environment.system_attributes
result = {
'model': model,
'action': {
'result': None,
'isException': False
}
}
if exception is not None:
result['action'] = TaskExecutor.exception_result(
exception, exception_traceback)
else:
result['action']['result'] = serializer.serialize_object(
action_result)
return result
开发者ID:schaertelr,项目名称:murano,代码行数:54,代码来源:engine.py
示例6: _execute
def _execute(self, pkg_loader):
class_loader = package_class_loader.PackageClassLoader(pkg_loader)
system_objects.register(class_loader, pkg_loader)
get_plugin_loader().register_in_loader(class_loader)
exc = executor.MuranoDslExecutor(class_loader, self.environment)
obj = exc.load(self.model)
self._validate_model(obj, self.action, class_loader)
action_result = None
exception = None
exception_traceback = None
try:
LOG.info(_LI('Invoking pre-execution hooks'))
self.environment.start()
# Skip execution of action in case no action is provided.
# Model will be just loaded, cleaned-up and unloaded.
# Most of the time this is used for deletion of environments.
if self.action:
action_result = self._invoke(exc)
except Exception as e:
exception = e
if isinstance(e, dsl_exception.MuranoPlException):
LOG.error('\n' + e.format(prefix=' '))
else:
exception_traceback = traceback.format_exc()
LOG.exception(
_LE("Exception %(exc)s occured"
" during invocation of %(method)s"),
{'exc': e, 'method': self.action['method']})
reporter = status_reporter.StatusReporter()
reporter.initialize(obj)
reporter.report_error(obj, str(e))
finally:
LOG.info(_LI('Invoking post-execution hooks'))
self.environment.finish()
model = serializer.serialize_model(obj, exc)
model['SystemData'] = self._environment.system_attributes
result = {
'model': model,
'action': {
'result': None,
'isException': False
}
}
if exception is not None:
result['action'] = TaskExecutor.exception_result(
exception, exception_traceback)
else:
result['action']['result'] = serializer.serialize_object(
action_result)
return result
开发者ID:finalbro,项目名称:murano,代码行数:54,代码来源:engine.py
示例7: verify_and_get_env
def verify_and_get_env(db_session, environment_id, request):
environment = db_session.query(models.Environment).get(environment_id)
if not environment:
LOG.info(_LI(
'Environment with id {0} not found').format(environment_id))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
LOG.info(_LI(
'User is not authorized to access this tenant resources.'))
raise exc.HTTPUnauthorized
return environment
开发者ID:schaertelr,项目名称:murano,代码行数:12,代码来源:deployments.py
示例8: _validate_environment
def _validate_environment(self, unit, request, environment_id):
environment = unit.query(models.Environment).get(environment_id)
if environment is None:
LOG.info(_LI('Environment <EnvId {0}> '
'is not found').format(environment_id))
raise exc.HTTPNotFound
if environment.tenant_id != request.context.tenant:
LOG.info(_LI('User is not authorized to access '
'this tenant resources.'))
raise exc.HTTPUnauthorized
开发者ID:schaertelr,项目名称:murano,代码行数:12,代码来源:actions.py
示例9: 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.info(_LI('Deployment with id {0} not found').format(deployment_id))
raise exc.HTTPNotFound
if deployment.environment_id != environment_id:
LOG.info(_LI('Deployment with id {0} not found'
' in environment {1}').format(deployment_id,
environment_id))
raise exc.HTTPBadRequest
deployment.description = _patch_description(deployment.description)
return deployment
开发者ID:schaertelr,项目名称:murano,代码行数:13,代码来源:deployments.py
示例10: call_static_action
def call_static_action(cls, context, task):
s_task = token_sanitizer.TokenSanitizer().sanitize(task)
LOG.info(_LI('Starting execution of static action: '
'{task_desc}').format(task_desc=jsonutils.dumps(s_task)))
result = None
reporter = status_reporter.StatusReporter(task['id'])
try:
task_executor = StaticActionExecutor(task, reporter)
result = task_executor.execute()
return result
finally:
LOG.info(_LI('Finished execution of static action: '
'{task_desc}').format(task_desc=jsonutils.dumps(result)))
开发者ID:AleptNamrata,项目名称:murano,代码行数:15,代码来源:engine.py
示例11: execute
def execute(task):
s_task = token_sanitizer.TokenSanitizer().sanitize(task)
LOG.info(_LI('Starting processing task: {task_desc}').format(
task_desc=jsonutils.dumps(s_task)))
result = None
reporter = status_reporter.StatusReporter(task['id'])
try:
task_executor = TaskExecutor(task, reporter)
result = task_executor.execute()
return result
finally:
LOG.info(_LI('Finished processing task: {task_desc}').format(
task_desc=jsonutils.dumps(result)))
开发者ID:Magic-Mirror,项目名称:murano,代码行数:15,代码来源:engine.py
示例12: 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}
开发者ID:sajuptpm,项目名称:murano,代码行数:26,代码来源:actions.py
示例13: get_default_router
def get_default_router(self):
router_name = self._settings.router_name
routers = self._client.list_routers(tenant_id=self._project_id, name=router_name).get("routers")
if len(routers) == 0:
LOG.debug("Router {name} not found".format(name=router_name))
if self._settings.create_router:
LOG.debug("Attempting to create Router {router}".format(router=router_name))
external_network = self._settings.external_network
kwargs = (
{"id": external_network} if uuidutils.is_uuid_like(external_network) else {"name": external_network}
)
networks = self._client.list_networks(**kwargs).get("networks")
ext_nets = filter(lambda n: n["router:external"], networks)
if len(ext_nets) == 0:
raise KeyError("Router %s could not be created, " "no external network found" % router_name)
nid = ext_nets[0]["id"]
body_data = {
"router": {
"name": router_name,
"external_gateway_info": {"network_id": nid},
"admin_state_up": True,
}
}
router = self._client.create_router(body=body_data).get("router")
LOG.info(_LI("Created router: {id}").format(id=router["id"]))
return router["id"]
else:
raise KeyError("Router %s was not found" % router_name)
else:
if routers[0]["external_gateway_info"] is None:
raise exc.RouterInfoException("Please set external gateway for" " the router %s " % router_name)
router_id = routers[0]["id"]
return router_id
开发者ID:olivierlemasle,项目名称:murano,代码行数:35,代码来源:net_explorer.py
示例14: _build_index
def _build_index(self):
for folder in self.search_package_folders(self._base_path):
try:
package = load_utils.load_from_dir(folder)
dsl_package = murano_package.MuranoPackage(self._root_loader, package)
for class_name in package.classes:
dsl_package.register_class(
(lambda pkg, cls: lambda: get_class(pkg, cls))(package, class_name), class_name
)
if dsl_package.name == constants.CORE_LIBRARY:
system_objects.register(dsl_package)
self.register_package(dsl_package)
except pkg_exc.PackageLoadError:
LOG.info(_LI("Unable to load package from path: {0}").format(folder))
continue
LOG.info(_LI("Loaded package from path {0}").format(folder))
开发者ID:olivierlemasle,项目名称:murano,代码行数:16,代码来源:package_loader.py
示例15: validate
def validate(self, model, package_loader=None):
"""Validate model using Congress rule engine.
@type model: dict
@param model: Dictionary representation of model starting on
environment level (['Objects'])
@type package_loader: murano.dsl.package_loader.MuranoPackageLoader
@param package_loader: Optional. Used for evaluating parent class types
@raises ValidationError in case validation was not successful
"""
if model is None:
return
env_id = model['?']['id']
validation_result = self._execute_simulation(
package_loader, env_id, model,
'predeploy_errors(eid, oid, msg)')
if validation_result["result"]:
messages = self._parse_simulation_result(
'predeploy_errors', env_id,
validation_result["result"])
if messages:
result_str = "\n ".join(map(str, messages))
msg = _("Murano object model validation failed: {0}").format(
"\n " + result_str)
LOG.error(msg)
raise ValidationError(msg)
else:
LOG.info(_LI('Model valid'))
开发者ID:Magic-Mirror,项目名称:murano,代码行数:34,代码来源:model_policy_enforcer.py
示例16: _do_import_package
def _do_import_package(_dir, categories, update=False):
LOG.info(_LI("Going to import Murano package from {0}").format(_dir))
pkg = load_utils.load_from_dir(_dir)
LOG.info(_LI("Checking for existing"))
existing = db_catalog_api.package_search(
{'fqn': pkg.full_name},
AdminContext())
if existing:
existing_pkg = existing[0]
if update:
LOG.info(_LI(
"Deleting existing package {0}").format(existing_pkg.id))
db_catalog_api.package_delete(existing_pkg.id, AdminContext())
else:
LOG.error(_LE("Package '{0}' exists ({1}). Use --update.").format(
pkg.full_name,
existing_pkg.id))
return
package = {
'fully_qualified_name': pkg.full_name,
'type': pkg.package_type,
'author': pkg.author,
'supplier': pkg.supplier,
'name': pkg.display_name,
'description': pkg.description,
# note: we explicitly mark all the imported packages as public,
# until a parameter added to control visibility scope of a package
'is_public': True,
'tags': pkg.tags,
'logo': pkg.logo,
'supplier_logo': pkg.supplier_logo,
'ui_definition': pkg.raw_ui,
'class_definitions': pkg.classes,
'archive': pkg.blob,
'categories': categories or []
}
# note(ruhe): the second parameter is tenant_id
# it is a required field in the DB, that's why we pass an empty string
result = db_catalog_api.package_upload(package, '')
LOG.info(_LI("Finished import of package {0}").format(result.id))
开发者ID:hybrid-murano,项目名称:hybrid-murano,代码行数:44,代码来源:manage.py
示例17: _build_index
def _build_index(self):
for entry in os.listdir(self._base_path):
folder = os.path.join(self._base_path, entry)
if not os.path.isdir(folder) or entry in self._processed_entries:
continue
try:
package = load_utils.load_from_dir(
folder, preload=True,
loader=yaql_yaml_loader.YaqlYamlLoader)
except pkg_exc.PackageLoadError:
LOG.info(_LI('Unable to load package from path: {0}').format(
os.path.join(self._base_path, entry)))
continue
LOG.info(_LI('Loaded package from path {0}').format(
os.path.join(self._base_path, entry)))
for c in package.classes:
self._packages_by_class[c] = package
self._packages_by_name[package.full_name] = package
self._processed_entries.add(entry)
开发者ID:hybrid-murano,项目名称:hybrid-murano,代码行数:21,代码来源:package_loader.py
示例18: my_process_result
def my_process_result(context, result, environment_id):
if environment_id != scheduler.get_scheduler_id():
return old_process_result(context, result, environment_id)
model = result['model']
action_result = result.get('action', {})
unit = db_session.get_session()
# close deployment
deployment = server.get_last_deployment(unit, environment_id)
deployment.finished = timeutils.utcnow()
deployment.result = action_result
num_errors = unit.query(models.Status).filter_by(level='error', task_id=deployment.id).count()
num_warnings = unit.query(models.Status).filter_by(level='warning', task_id=deployment.id).count()
if num_errors:
final_status_text = "finished with errors"
elif num_warnings:
final_status_text = "finished with warnings"
else:
final_status_text = "finished"
status = models.Status()
status.task_id = deployment.id
status.text = final_status_text
status.level = 'info'
deployment.statuses.append(status)
deployment.save(unit)
# close session
session_id = model['SystemData']['SessionId']
conf_session = unit.query(models.Session).get(session_id)
if num_errors > 0 or result['action'].get('isException'):
conf_session.state = states.EnvironmentStatus.DEPLOY_FAILURE
else:
conf_session.state = states.EnvironmentStatus.READY
conf_session.description = model
if conf_session.description['Objects'] is not None:
conf_session.description['Objects']['services'] = conf_session.description['Objects'].pop('applications', [])
conf_session.version += 1
conf_session.save(unit)
# output application tracking information
services = []
objects = model['Objects']
if objects:
services = objects.get('services')
if num_errors + num_warnings > 0:
LOG.warning(_LW('Schedule Status: Failed Apps: {services}').format(services=services))
else:
LOG.info(_LI('Schedule Status: Successful Apps: {services}').format(services=services))
开发者ID:hybrid-murano,项目名称:murano-mitaka,代码行数:51,代码来源:hybrid.py
示例19: f_retry
def f_retry(*args, **kwargs):
mtries, mdelay = tries, delay
forever = mtries == -1
while forever or mtries > 1:
try:
return f(*args, **kwargs)
except ExceptionToCheck as e:
LOG.exception(e)
LOG.info(_LI("Retrying in {0} seconds...").format(mdelay))
eventlet.sleep(mdelay)
if not forever:
mtries -= 1
if mdelay < 60:
mdelay *= backoff
return f(*args, **kwargs)
开发者ID:hybrid-murano,项目名称:hybrid-murano,代码行数:19,代码来源:utils.py
示例20: handle_task
def handle_task(context, task):
s_task = token_sanitizer.TokenSanitizer().sanitize(task)
LOG.info(_LI('Starting processing task: {task_desc}').format(
task_desc=jsonutils.dumps(s_task)))
result = {'model': task['model']}
try:
task_executor = TaskExecutor(task)
result = task_executor.execute()
except Exception as e:
LOG.exception(_LE('Error during task execution for tenant %s'),
task['tenant_id'])
result['action'] = TaskExecutor.exception_result(e)
msg_env = Environment(task['id'])
reporter = status_reporter.StatusReporter()
reporter.initialize(msg_env)
reporter.report_error(msg_env, str(e))
finally:
rpc.api().process_result(result, task['id'])
开发者ID:finalbro,项目名称:murano,代码行数:19,代码来源:engine.py
注:本文中的murano.common.i18n._LI函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论