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

Python _i18n._函数代码示例

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

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



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

示例1: validate_dpd_dict

def validate_dpd_dict(dpd_dict):
    for key, value in dpd_dict.items():
        if key not in DPD_SUPPORTED_KEYS:
            message = _(
                "DPD Dictionary KeyError: "
                "Reason-Invalid DPD key : "
                "'%(key)s' not in %(supported_key)s") % {
                    'key': key, 'supported_key': DPD_SUPPORTED_KEYS}
            raise exceptions.CommandError(message)
        if key == 'action' and value not in DPD_SUPPORTED_ACTIONS:
            message = _(
                "DPD Dictionary ValueError: "
                "Reason-Invalid DPD action : "
                "'%(key_value)s' not in %(supported_action)s") % {
                    'key_value': value,
                    'supported_action': DPD_SUPPORTED_ACTIONS}
            raise exceptions.CommandError(message)
        if key in ('interval', 'timeout'):
            try:
                if int(value) <= 0:
                    raise ValueError()
            except ValueError:
                message = _(
                    "DPD Dictionary ValueError: "
                    "Reason-Invalid positive integer value: "
                    "'%(key)s' = %(value)s") % {
                        'key': key, 'value': value}
                raise exceptions.CommandError(message)
            else:
                dpd_dict[key] = int(value)
    return
开发者ID:huntxu,项目名称:python-neutronclient,代码行数:31,代码来源:utils.py


示例2: get_parser

 def get_parser(self, prog_name):
     parser = super(CreateBgpPeer, self).get_parser(prog_name)
     parser.add_argument(
         'name',
         metavar='<name>',
         help=_("Name of the BGP peer to create"))
     parser.add_argument(
         '--peer-ip',
         metavar='<peer-ip-address>',
         required=True,
         help=_("Peer IP address"))
     parser.add_argument(
         '--remote-as',
         required=True,
         metavar='<peer-remote-as>',
         help=_("Peer AS number. (Integer in [%(min_val)s, %(max_val)s] "
                "is allowed)") % {'min_val': constants.MIN_AS_NUM,
                                  'max_val': constants.MAX_AS_NUM})
     parser.add_argument(
         '--auth-type',
         metavar='<peer-auth-type>',
         choices=['none', 'md5'],
         type=nc_utils.convert_to_lowercase,
         default='none',
         help=_("Authentication algorithm. Supported algorithms: "
                "none (default), md5"))
     parser.add_argument(
         '--password',
         metavar='<auth-password>',
         help=_("Authentication password"))
     nc_osc_utils.add_project_owner_option_to_parser(parser)
     return parser
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:32,代码来源:bgp_peer.py


示例3: _get_common_parser

def _get_common_parser(parser):
    parser.add_argument(
        '--description',
        metavar='<description>',
        help=_('Description for the VPN service'))
    parser.add_argument(
        '--subnet',
        metavar='<subnet>',
        help=_('Local private subnet (name or ID)'))
    parser.add_argument(
        '--flavor',
        metavar='<flavor>',
        help=_('Flavor for the VPN service (name or ID)'))
    admin_group = parser.add_mutually_exclusive_group()
    admin_group.add_argument(
        '--enable',
        action='store_true',
        help=_("Enable VPN service")
    )
    admin_group.add_argument(
        '--disable',
        action='store_true',
        help=_("Disable VPN service")
    )
    return parser
开发者ID:huntxu,项目名称:python-neutronclient,代码行数:25,代码来源:vpnservice.py


示例4: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         '--name',
         help=_('Name of security group.'))
     parser.add_argument(
         '--description',
         help=_('Description of security group.'))
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:7,代码来源:securitygroup.py


示例5: updatable_args2body

def updatable_args2body(parsed_args, body, for_create=True, ip_version=None):
    if parsed_args.disable_dhcp and parsed_args.enable_dhcp:
        raise exceptions.CommandError(_(
            "You cannot enable and disable DHCP at the same time."))

    neutronV20.update_dict(parsed_args, body,
                           ['name', 'allocation_pools',
                            'host_routes', 'dns_nameservers',
                            'description'])
    if parsed_args.no_gateway:
        body['gateway_ip'] = None
    elif parsed_args.gateway:
        body['gateway_ip'] = parsed_args.gateway
    if parsed_args.disable_dhcp:
        body['enable_dhcp'] = False
    if parsed_args.enable_dhcp:
        body['enable_dhcp'] = True
    if for_create and parsed_args.ipv6_ra_mode:
        if ip_version == 4:
            raise exceptions.CommandError(_("--ipv6-ra-mode is invalid "
                                            "when --ip-version is 4"))
        body['ipv6_ra_mode'] = parsed_args.ipv6_ra_mode
    if for_create and parsed_args.ipv6_address_mode:
        if ip_version == 4:
            raise exceptions.CommandError(_("--ipv6-address-mode is "
                                            "invalid when --ip-version "
                                            "is 4"))
        body['ipv6_address_mode'] = parsed_args.ipv6_address_mode
