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

Python _i18n._函数代码示例

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

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



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

示例1: load_class_by_alias_or_classname

def load_class_by_alias_or_classname(namespace, name):
    """Load class using stevedore alias or the class name

    Load class using the stevedore driver manager
    :param namespace: namespace where the alias is defined
    :param name: alias or class name of the class to be loaded
    :returns: class if calls can be loaded
    :raises ImportError: if class cannot be loaded
    """

    if not name:
        LOG.error("Alias or class name is not set")
        raise ImportError(_("Class not found."))
    try:
        # Try to resolve class by alias
        mgr = driver.DriverManager(namespace, name)
        class_to_load = mgr.driver
    except RuntimeError:
        e1_info = sys.exc_info()
        # Fallback to class name
        try:
            class_to_load = importutils.import_class(name)
        except (ImportError, ValueError):
            LOG.error("Error loading class by alias",
                      exc_info=e1_info)
            LOG.error("Error loading class by class name",
                      exc_info=True)
            raise ImportError(_("Class not found."))
    return class_to_load
开发者ID:openstack,项目名称:tacker,代码行数:29,代码来源:utils.py


示例2: _create_vnffg_post

    def _create_vnffg_post(self, context, sfc_instance_id,
                           fc_instance_id, vnffg_dict):
        LOG.debug(_('SFC created instance is %s'), sfc_instance_id)
        LOG.debug(_('Flow Classifier created instance is %s'),
                  fc_instance_id)
        nfp_dict = self.get_nfp(context, vnffg_dict['forwarding_paths'])
        sfc_id = nfp_dict['chain_id']
        classifier_id = nfp_dict['classifier_id']
        with context.session.begin(subtransactions=True):
            query = (self._model_query(context, VnffgChain).
                     filter(VnffgChain.id == sfc_id).
                     filter(VnffgChain.status == constants.PENDING_CREATE).
                     one())
            query.update({'instance_id': sfc_instance_id})
            if sfc_instance_id is None:
                query.update({'status': constants.ERROR})
            else:
                query.update({'status': constants.ACTIVE})

            query = (self._model_query(context, VnffgClassifier).
                     filter(VnffgClassifier.id == classifier_id).
                     filter(VnffgClassifier.status ==
                            constants.PENDING_CREATE).
                     one())
            query.update({'instance_id': fc_instance_id})

            if fc_instance_id is None:
                query.update({'status': constants.ERROR})
            else:
                query.update({'status': constants.ACTIVE})
开发者ID:pineunity,项目名称:tacker,代码行数:30,代码来源:vnffg_db.py


示例3: _make_vnffg_dict

 def _make_vnffg_dict(self, vnffg_db, fields=None):
     LOG.debug(_('vnffg_db %s'), vnffg_db)
     LOG.debug(_('vnffg_db nfp %s'), vnffg_db.forwarding_paths)
     res = {
         'forwarding_paths': vnffg_db.forwarding_paths[0]['id']
     }
     key_list = ('id', 'tenant_id', 'name', 'description',
                 'vnf_mapping', 'status', 'vnffgd_id')
     res.update((key, vnffg_db[key]) for key in key_list)
     return self._fields(res, fields)
开发者ID:pineunity,项目名称:tacker,代码行数:10,代码来源:vnffg_db.py


示例4: _make_classifier_dict

 def _make_classifier_dict(self, classifier_db, fields=None):
     LOG.debug(_('classifier_db %s'), classifier_db)
     LOG.debug(_('classifier_db match %s'), classifier_db.match)
     res = {
         'match': self._make_acl_match_dict(classifier_db.match)
     }
     key_list = ('id', 'tenant_id', 'instance_id', 'status', 'chain_id',
                 'nfp_id')
     res.update((key, classifier_db[key]) for key in key_list)
     return self._fields(res, fields)
开发者ID:pineunity,项目名称:tacker,代码行数:10,代码来源:vnffg_db.py


