• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python i18n._LW函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中murano.common.i18n._LW函数的典型用法代码示例。如果您正苦于以下问题:Python _LW函数的具体用法?Python _LW怎么用?Python _LW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了_LW函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: delete

    def delete(self):
        while True:
            try:
                if not self.current():
                    return
                self._wait_state(lambda s: True)
                self._client.stacks.delete(stack_id=self._name)
                self._wait_state(
                    lambda status: status in ('DELETE_COMPLETE', 'NOT_FOUND'),
                    wait_progress=True)
            except heat_exc.NotFound:
                LOG.warning(_LW('Stack {stack_name} already deleted?')
                            .format(stack_name=self._name))
                break
            except heat_exc.HTTPConflict as e:
                LOG.warning(_LW('Conflicting operation: {msg}').format(msg=e))
                eventlet.sleep(3)
            else:
                break

        if cache.has_key(self._name):
            del cache[self._name]
        if applied.has_key(self._name):
            del applied[self._name]
        if pushing.has_key(self._name):
            del pushing[self._name]
开发者ID:hybrid-murano,项目名称:murano-mitaka,代码行数:26,代码来源:heat_stack.py


示例2: cleanup_duplicates

 def cleanup_duplicates(self, name_map):
     for class_name, package_names in six.iteritems(name_map):
         if len(package_names) >= 2:
             LOG.warning(_LW("Class is defined in multiple packages!"))
             for package_name in package_names:
                 LOG.warning(_LW("Disabling class '%(class_name)s' in "
                                 "'%(dist)s' due to conflict") %
                             dict(class_name=class_name, dist=package_name))
                 self.packages[package_name].classes.pop(class_name)
开发者ID:aawm,项目名称:murano,代码行数:9,代码来源:plugin_loader.py


示例3: bind

    def bind(self, req, body, instance_id, app_id):
        db_service = db_cf.get_service_for_instance(instance_id)
        if not db_service:
            return {}

        service_id = db_service.service_id
        environment_id = db_service.environment_id
        token = req.headers['X-Auth-Token']
        m_cli = _get_muranoclient(token, req)

        session_id = create_session(m_cli, environment_id)
        env = m_cli.environments.get(environment_id, session_id)
        LOG.debug('Got environment {0}'.format(env))
        service = self._get_service(env, service_id)
        LOG.debug('Got service {0}'.format(service))

        # NOTE(starodubcevna): Here we need to find an action which will return
        # us needed credentials. By default we will looking for getCredentials
        # action.
        result = {}
        try:
            actions = service['?']['_actions']
            for action_id in list(actions):
                if 'getCredentials' in action_id:

                    @retrying.retry(retry_on_exception=lambda e: isinstance(e,
                                    TypeError),
                                    wait_random_min=1000,
                                    wait_random_max=10000,
                                    stop_max_delay=30000)
                    def _get_creds(client, task_id, environment_id):
                        result = m_cli.actions.get_result(environment_id,
                                                          task_id)['result']
                        return result

                    task_id = m_cli.actions.call(environment_id, action_id)
                    result = _get_creds(m_cli, task_id, environment_id)

            if not result:
                LOG.warning(_LW("This application doesn't have action "
                                "getCredentials"))
                return response.Response(status=500)
        except KeyError:
            # NOTE(starodubcevna): In CF service broker API spec return
            # code for failed bind is not present, so we will return 500.
            LOG.warning(_LW("This application doesn't have actions at all"))
            return response.Response(status=500)

        if 'credentials' in list(result):
            return result
        else:
            return {'credentials': result}
开发者ID:ISCAS-VDI,项目名称:murano-base,代码行数:52,代码来源:cfapi.py


示例4: invoke_method

    def invoke_method(self, name, this, context, murano_class, *args):
        external_call = False
        if context is None:
            external_call = True
            context = self._root_context
        method = this.type.find_single_method(name)

        is_special_method = name in ('initialize', 'destroy')

        if external_call and not is_special_method and \
                method.usage != murano_method.MethodUsages.Action:
            raise Exception('{0} is not an action'.format(method.name))
        # TODO(slagun): check method accessibility from murano_class

        if not external_call and is_special_method:
            LOG.warning(_LW('initialize/destroy methods are called '
                            'automatically by engine. This call is no-op '
                            'and will become exception in the future'))
            return None

        # restore this from upcast object (no change if there was no upcast)
        this = this.real_this
        arguments_scheme = method.arguments_scheme
        params = self._evaluate_parameters(
            arguments_scheme, context, this, *args)
        return self._invoke_method_implementation(
            method, this, context, params)