开发者ID:ChameleonCloud,项目名称:python-neutronclient,代码行数:28,代码来源:subnet.py


示例6: add_known_arguments

 def add_known_arguments(self, parser):
     _add_common_args(parser)
     parser.add_argument(
         '--admin-state-down',
         dest='admin_state', action='store_false',
         help=_('Set admin state up to false.'))
     parser.add_argument(
         '--listener',
         help=_('Listener whose default-pool should be set to this pool. '
                'At least one of --listener or --loadbalancer must be '
                'specified.'))
     parser.add_argument(
         '--loadbalancer',
         help=_('Loadbalancer with which this pool should be associated. '
                'At least one of --listener or --loadbalancer must be '
                'specified.'))
     parser.add_argument(
         '--protocol',
         type=utils.convert_to_uppercase,
         required=True,
         choices=['HTTP', 'HTTPS', 'TCP'],
         help=_('Protocol for balancing.'))
     parser.add_argument(
         '--session-persistence',
         metavar='type=TYPE[,cookie_name=COOKIE_NAME]',
         type=utils.str2dict_type(required_keys=['type'],
                                  optional_keys=['cookie_name']),
         help=_('The type of session persistence to use and associated '
                'cookie name.'))
开发者ID:Juniper,项目名称:python-neutronclient,代码行数:29,代码来源:pool.py


示例7: run

 def run(self, parsed_args):
     self.log.debug('run(%s)', parsed_args)
     self.set_extra_attrs(parsed_args)
     neutron_client = self.get_client()
     _extra_values = parse_args_to_dict(self.values_specs)
     _merge_args(self, parsed_args, _extra_values,
                 self.values_specs)
     body = self.args2body(parsed_args)
     if self.resource in body:
         body[self.resource].update(_extra_values)
     else:
         body[self.resource] = _extra_values
     if not body[self.resource]:
         raise exceptions.CommandError(
             _("Must specify new values to update %s") %
             self.cmd_resource)
     if self.allow_names:
         _id = find_resourceid_by_name_or_id(
             neutron_client, self.resource, parsed_args.id,
             cmd_resource=self.cmd_resource, parent_id=self.parent_id)
     else:
         _id = find_resourceid_by_id(
             neutron_client, self.resource, parsed_args.id,
             self.cmd_resource, self.parent_id)
     obj_updater = getattr(neutron_client,
                           "update_%s" % self.cmd_resource)
     if self.parent_id:
         obj_updater(_id, self.parent_id, body)
     else:
         obj_updater(_id, body)
     print((_('Updated %(resource)s: %(id)s') %
            {'id': parsed_args.id, 'resource': self.resource}),
           file=self.app.stdout)
     return
开发者ID:doonhammer,项目名称:python-neutronclient,代码行数:34,代码来源:__init__.py


示例8: _get_common_parser

    def _get_common_parser(self, parser):
        """Adds to parser arguments common to create, set and unset commands.

        :params ArgumentParser parser: argparse object contains all command's
                                       arguments
        """
        ADVERTISE_ROUTES = _("Routes will be advertised to the "
                             "BGP VPN%s") % (
                                 _(' (default)') if self._action == 'create'
                                 else "")
        NOT_ADVERTISE_ROUTES = _("Routes from the router will not be "
                                 "advertised to the BGP VPN")

        group_advertise_extra_routes = parser.add_mutually_exclusive_group()
        group_advertise_extra_routes.add_argument(
            '--advertise_extra_routes',
            action='store_true',
            help=NOT_ADVERTISE_ROUTES if self._action == 'unset'
            else ADVERTISE_ROUTES,
        )
        group_advertise_extra_routes.add_argument(
            '--no-advertise_extra_routes',
            action='store_true',
            help=ADVERTISE_ROUTES if self._action == 'unset'
            else NOT_ADVERTISE_ROUTES,
        )
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:26,代码来源:router_association.py


示例9: _add_common_args

def _add_common_args(parser, is_create=True):
        parser.add_argument(
            '--type',
            required=is_create,
            type=utils.convert_to_uppercase,
            choices=['HOST_NAME', 'PATH', 'FILE_TYPE', 'HEADER', 'COOKIE'],
            help=_('Rule type.'))
        parser.add_argument(
            '--compare-type',
            required=is_create,
            type=utils.convert_to_uppercase,
            choices=['REGEX', 'STARTS_WITH', 'ENDS_WITH',
                     'CONTAINS', 'EQUAL_TO'],
            help=_('Rule compare type.'))
        parser.add_argument(
            '--invert-compare',
            dest='invert',
            action='store_true',
            help=_('Invert the compare type.'))
        parser.add_argument(
            '--key',
            help=_('Key to compare.'
                   ' Relevant for HEADER and COOKIE types only.'))
        parser.add_argument(
            '--value',
            required=is_create,
            help=_('Value to compare.'))