示例5: delete_vim_auth

    def delete_vim_auth(self, vim_id):
        """Delete vim information

         Delete vim key stored in file system
         """
        LOG.debug(_('Attempting to delete key for vim id %s'), vim_id)
        key_file = os.path.join(CONF.vim_keys.openstack, vim_id)
        try:
            os.remove(key_file)
            LOG.debug(_('VIM key deleted successfully for vim %s'), vim_id)
        except OSError:
            LOG.warning(_('VIM key deletion unsuccessful for vim %s'), vim_id)
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:12,代码来源:openstack_driver.py


示例6: _get_vnf_mapping

    def _get_vnf_mapping(self, context, vnf_mapping, vnf_members):
        """Creates/validates a mapping of VNFD names to VNF IDs for NFP.

        :param context: SQL session context
        :param vnf_mapping: dict of requested VNFD:VNF_ID mappings
        :param vnf_members: list of constituent VNFs from a VNFFG
        :return: dict of VNFD:VNF_ID mappings
        """
        vnfm_plugin = manager.TackerManager.get_service_plugins()['VNFM']
        new_mapping = dict()

        for vnfd in vnf_members:
            # there should only be one ID returned for a unique name
            try:
                vnfd_id = vnfm_plugin.get_vnfds(context, {'name': [vnfd]},
                                                fields=['id']).pop()['id']
            except Exception:
                raise nfvo.VnffgdVnfdNotFoundException(vnfd_name=vnfd)
            if vnfd_id is None:
                raise nfvo.VnffgdVnfdNotFoundException(vnfd_name=vnfd)
            else:
                # if no VNF mapping, we need to abstractly look for instances
                # that match VNFD
                if vnf_mapping is None or vnfd not in vnf_mapping.keys():
                    # find suitable VNFs from vnfd_id
                    LOG.debug(_('Searching VNFS with id %s'), vnfd_id)
                    vnf_list = vnfm_plugin.get_vnfs(context,
                                                    {'vnfd_id': [vnfd_id]},
                                                    fields=['id'])
                    if len(vnf_list) == 0:
                        raise nfvo.VnffgInvalidMappingException(vnfd_name=vnfd)
                    else:
                        LOG.debug(_('Matching VNFs found %s'), vnf_list)
                        vnf_list = [vnf['id'] for vnf in vnf_list]
                    if len(vnf_list) > 1:
                        new_mapping[vnfd] = random.choice(vnf_list)
                    else:
                        new_mapping[vnfd] = vnf_list[0]
                # if VNF mapping, validate instances exist and match the VNFD
                else:
                    vnf_vnfd = vnfm_plugin.get_vnf(context, vnf_mapping[vnfd],
                                                   fields=['vnfd_id'])
                    if vnf_vnfd is not None:
                        vnf_vnfd_id = vnf_vnfd['vnfd_id']
                    else:
                        raise nfvo.VnffgInvalidMappingException(vnfd_name=vnfd)
                    if vnfd_id != vnf_vnfd_id:
                        raise nfvo.VnffgInvalidMappingException(vnfd_name=vnfd)
                    else:
                        new_mapping[vnfd] = vnf_mapping.pop(vnfd)
        self._validate_vim(context, new_mapping.values())
        return new_mapping
开发者ID:pineunity,项目名称:tacker,代码行数:52,代码来源:vnffg_db.py


示例7: delete_chain

    def delete_chain(self, chain_id, auth_attr=None):
        if not auth_attr:
            LOG.warning(_("auth information required for n-sfc driver"))
            return None

        neutronclient_ = NeutronClient(auth_attr)
        neutronclient_.port_chain_delete(chain_id)
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:7,代码来源:openstack_driver.py


示例8: flow_classifier_create

 def flow_classifier_create(self, fc_dict):
     LOG.debug(_("fc_dict passed is {fc_dict}").format(fc_dict=fc_dict))
     fc = self.client.create_flow_classifier({'flow_classifier': fc_dict})
     if fc:
         return fc['flow_classifier']['id']
     else:
         return None
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:7,代码来源:openstack_driver.py