开发者ID:hybrid-murano,项目名称:hybrid-murano,代码行数:27,代码来源:executor.py


示例5: get_last_operation

    def get_last_operation(self, req, instance_id):
        service = db_cf.get_service_for_instance(instance_id)
        # NOTE(freerunner): Prevent code 500 if requested environment
        # already doesn't exist.
        if not service:
            LOG.warning(_LW('Requested service for instance {} is not found'))
            body = {}
            resp = response.Response(status=410, json_body=body)
            return resp
        env_id = service.environment_id
        token = req.headers["X-Auth-Token"]
        m_cli = _get_muranoclient(token, req)

        # NOTE(starodubcevna): we can track only environment status. it's
        # murano API limitation.
        m_environment = m_cli.environments.get(env_id)
        if m_environment.status == 'ready':
            body = {'state': 'succeeded',
                    'description': 'operation succeed'}
            resp = response.Response(status=200, json_body=body)
        elif m_environment.status in ['pending', 'deleting', 'deploying']:
            body = {'state': 'in progress',
                    'description': 'operation in progress'}
            resp = response.Response(status=202, json_body=body)
        elif m_environment.status in ['deploy failure', 'delete failure']:
            body = {'state': 'failed',
                    'description': '{0}. Please correct it manually'.format(
                        m_environment.status)}
            resp = response.Response(status=200, json_body=body)
        return resp
开发者ID:Aqsamm,项目名称:murano,代码行数:30,代码来源:cfapi.py