开发者ID:ChameleonCloud,项目名称:python-neutronclient,代码行数:27,代码来源:l7rule.py


示例10: add_bandwidth_limit_arguments

def add_bandwidth_limit_arguments(parser):
    parser.add_argument(
        '--max-kbps',
        help=_('max bandwidth in kbps.'))
    parser.add_argument(
        '--max-burst-kbps',
        help=_('max burst bandwidth in kbps.'))
开发者ID:ChameleonCloud,项目名称:python-neutronclient,代码行数:7,代码来源:bandwidth_limit_rule.py


示例11: add_common_args

def add_common_args(parser):
    parser.add_argument(
        '--name',
        help=_('Name for the VPN service.'))
    parser.add_argument(
        '--description',
        help=_('Description for the VPN service.'))
开发者ID:Juniper,项目名称:python-neutronclient,代码行数:7,代码来源:vpnservice.py


示例12: get_parser

 def get_parser(self, prog_name):
     parser = super(SetNetworkTrunk, self).get_parser(prog_name)
     parser.add_argument(
         'trunk',
         metavar="<trunk>",
         help=_("Trunk to modify (name or ID)")
     )
     parser.add_argument(
         '--name',
         metavar="<name>",
         help=_("Set trunk name")
     )
     parser.add_argument(
         '--subport',
         metavar='<port=,segmentation-type=,segmentation-id=>',
         action=parseractions.MultiKeyValueAction, dest='set_subports',
         help=_("Subport to add. Subport is of form "
                "\'port=<name or ID>,segmentation-type=,segmentation-ID=\'"
                "(--subport) option can be repeated)")
     )
     admin_group = parser.add_mutually_exclusive_group()
     admin_group.add_argument(
         '--enable',
         action='store_true',
         help=_("Enable trunk")
     )
     admin_group.add_argument(
         '--disable',
         action='store_true',
         help=_("Disable trunk")
     )
     return parser
开发者ID:lmaycotte,项目名称:python-neutronclient,代码行数:32,代码来源:network_trunk.py


示例13: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         'name',
         metavar='NAME',
         help=_('Name of the BGP peer to create.'))
     parser.add_argument(
         '--peer-ip',
         metavar='PEER_IP_ADDRESS',
         required=True,
         help=_('Peer IP address.'))
     parser.add_argument(
         '--remote-as',
         required=True,
         metavar='PEER_REMOTE_AS',
         help=_('Peer AS number. (Integer in [%(min_val)s, %(max_val)s] '
                'is allowed.)') %
         {'min_val': neutronv20.bgp.speaker.MIN_AS_NUM,
          'max_val': neutronv20.bgp.speaker.MAX_AS_NUM})
     parser.add_argument(
         '--auth-type',
         metavar='PEER_AUTH_TYPE',
         choices=['none', 'md5'],
         default='none',
         type=utils.convert_to_lowercase,
         help=_('Authentication algorithm. Supported algorithms: '
                'none(default), md5'))
     parser.add_argument(
         '--password',
         metavar='AUTH_PASSWORD',
         help=_('Authentication password.'))
开发者ID:ChameleonCloud,项目名称:python-neutronclient,代码行数:30,代码来源:peer.py


示例14: validate_lifetime_dict

def validate_lifetime_dict(lifetime_dict):

    for key, value in lifetime_dict.items():
        if key not in lifetime_keys:
            message = _(
                "Lifetime Dictionary KeyError: "
                "Reason-Invalid unit key : "
                "'%(key)s' not in %(supported_key)s") % {
                    'key': key, 'supported_key': lifetime_keys}
            raise exceptions.CommandError(message)
        if key == 'units' and value not in lifetime_units:
            message = _(
                "Lifetime Dictionary ValueError: "
                "Reason-Invalid units : "
                "'%(key_value)s' not in %(supported_units)s") % {
                    'key_value': key, 'supported_units': lifetime_units}
            raise exceptions.CommandError(message)
        if key == 'value':
            try:
                if int(value) < 60:
                    raise ValueError()
            except ValueError:
                message = _(
                    "Lifetime Dictionary ValueError: "
                    "Reason-Invalid value should be at least 60:"
                    "'%(key_value)s' = %(value)s") % {
                        'key_value': key, 'value': value}
                raise exceptions.CommandError(message)
            else:
                lifetime_dict['value'] = int(value)
    return
开发者ID:huntxu,项目名称:python-neutronclient,代码行数:31,代码来源:utils.py


示例15: _common_args2body

def _common_args2body(client, parsed_args, is_create=True):
    if parsed_args.redirect_url:
        if parsed_args.action != 'REDIRECT_TO_URL':
            raise exceptions.CommandError(_('Action must be REDIRECT_TO_URL'))
    if parsed_args.redirect_pool:
        if parsed_args.action != 'REDIRECT_TO_POOL':
            raise exceptions.CommandError(_('Action must be REDIRECT_TO_POOL'))
        parsed_args.redirect_pool_id = _get_pool_id(
            client, parsed_args.redirect_pool)
    if (parsed_args.action == 'REDIRECT_TO_URL' and
            not parsed_args.redirect_url):
        raise exceptions.CommandError(_('Redirect URL must be specified'))
    if (parsed_args.action == 'REDIRECT_TO_POOL' and
            not parsed_args.redirect_pool):
        raise exceptions.CommandError(_('Redirect pool must be specified'))

    attributes = ['name', 'description',
                  'action', 'redirect_pool_id', 'redirect_url',
                  'position', 'admin_state_up']
    if is_create:
        parsed_args.listener_id = _get_listener_id(
            client, parsed_args.listener)
        attributes.extend(['listener_id', 'tenant_id'])
    body = {}
    neutronV20.update_dict(parsed_args, body, attributes)
    return {'l7policy': body}
开发者ID:ChameleonCloud,项目名称:python-neutronclient,代码行数:26,代码来源:l7policy.py


示例16: _add_common_args

def _add_common_args(parser):
    parser.add_argument(
        '--description',
        help=_('Description of the load balancer.'))
    parser.add_argument(
        '--name', metavar='NAME',
        help=_('Name of the load balancer.'))
开发者ID:lmaycotte,项目名称:python-neutronclient,代码行数:7,代码来源:loadbalancer.py


示例17: _bulk_delete

 def _bulk_delete(self, obj_deleter, neutron_client, parsed_args_ids):
     successful_delete = []
     non_existent = []
     multiple_ids = []
     for item_id in parsed_args_ids:
         try:
             self.delete_item(obj_deleter, neutron_client, item_id)
             successful_delete.append(item_id)
         except exceptions.NotFound:
             non_existent.append(item_id)
         except exceptions.NeutronClientNoUniqueMatch:
             multiple_ids.append(item_id)
     if successful_delete:
         print((_('Deleted %(resource)s(s): %(id)s'))
               % {'id': ", ".join(successful_delete),
                  'resource': self.cmd_resource},
               file=self.app.stdout)
     if non_existent or multiple_ids:
         err_msgs = []
         if non_existent:
             err_msgs.append((_("Unable to find %(resource)s(s) with id(s) "
                                "'%(id)s'.") %
                              {'resource': self.cmd_resource,
                               'id': ", ".join(non_existent)}))
         if multiple_ids:
             err_msgs.append((_("Multiple %(resource)s(s) matches found "
                                "for name(s) '%(id)s'. Please use an ID "
                                "to be more specific.") %
                              {'resource': self.cmd_resource,
                               'id': ", ".join(multiple_ids)}))
         raise exceptions.NeutronCLIError(message='\n'.join(err_msgs))
开发者ID:huntxu,项目名称:python-neutronclient,代码行数:31,代码来源:__init__.py


示例18: get_parser

 def get_parser(self, prog_name):
     parser = super(SetSfcPortPairGroup, self).get_parser(prog_name)
     parser.add_argument(
         'port_pair_group',
         metavar='<port-pair-group>',
         help=_("Port pair group to modify (name or ID)"))
     parser.add_argument(
         '--name',
         metavar='<name>',
         help=_('Name of the port pair group'))
     parser.add_argument(
         '--description',
         metavar='<description>',
         help=_('Description for the port pair group'))
     parser.add_argument(
         '--port-pair',
         metavar='<port-pair>',
         dest='port_pairs',
         default=[],
         action='append',
         help=_('Port pair (name or ID). '
                'This option can be repeated.'))
     parser.add_argument(
         '--no-port-pair',
         action='store_true',
         help=_('Remove all port pair from port pair group'))
     return parser
开发者ID:huntxu,项目名称:python-neutronclient,代码行数:27,代码来源:sfc_port_pair_group.py


示例19: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument('--name',
                         help=_('Updated name of the address scope.'))
     utils.add_boolean_argument(
         parser, '--shared',
         help=_('Set sharing of address scope. '
                '(True means shared)'))
开发者ID:Juniper,项目名称:python-neutronclient,代码行数:7,代码来源:address_scope.py


示例20: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Name of the security group to be created.'))
     parser.add_argument(
         '--description',
         help=_('Description of the security group to be created.'))
开发者ID:Juniper,项目名称:python-neutronclient,代码行数:7,代码来源:securitygroup.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.add_boolean_argument函数代码示例发布时间:2022-05-27
下一篇:
Python directory.get_plugin函数代码示例发布时间: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