示例9: _validate_auth_url

 def _validate_auth_url(self, auth_url):
     try:
         keystone_version = self.keystone.get_version(auth_url)
     except Exception as e:
         LOG.error(_('VIM Auth URL invalid'))
         raise nfvo.VimConnectionException(message=e.message)
     return keystone_version
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:7,代码来源:openstack_driver.py


示例10: _make_chain_dict

 def _make_chain_dict(self, chain_db, fields=None):
     LOG.debug(_('chain_db %s'), chain_db)
     res = {}
     key_list = ('id', 'tenant_id', 'symmetrical', 'status', 'chain',
                 'path_id', 'nfp_id', 'instance_id')
     res.update((key, chain_db[key]) for key in key_list)
     return self._fields(res, fields)
开发者ID:pineunity,项目名称:tacker,代码行数:7,代码来源:vnffg_db.py


示例11: _make_cluster_member_dict

 def _make_cluster_member_dict(self, cluster_id, index, role, vnf_info):
     cluster_member_dict = {}
     cluster_member_dict['cluster_id'] = cluster_id
     cluster_member_dict['index'] = index
     cluster_member_dict['role'] = role
     cluster_member_dict['vnf_info'] = vnf_info
     LOG.debug(_("_make_cluster_member_dict c : %s"), cluster_member_dict)
     return cluster_member_dict
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:8,代码来源:nfvo_plugin.py


示例12: validate_tosca

    def validate_tosca(self, template):
        if "tosca_definitions_version" not in template:
            raise nfvo.ToscaParserFailed(
                error_msg_details='tosca_definitions_version missing in '
                                  'template'
            )

        LOG.debug(_('template yaml: %s'), template)

        toscautils.updateimports(template)

        try:
            tosca_template.ToscaTemplate(
                a_file=False, yaml_dict_tpl=template)
        except Exception as e:
            LOG.exception(_("tosca-parser error: %s"), str(e))
            raise nfvo.ToscaParserFailed(error_msg_details=str(e))
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:17,代码来源:nfvo_plugin.py


示例13: delete_flow_classifier

    def delete_flow_classifier(self, fc_id, auth_attr=None):
        if not auth_attr:
            LOG.warning(_("auth information required for n-sfc driver"))
            raise EnvironmentError('auth attribute required for'
                                   ' networking-sfc driver')

        neutronclient_ = NeutronClient(auth_attr)
        neutronclient_.flow_classifier_delete(fc_id)
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:8,代码来源:openstack_driver.py


示例14: _make_nfp_dict

 def _make_nfp_dict(self, nfp_db, fields=None):
     LOG.debug(_('nfp_db %s'), nfp_db)
     res = {'chain_id': nfp_db.chain['id'],
            'classifier_id': nfp_db.classifier['id']}
     key_list = ('name', 'id', 'tenant_id', 'symmetrical', 'status',
                 'path_id', 'vnffg_id')
     res.update((key, nfp_db[key]) for key in key_list)
     return self._fields(res, fields)
开发者ID:pineunity,项目名称:tacker,代码行数:8,代码来源:vnffg_db.py


示例15: create_vnffgd

    def create_vnffgd(self, context, vnffgd):
        template = vnffgd['vnffgd']
        LOG.debug(_('template %s'), template)
        tenant_id = self._get_tenant_id_for_create(context, template)

        with context.session.begin(subtransactions=True):
            template_id = str(uuid.uuid4())
            template_db = VnffgTemplate(
                id=template_id,
                tenant_id=tenant_id,
                name=template.get('name'),
                description=template.get('description'),
                template=template.get('template'))
            context.session.add(template_db)

        LOG.debug(_('template_db %(template_db)s'),
                  {'template_db': template_db})
        return self._make_template_dict(template_db)