示例6: 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.warning(_LW('Could not open session for environment '
                            '<EnvId: {id}>, environment has deploying '
                            'status.').format(id=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 {id}> '
                          'is invalid').format(id=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:NikolayStarodubtsev,项目名称:murano,代码行数:27,代码来源:actions.py


示例7: deprovision

    def deprovision(self, req, instance_id):
        service = db_cf.get_service_for_instance(instance_id)
        if not service:
            return {}

        service_id = service.service_id
        environment_id = service.environment_id
        tenant = service.tenant
        _, _, keystone = self._check_auth(req, tenant)
        # Once we get here we were authorized by keystone
        token = keystone.auth_token
        m_cli = muranoclient(token)

        try:
            session_id = create_session(m_cli, environment_id)
        except exc.HTTPForbidden:
            # FIXME(Kezar): this is a temporary solution, should be replaced
            # with 'incomplete' response for Cloud Foudry as soon as we will
            # know which is right format for it.
            LOG.warning(_LW("Can't create new session. Please remove service "
                            "manually in environment {0}")
                        .format(environment_id))
            return {}

        m_cli.services.delete(environment_id, '/' + service_id, session_id)
        m_cli.sessions.deploy(environment_id, session_id)
        return {}
开发者ID:tianshangjun,项目名称:murano,代码行数:27,代码来源:cfapi.py


示例8: get_keystone_token

    def get_keystone_token(self, user, password):
        # TODO(starodubcevna): picking up project_name and auth_url from
        # section related to Cloud Foundry service broker is probably a duct
        # tape and should be rewritten as soon as we get more non-OpenStack
        # services as murano recipients. The same is right for project and user
        # domain names.

        auth_url = CONF.cfapi.auth_url
        if not (auth_url.endswith('v2.0') or auth_url.endswith('v3')):
            auth_url += '/v3'
        elif auth_url.endswith('v2.0'):
            auth_url = auth_url.replace('v2.0', 'v3')
        elif auth_url.endswith('v3'):
            pass
        else:
            LOG.warning(_LW('Wrong format for service broker auth url'))

        kwargs = {'auth_url': auth_url,
                  'username': user,
                  'password': password,
                  'project_name': CONF.cfapi.tenant,
                  'user_domain_name': CONF.cfapi.user_domain_name,
                  'project_domain_name': CONF.cfapi.project_domain_name}
        password_auth = v3.Password(**kwargs)
        session = ks_session.Session(auth=password_auth)

        self._query_endpoints(password_auth, session)

        return session.get_token()
开发者ID:AleptNamrata,项目名称:murano,代码行数:29,代码来源:ext_context.py


示例9: _from_json

 def _from_json(self, datastring):
     value = datastring
     try:
         LOG.debug("Trying deserialize '{data}' to json".format(data=datastring))
         value = jsonutils.loads(datastring)
     except ValueError:
         LOG.warning(_LW("Unable deserialize to json, using raw text"))
     return value
开发者ID:tianshangjun,项目名称:murano,代码行数:8,代码来源:wsgi.py


示例10: _destroy_object

 def _destroy_object(self, obj):
     methods = obj.type.find_methods(lambda m: m.name == '.destroy')
     for method in methods:
         try:
             method.invoke(obj, (), {}, None)
         except Exception as e:
             LOG.warning(_LW(
                 'Muted exception during execution of .destroy '
                 'on {0}: {1}').format(obj, e), exc_info=True)
开发者ID:AleptNamrata,项目名称:murano,代码行数:9,代码来源:executor.py


示例11: push

    def push(self):
        if self._applied or self._template is None:
            return

        self._tags = ','.join(CONF.heat.stack_tags)
        if 'heat_template_version' not in self._template:
            self._template['heat_template_version'] = HEAT_TEMPLATE_VERSION

        if 'description' not in self._template and self._description:
            self._template['description'] = self._description

        template = copy.deepcopy(self._template)
        LOG.debug('Pushing: {template}'.format(template=template))

        while True:
            try:
                current_status = self._get_status()
                resources = template.get('Resources') or template.get(
                    'resources')
                if current_status == 'NOT_FOUND':
                    if resources is not None:
                        token_client = self._get_token_client()
                        token_client.stacks.create(
                            stack_name=self._name,
                            parameters=self._parameters,
                            template=template,
                            files=self._files,
                            environment=self._hot_environment,
                            disable_rollback=True,
                            tags=self._tags)

                        self._wait_state(
                            lambda status: status == 'CREATE_COMPLETE')
                else:
                    if resources is not None:
                        self._client.stacks.update(
                            stack_id=self._name,
                            parameters=self._parameters,
                            files=self._files,
                            environment=self._hot_environment,
                            template=template,
                            disable_rollback=True,
                            tags=self._tags)
                        self._wait_state(
                            lambda status: status == 'UPDATE_COMPLETE', True)
                    else:
                        self.delete()
            except heat_exc.HTTPConflict as e:
                LOG.warning(_LW('Conflicting operation: {msg}').format(msg=e))
                eventlet.sleep(3)
            else:
                break

        self._applied = not utils.is_different(self._template, template)
开发者ID:ISCAS-VDI,项目名称:murano-base,代码行数:54,代码来源:heat_stack.py


示例12: try_cleanup_cache

    def try_cleanup_cache(self, package_directory=None, current_id=None):
        """Attempts to cleanup cache in a given directory.

        :param package_directory: directory containing cached packages
        :param current_id: optional id of the package to exclude from the list
        of deleted packages
        """
        if not package_directory:
            return

        pkg_ids_listed = set()
        try:
            pkg_ids_listed = set(os.listdir(package_directory))
        except OSError:
            # No directory for this package, probably someone
            # already deleted everything. Anyway nothing to delete
            return

        # if current_id was given: ensure it's not checked for removal
        pkg_ids_listed -= {current_id}

        for pkg_id in pkg_ids_listed:
            stale_directory = os.path.join(package_directory, pkg_id)

            if not os.path.isdir(package_directory):
                continue

            usage_lock_path = os.path.join(self._cache_directory, "{}_usage.lock".format(pkg_id))
            ipc_lock = m_utils.ExclusiveInterProcessLock(path=usage_lock_path, sleep_func=eventlet.sleep)

            try:
                with usage_mem_locks[pkg_id].write_lock(False) as acquired:
                    if not acquired:
                        # the package is in use by other deployment in this
                        # process will do nothing, someone else would delete it
                        continue
                    acquired_ipc_lock = ipc_lock.acquire(blocking=False)
                    if not acquired_ipc_lock:
                        # the package is in use by other deployment in another
                        # process, will do nothing, someone else would delete
                        continue

                    shutil.rmtree(stale_directory, ignore_errors=True)
                    ipc_lock.release()

                    for lock_type in ("usage", "download"):
                        lock_path = os.path.join(self._cache_directory, "{}_{}.lock".format(pkg_id, lock_type))
                        try:
                            os.remove(lock_path)
                        except OSError:
                            LOG.warning(_LW("Couldn't delete lock file: " "{}").format(lock_path))
            except RuntimeError:
                # couldn't upgrade read lock to write-lock. go on.
                continue
开发者ID:olivierlemasle,项目名称:murano,代码行数:54,代码来源:package_loader.py


示例13: delete

    def delete(self, _context):
        client = self._clients.get_heat_client(_context)
        try:
            if not self.current(_context):
                return
            client.stacks.delete(stack_id=self._name)
            self._wait_state(_context, lambda status: status in ("DELETE_COMPLETE", "NOT_FOUND"))
        except heat_exc.NotFound:
            LOG.warn(_LW("Stack {0} already deleted?").format(self._name))

        self._template = {}
        self._applied = True
开发者ID:chenyujie,项目名称:hybrid-murano,代码行数:12,代码来源:heat_stack.py


示例14: delete

    def delete(self):
        client = self._clients.get_heat_client()
        try:
            if not self.current():
                return
            client.stacks.delete(stack_id=self._name)
            self._wait_state(lambda status: status in ("DELETE_COMPLETE", "NOT_FOUND"), wait_progress=True)
        except heat_exc.NotFound:
            LOG.warning(_LW("Stack {stack_name} already deleted?").format(stack_name=self._name))

        self._template = {}
        self._applied = True
开发者ID:Magic-Mirror,项目名称:murano,代码行数:12,代码来源:heat_stack.py


示例15: register_in_loader

 def register_in_loader(self, class_loader):
     for package in six.itervalues(self.packages):
         for class_name, clazz in six.iteritems(package.classes):
             if hasattr(clazz, "_murano_class_name"):
                 LOG.warning(_LW("Class '%(class_name)s' has a MuranoPL "
                                 "name '%(name)s' defined which will be "
                                 "ignored") %
                             dict(class_name=class_name,
                             name=getattr(clazz, "_murano_class_name")))
             LOG.debug("Registering '%s' from '%s' in class loader"
                       % (class_name, package.name))
             class_loader.import_class(clazz, name=class_name)
开发者ID:aawm,项目名称:murano,代码行数:12,代码来源:plugin_loader.py


示例16: _get_filters

def _get_filters(query_params):
    filters = {}
    for param_pair in query_params:
        k, v = param_pair
        if k not in SUPPORTED_PARAMS:
            LOG.warning(_LW("Search by parameter '{name}' "
                            "is not supported. Skipping it.").format(name=k))
            continue

        if k in LIST_PARAMS:
            filters.setdefault(k, []).append(v)
        else:
            filters[k] = v
        order_by = filters.get('order_by', [])
        for i in order_by[:]:
            if ORDER_VALUES and i not in ORDER_VALUES:
                filters['order_by'].remove(i)
                LOG.warning(_LW("Value of 'order_by' parameter is not valid. "
                                "Allowed values are: {values}. Skipping it.")
                            .format(values=", ".join(ORDER_VALUES)))
    return filters
开发者ID:abochkarev,项目名称:murano,代码行数:21,代码来源:catalog.py


示例17: __init__

 def __init__(self, pkg_loader, package_definition):
     super(MuranoPackage, self).__init__(
         pkg_loader, package_definition.name, runtime_version='1.0')
     for class_name, clazz in six.iteritems(package_definition.classes):
         if hasattr(clazz, "_murano_class_name"):
             LOG.warning(_LW("Class '%(class_name)s' has a MuranoPL "
                             "name '%(name)s' defined which will be "
                             "ignored") %
                         dict(class_name=class_name,
                         name=getattr(clazz, "_murano_class_name")))
         LOG.debug("Registering '%s' from '%s' in class loader"
                   % (class_name, package_definition.name))
         self.register_class(clazz, class_name)
开发者ID:Aqsamm,项目名称:murano,代码行数:13,代码来源:extensions_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: _do_add

def _do_add(package, change):
    # Only categories and tags support addition
    path = change["path"][0]
    value = change["value"]

    calculate = {"categories": _get_categories, "tags": _get_tags}
    items_to_add = calculate[path](value)
    for item in items_to_add:
        try:
            getattr(package, path).append(item)
        except AssertionError:
            msg = _LW("One of the specified {0} is already " "associated with a package. Doing nothing.")
            LOG.warning(msg.format(path))
    return package
开发者ID:chenyujie,项目名称:hybrid-murano,代码行数:14,代码来源:api.py


示例20: delete

    def delete(self):
        try:
            if not self.current():
                return
            self._wait_state(lambda s: True)
            self._client.stacks.delete(stack_id=self._name)
            self._wait_state(
                lambda status: status in ('DELETE_COMPLETE', 'NOT_FOUND'),
                wait_progress=True)
        except heat_exc.NotFound:
            LOG.warning(_LW('Stack {stack_name} already deleted?')
                        .format(stack_name=self._name))

        self._template = {}
        self._applied = True
开发者ID:Aqsamm,项目名称:murano,代码行数:15,代码来源:heat_stack.py



注:本文中的murano.common.i18n._LW函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python policy.check函数代码示例发布时间:2022-05-27
下一篇:
Python i18n._LI函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap