当前位置: 首页>>代码示例>>Python>>正文


Python i18n._函数代码示例

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


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

示例1: retry_request

    def retry_request(self, method, action, body=None,
                      headers=None, params=None):
        """Call do_request with the default retry configuration.

        Only idempotent requests should retry failed connection attempts.
        :raises: ConnectionFailed if the maximum # of retries is exceeded
        """
        max_attempts = self.retries + 1
        for i in range(max_attempts):
            try:
                return self.do_request(method, action, body=body,
                                       headers=headers, params=params)
            except exceptions.ConnectionFailed:
                # Exception has already been logged by do_request()
                if i < self.retries:
                    _logger.debug('Retrying connection to Tacker service')
                    time.sleep(self.retry_interval)
                elif self.raise_errors:
                    raise

        if self.retries:
            msg = (_("Failed to connect to Tacker server after %d attempts")
                   % max_attempts)
        else:
            msg = _("Failed to connect Tacker server")

        raise exceptions.ConnectionFailed(reason=msg)
开发者ID:Magic-Mirror,项目名称:python-tackerclient,代码行数:27,代码来源:client.py

示例2: take_action

 def take_action(self, parsed_args):
     client = self.app.client_manager.tackerclient
     failure = False
     deleted_ids = []
     failed_items = {}
     for resource_id in parsed_args.ns:
         try:
             obj = tackerV10.find_resourceid_by_name_or_id(
                 client, _NS, resource_id)
             client.delete_ns(obj)
             deleted_ids.append(resource_id)
         except Exception as e:
             failure = True
             failed_items[resource_id] = e
     if failure:
         msg = ''
         if deleted_ids:
             msg = (_('Successfully deleted %(resource)s(s):'
                      ' %(deleted_list)s') % {'deleted_list':
                                              ', '.join(deleted_ids),
                                              'resource': _NS})
         err_msg = _("\n\nUnable to delete the below"
                     " %s(s):") % _NS
         for failed_id, error in failed_items.iteritems():
             err_msg += (_('\n Cannot delete %(failed_id)s: %(error)s')
                         % {'failed_id': failed_id,
                            'error': error})
         msg += err_msg
         raise exceptions.CommandError(msg)
     else:
         print((_('All specified %(resource)s(s) deleted successfully')
                % {'resource': _NS}))
     return
开发者ID:openstack,项目名称:python-tackerclient,代码行数:33,代码来源:ns.py

示例3: get_parser

 def get_parser(self, prog_name):
     parser = super(CreateNS, self).get_parser(prog_name)
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Name for NS'))
     parser.add_argument(
         '--tenant-id', metavar='TENANT_ID',
         help=_('The owner tenant ID'))
     parser.add_argument(
         '--description',
         help=_('Set description for the NS'))
     nsd_group = parser.add_mutually_exclusive_group(required=True)
     nsd_group.add_argument(
         '--nsd-id',
         help=_('NSD ID to use as template to create NS'))
     nsd_group.add_argument(
         '--nsd-template',
         help=_('NSD file to create NS'))
     nsd_group.add_argument(
         '--nsd-name',
         help=_('NSD name to use as template to create NS'))
     vim_group = parser.add_mutually_exclusive_group()
     vim_group.add_argument(
         '--vim-id',
         help=_('VIM ID to use to create NS on the specified VIM'))
     vim_group.add_argument(
         '--vim-name',
         help=_('VIM name to use to create NS on the specified VIM'))
     parser.add_argument(
         '--vim-region-name',
         help=_('VIM Region to use to create NS on the specified VIM'))
     parser.add_argument(
         '--param-file',
         help=_('Specify parameter YAML file'))
     return parser
开发者ID:openstack,项目名称:python-tackerclient,代码行数:35,代码来源:ns.py

示例4: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Set a name for the VNF'))
     parser.add_argument(
         '--description',
         help=_('Set description for the VNF'))
     vnfd_group = parser.add_mutually_exclusive_group(required=True)
     vnfd_group.add_argument(
         '--vnfd-id',
         help=_('VNFD ID to use as template to create VNF'))
     vnfd_group.add_argument(
         '--vnfd-name',
         help=_('VNFD Name to use as template to create VNF'))
     vnfd_group.add_argument(
         '--vnfd-template',
         help=_("VNFD file to create VNF"))
     vim_group = parser.add_mutually_exclusive_group()
     vim_group.add_argument(
         '--vim-id',
         help=_('VIM ID to use to create VNF on the specified VIM'))
     vim_group.add_argument(
         '--vim-name',
         help=_('VIM name to use to create VNF on the specified VIM'))
     parser.add_argument(
         '--vim-region-name',
         help=_('VIM Region to use to create VNF on the specified VIM'))
     parser.add_argument(
         '--config-file',
         help=_('YAML file with VNF configuration'))
     parser.add_argument(
         '--param-file',
         help=_('Specify parameter yaml file'))
开发者ID:openstack,项目名称:python-tackerclient,代码行数:33,代码来源:vnf.py

示例5: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument('--vnfd-file', help=_('Specify VNFD file'))
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Set a name for the VNFD'))
     parser.add_argument(
         '--description',
         help=_('Set a description for the VNFD'))
开发者ID:openstack,项目名称:python-tackerclient,代码行数:8,代码来源:vnfd.py

示例6: get_parser

 def get_parser(self, prog_name):
     parser = super(ListSFC, self).get_parser(prog_name)
     parser.add_argument(
         '--nfp-id',
         help=_('List SFC(s) with specific nfp id'))
     parser.add_argument(
         '--tenant-id', metavar='TENANT_ID',
         help=_('The owner tenant ID or project ID'))
     return parser
开发者ID:openstack,项目名称:python-tackerclient,代码行数:9,代码来源:vnffg.py

示例7: check_non_negative_int

def check_non_negative_int(value):
    try:
        value = int(value)
    except ValueError:
        raise argparse.ArgumentTypeError(_("invalid int value: %r") % value)
    if value < 0:
        raise argparse.ArgumentTypeError(_("input value %d is negative") %
                                         value)
    return value
开发者ID:openstack,项目名称:python-tackerclient,代码行数:9,代码来源:shell.py

示例8: get_parser

 def get_parser(self, prog_name):
     parser = super(ListVNFResources, self).get_parser(prog_name)
     if self.allow_names:
         help_str = _('ID or name of %s to look up')
     else:
         help_str = _('ID of %s to look up')
     parser.add_argument(
         'id', metavar=self.get_id(),
         help=help_str % self.resource)
     return parser
开发者ID:openstack,项目名称:python-tackerclient,代码行数:10,代码来源:vnf.py

示例9: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Set a name for the NS'))
     parser.add_argument(
         '--description',
         help=_('Set description for the NS'))
     nsd_group = parser.add_mutually_exclusive_group(required=True)
     nsd_group.add_argument(
         '--nsd-id',
         help=_('NSD ID to use as template to create NS'))
     nsd_group.add_argument(
         '--nsd-template',
         help=_('NSD file to create NS'))
     nsd_group.add_argument(
         '--nsd-name',
         help=_('NSD name to use as template to create NS'))
     vim_group = parser.add_mutually_exclusive_group()
     vim_group.add_argument(
         '--vim-id',
         help=_('VIM ID to use to create NS on the specified VIM'))
     vim_group.add_argument(
         '--vim-name',
         help=_('VIM name to use to create NS on the specified VIM'))
     parser.add_argument(
         '--vim-region-name',
         help=_('VIM Region to use to create NS on the specified VIM'))
     parser.add_argument(
         '--param-file',
         help=_('Specify parameter yaml file'))
开发者ID:openstack,项目名称:python-tackerclient,代码行数:30,代码来源:ns.py

示例10: get_parser

 def get_parser(self, prog_name):
     parser = super(DeleteVNF, self).get_parser(prog_name)
     parser.add_argument(
         _VNF,
         metavar="<VNF>",
         nargs="+",
         help=_("VNF(s) to delete (name or ID)"))
     parser.add_argument(
         '--force',
         default=False,
         action='store_true',
         help=_('Force delete VNF instance'))
     return parser
开发者ID:openstack,项目名称:python-tackerclient,代码行数:13,代码来源:vnf.py

示例11: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         '--vnffgd-template',
         help=_('VNFFGD file to update VNFFG')
     )
     parser.add_argument(
         '--vnf-mapping',
         help=_('List of logical VNFD name to VNF instance name mapping.  '
                'Example: VNF1:my_vnf1,VNF2:my_vnf2'))
     parser.add_argument(
         '--symmetrical',
         action='store_true',
         default=False,
         help=_('Should a reverse path be created for the NFP'))
开发者ID:openstack,项目名称:python-tackerclient,代码行数:14,代码来源:vnffg.py

示例12: build_option_parser

    def build_option_parser(self, description, version):
        """Return an argparse option parser for this application.

        Subclasses may override this method to extend
        the parser with more global options.

        :param description: full description of the application
        :paramtype description: str
        :param version: version number for the application
        :paramtype version: str
        """
        parser = argparse.ArgumentParser(
            description=description,
            add_help=False, )
        parser.add_argument(
            '--version',
            action='version',
            version=__version__, )
        parser.add_argument(
            '-v', '--verbose', '--debug',
            action='count',
            dest='verbose_level',
            default=self.DEFAULT_VERBOSE_LEVEL,
            help=_('Increase verbosity of output and show tracebacks on'
                   ' errors. You can repeat this option.'))
        parser.add_argument(
            '-q', '--quiet',
            action='store_const',
            dest='verbose_level',
            const=0,
            help=_('Suppress output except warnings and errors.'))
        parser.add_argument(
            '-h', '--help',
            action=HelpAction,
            nargs=0,
            default=self,  # tricky
            help=_("Show this help message and exit."))
        parser.add_argument(
            '-r', '--retries',
            metavar="NUM",
            type=check_non_negative_int,
            default=0,
            help=_("How many times the request to the Tacker server should "
                   "be retried if it fails."))
        # FIXME(bklei): this method should come from python-keystoneclient
        self._append_global_identity_args(parser)

        return parser
开发者ID:openstack,项目名称:python-tackerclient,代码行数:48,代码来源:shell.py

示例13: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         '--config-file',
         required=True,
         help=_('YAML file with VIM configuration parameters'))
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Set a name for the VIM'))
     parser.add_argument(
         '--description',
         help=_('Set a description for the VIM'))
     parser.add_argument(
         '--is-default',
         action='store_true',
         default=False,
         help=_('Set as default VIM'))
开发者ID:openstack,项目名称:python-tackerclient,代码行数:16,代码来源:vim.py

示例14: _from_xml

 def _from_xml(self, datastring):
     if datastring is None:
         return None
     plurals = set(self.metadata.get("plurals", {}))
     try:
         node = etree.fromstring(datastring)
         root_tag = self._get_key(node.tag)
         links = self._get_links(root_tag, node)
         result = self._from_xml_node(node, plurals)
         # There is no case where root_tag = constants.VIRTUAL_ROOT_KEY
         # and links is not None because of the way data are serialized
         if root_tag == constants.VIRTUAL_ROOT_KEY:
             return result
         return dict({root_tag: result}, **links)
     except Exception as e:
         parseError = False
         # Python2.7
         if hasattr(etree, "ParseError") and isinstance(e, getattr(etree, "ParseError")):
             parseError = True
         # Python2.6
         elif isinstance(e, expat.ExpatError):
             parseError = True
         if parseError:
             msg = _("Cannot understand XML")
             raise exception.MalformedResponseBody(reason=msg)
         else:
             raise
开发者ID:trozet,项目名称:python-tackerclient,代码行数:27,代码来源:serializer.py

示例15: get_parser

 def get_parser(self, prog_name):
     parser = super(CreateNSD, self).get_parser(prog_name)
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Name for NSD'))
     parser.add_argument(
         '--tenant-id', metavar='TENANT_ID',
         help=_('The owner tenant ID or project ID'))
     parser.add_argument(
         '--nsd-file',
         required=True,
         help=_('YAML file with NSD parameters'))
     parser.add_argument(
         '--description',
         help=_('Set a description for the NSD'))
     return parser
开发者ID:openstack,项目名称:python-tackerclient,代码行数:16,代码来源:nsd.py


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