开发者ID:pineunity,项目名称:tacker,代码行数:18,代码来源:vnffg_db.py


示例16: _get_policy_property

 def _get_policy_property(self, vnfd_dict, prop_name):
         polices = vnfd_dict['topology_template'].get('policies', [])
         prop = None
         for policy_dict in polices:
             for name, policy in policy_dict.items():
                 if(policy.get('type') == constants.POLICY_LOADBALANCE):
                     prop = policy.get('properties')[prop_name]
                     LOG.debug(_("create_vnfcluster prop: %s"), prop)
         return prop
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:9,代码来源:nfvo_plugin.py


示例17: _create_secret_ref

    def _create_secret_ref(self, object_id):
        """Creates the URL required for accessing a secret.

        :param object_id: the UUID of the key to copy
        :return: the URL of the requested secret
        """
        if not object_id:
            msg = _("Key ID is None")
            raise exception.KeyManagerError(reason=msg)
        return "%ssecrets/%s" % (self._base_url, object_id)
开发者ID:openstack,项目名称:tacker,代码行数:10,代码来源:barbican_key_manager.py


示例18: update_chain

 def update_chain(self, chain_id, fc_ids, vnfs,
                  symmetrical=False, auth_attr=None):
     # TODO(s3wong): chain can be updated either for
     # the list of fc and/or list of port-pair-group
     # since n-sfc driver does NOT track the ppg id
     # it will look it up (or reconstruct) from
     # networking-sfc DB --- but the caveat is that
     # the VNF name MUST be unique
     LOG.warning(_("n-sfc driver does not support sf chain update"))
     raise NotImplementedError('sf chain update not supported')
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:10,代码来源:openstack_driver.py


示例19: register_vim

    def register_vim(self, vim_obj):
        """Validate and register VIM

        Store VIM information in Tacker for
        VNF placements
        """
        ks_client = self.authenticate_vim(vim_obj)
        self.discover_placement_attr(vim_obj, ks_client)
        self.encode_vim_auth(vim_obj['id'], vim_obj['auth_cred'])
        LOG.debug(_('VIM registration completed for %s'), vim_obj)
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:10,代码来源:openstack_driver.py


示例20: create_flow_classifier

    def create_flow_classifier(self, name, fc, symmetrical=False,
                               auth_attr=None):
        def _translate_ip_protocol(ip_proto):
            if ip_proto == '1':
                return 'icmp'
            elif ip_proto == '6':
                return 'tcp'
            elif ip_proto == '17':
                return 'udp'
            else:
                return None

        if not auth_attr:
            LOG.warning(_("auth information required for n-sfc driver"))
            return None

        if symmetrical:
            LOG.warning(_("n-sfc driver does not support symmetrical"))
            raise NotImplementedError('symmetrical chain not supported')
        LOG.debug(_('fc passed is %s'), fc)
        sfc_classifier_params = {}
        for field in fc:
            if field in FC_MAP:
                sfc_classifier_params[FC_MAP[field]] = fc[field]
            elif field == 'ip_proto':
                protocol = _translate_ip_protocol(str(fc[field]))
                if not protocol:
                    raise ValueError('protocol %s not supported' % fc[field])
                sfc_classifier_params['protocol'] = protocol
            else:
                LOG.warning(_("flow classifier %s not supported by "
                              "networking-sfc driver"), field)

        LOG.debug(_('sfc_classifier_params is %s'), sfc_classifier_params)
        if len(sfc_classifier_params) > 0:
            neutronclient_ = NeutronClient(auth_attr)

            fc_id = neutronclient_.flow_classifier_create(
                sfc_classifier_params)
            return fc_id

        raise ValueError('empty match field for input flow classifier')
开发者ID:K-OpenNet,项目名称:OPNFV-Cluster,代码行数:42,代码来源:openstack_driver.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python context.get_admin_context函数代码示例发布时间:2022-05-27
下一篇:
Python config.CONFIG类代码示例发布时间: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