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


Python _i18n._函数代码示例

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


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

示例1: _add_updatable_args

def _add_updatable_args(parser):
    parser.add_argument(
        '--name',
        help=_('Name of this router type.'))
    parser.add_argument(
        '--description',
        help=_('Description of this router type.'))
    parser.add_argument(
        '--ha-enabled',
        dest='ha_enabled_by_default',
        action='store_true',
        help=_('Make HA enabled for the router type.'),
        default=argparse.SUPPRESS)
    parser.add_argument(
        '--ha_enabled',
        dest='ha_enabled_by_default',
        action='store_true',
        help=argparse.SUPPRESS,
        default=argparse.SUPPRESS)
    parser.add_argument(
        '--unshared',
        dest='shared',
        action='store_false',
        help=_('Make router type NOT shared among tenants.'),
        default=argparse.SUPPRESS)
    parser.add_argument(
        '--slot-need',
        help=_('Number of slots routers of this type consumes.'))
    parser.add_argument(
        '--slot_need',
        help=argparse.SUPPRESS)
开发者ID:abattye,项目名称:networking-cisco,代码行数:31,代码来源:routertype.py

示例2: _agent_registration

    def _agent_registration(self):
        """Register this agent with the server.

        This method registers the cfg agent with the neutron server so hosting
        devices can be assigned to it. In case the server is not ready to
        accept registration (it sends a False) then we retry registration
        for `MAX_REGISTRATION_ATTEMPTS` with a delay of
        `REGISTRATION_RETRY_DELAY`. If there is no server response or a
        failure to register after the required number of attempts,
        the agent stops itself.
        """
        for attempts in range(MAX_REGISTRATION_ATTEMPTS):
            context = n_context.get_admin_context_without_session()
            self.send_agent_report(self.agent_state, context)
            res = self.devmgr_rpc.register_for_duty(context)
            if res is True:
                LOG.info(_LI("[Agent registration] Agent successfully "
                             "registered"))
                return
            elif res is False:
                LOG.warning(_LW("[Agent registration] Neutron server said "
                                "that device manager was not ready. Retrying "
                                "in %0.2f seconds "), REGISTRATION_RETRY_DELAY)
                time.sleep(REGISTRATION_RETRY_DELAY)
            elif res is None:
                LOG.error(_LE("[Agent registration] Neutron server said that "
                              "no device manager was found. Cannot continue. "
                              "Exiting!"))
                raise SystemExit(_("Cfg Agent exiting"))
        LOG.error(_LE("[Agent registration] %d unsuccessful registration "
                      "attempts. Exiting!"), MAX_REGISTRATION_ATTEMPTS)
        raise SystemExit(_("Cfg Agent exiting"))
开发者ID:nh0556,项目名称:networking-cisco,代码行数:32,代码来源:cfg_agent.py

示例3: add_known_arguments

 def add_known_arguments(self, parser):
     # adding admin_state_up here so that it is available for update only
     # as it is True by default and not meaningful in the create operation
     parser.add_argument(
         "--admin-state-up",
         dest="admin_state_up",
         action="store_true",
         help=_("Set hosting device administratively up."),
         default=argparse.SUPPRESS,
     )
     parser.add_argument(
         "--admin_state_up",
         dest="admin_state_up",
         action="store_true",
         help=argparse.SUPPRESS,
         default=argparse.SUPPRESS,
     )
     # adding no_auto_delete here so that it is available for update only
     # as auto_delete is False by default and not meaningful in the create
     # operation
     parser.add_argument(
         "--no-auto-delete",
         dest="auto_delete",
         action="store_false",
         help=_("Exempt hosting device from automated life cycle " "management."),
         default=argparse.SUPPRESS,
     )
     parser.add_argument(
         "--no_auto_delete",
         dest="auto_delete",
         action="store_false",
         help=argparse.SUPPRESS,
         default=argparse.SUPPRESS,
     )
     _add_updatable_args(parser)
开发者ID:JoelCapitao,项目名称:networking-cisco,代码行数:35,代码来源:hostingdevice.py

示例4: get_parser

 def get_parser(self, prog_name):
     parser = super(AddRouterToHostingDevice, self).get_parser(prog_name)
     parser.add_argument(
         'hosting_device',
         help=_('Name or id of the hosting device.'))
     parser.add_argument(
         'router',
         help=_('Name or id of router to add.'))
     return parser
开发者ID:abattye,项目名称:networking-cisco,代码行数:9,代码来源:routerscheduler.py

示例5: get_parser

 def get_parser(self, prog_name):
     parser = super(HostingDeviceDisassociateFromConfigAgent,
                    self).get_parser(prog_name)
     parser.add_argument(
         'config_agent_id',
         help=_('Id of the Cisco configuration agent.'))
     parser.add_argument(
         'hosting_device',
         help=_('Name or id of hosting device to disassociate.'))
     return parser
开发者ID:abattye,项目名称:networking-cisco,代码行数:10,代码来源:hostingdevicescheduler.py

示例6: verify_resource_dict

def verify_resource_dict(res_dict, is_create, attr_info):
    """Verifies required attributes are in resource dictionary, res_dict.

    Also checking that an attribute is only specified if it is allowed
    for the given operation (create/update).

    Attribute with default values are considered to be optional.

    This function contains code taken from function 'prepare_request_body' in
    attributes.py.
    """
    if not bc_attr.IS_PRE_NEWTON and 'tenant_id' in res_dict:
        res_dict['project_id'] = res_dict['tenant_id']
    if is_create:  # POST
        for attr, attr_vals in six.iteritems(attr_info):
            if attr_vals['allow_post']:
                if 'default' not in attr_vals and attr not in res_dict:
                    msg = _("Failed to parse request. Required attribute '%s' "
                            "not specified") % attr
                    raise webob.exc.HTTPBadRequest(msg)
                res_dict[attr] = res_dict.get(attr, attr_vals.get('default'))
            else:
                if attr in res_dict:
                    msg = _("Attribute '%s' not allowed in POST") % attr
                    raise webob.exc.HTTPBadRequest(msg)
    else:  # PUT
        for attr, attr_vals in six.iteritems(attr_info):
            if attr in res_dict and not attr_vals['allow_put']:
                msg = _("Cannot update read-only attribute %s") % attr
                raise webob.exc.HTTPBadRequest(msg)

    for attr, attr_vals in six.iteritems(attr_info):
        if (attr not in res_dict or
                res_dict[attr] is bc_attr.ATTR_NOT_SPECIFIED):
            continue
        # Convert values if necessary
        if 'convert_to' in attr_vals:
            res_dict[attr] = attr_vals['convert_to'](res_dict[attr])
        # Check that configured values are correct
        if 'validate' not in attr_vals:
            continue
        for rule in attr_vals['validate']:
            _ensure_format(rule, attr, res_dict)
            res = attributes.validators[rule](res_dict[attr],
                                              attr_vals['validate'][rule])
            if res:
                msg_dict = dict(attr=attr, reason=res)
                msg = (_("Invalid input for %(attr)s. Reason: %(reason)s.") %
                       msg_dict)
                raise webob.exc.HTTPBadRequest(msg)
    return res_dict
开发者ID:noironetworks,项目名称:networking-cisco,代码行数:51,代码来源:config.py

示例7: _parse_nexus_vni_range

    def _parse_nexus_vni_range(self, tunnel_range):
        """Raise an exception for invalid tunnel range or malformed range."""
        for ident in tunnel_range:
            if not self._is_valid_nexus_vni(ident):
                raise exc.NetworkTunnelRangeError(
                    tunnel_range=tunnel_range,
                    error=_("%(id)s is not a valid Nexus VNI value.") %
                    {'id': ident})

        if tunnel_range[1] < tunnel_range[0]:
            raise exc.NetworkTunnelRangeError(
                tunnel_range=tunnel_range,
                error=_("End of tunnel range is less than start of "
                        "tunnel range."))
开发者ID:noironetworks,项目名称:networking-cisco,代码行数:14,代码来源:type_nexus_vxlan.py

示例8: parse_ucsm_host_config

def parse_ucsm_host_config():
    sp_dict = {}
    host_dict = {}
    if cfg.CONF.ml2_cisco_ucsm.ucsm_host_list:
        host_config_list = cfg.CONF.ml2_cisco_ucsm.ucsm_host_list
        for host in host_config_list:
            hostname, sep, service_profile = host.partition(':')
            if not sep or not service_profile:
                raise cfg.Error(_("UCS Mech Driver: Invalid Host Service "
                                  "Profile config: %s") % host)
            key = (cfg.CONF.ml2_cisco_ucsm.ucsm_ip, hostname)
            if '/' not in service_profile:
                # Assuming the service profile is at the root level
                # and the path is not specified. This option
                # allows backward compatability with earlier config
                # format
                sp_dict[key] = (const.SERVICE_PROFILE_PATH_PREFIX +
                    service_profile.strip())
            else:
                # Assuming the complete path to Service Profile has
                # been provided in the config. The Service Profile
                # could be in an sub-org.
                sp_dict[key] = service_profile.strip()

            LOG.debug('Service Profile for %s is %s',
                hostname, sp_dict.get(key))
            host_dict[hostname] = cfg.CONF.ml2_cisco_ucsm.ucsm_ip
        return sp_dict, host_dict
开发者ID:noironetworks,项目名称:networking-cisco,代码行数:28,代码来源:config.py

示例9: _create_multi_ucsm_dicts

    def _create_multi_ucsm_dicts(self):
        """Creates a dictionary of all UCS Manager data from config."""
        multi_parser = cfg.MultiConfigParser()
        read_ok = multi_parser.read(cfg.CONF.config_file)

        if len(read_ok) != len(cfg.CONF.config_file):
            raise cfg.Error(_('Some config files were not parsed properly'))

        for parsed_file in multi_parser.parsed:
            for parsed_item in parsed_file.keys():
                dev_id, sep, dev_ip = parsed_item.partition(':')
                dev_ip = dev_ip.strip()
                if dev_id.lower() == 'ml2_cisco_ucsm_ip':
                    ucsm_info = []
                    eth_port_list = []
                    for dev_key, value in parsed_file[parsed_item].items():
                        config_item = dev_key.lower()
                        if config_item == 'ucsm_virtio_eth_ports':
                            for eth_port in value[0].split(','):
                                eth_port_list.append(
                                    const.ETH_PREFIX + str(eth_port).strip())
                            self.ucsm_port_dict[dev_ip] = eth_port_list
                        elif config_item == 'sp_template_list':
                            self._parse_sp_template_list(dev_ip, value)
                            self.sp_template_mode = True
                        elif config_item == 'vnic_template_list':
                            self._parse_vnic_template_list(dev_ip, value)
                            self.vnic_template_mode = True
                        else:
                            ucsm_info.append(value[0])
                    self.ucsm_dict[dev_ip] = ucsm_info
                    self.multi_ucsm_mode = True
开发者ID:abattye,项目名称:networking-cisco,代码行数:32,代码来源:config.py

示例10: _create_multi_ucsm_dicts

    def _create_multi_ucsm_dicts(self):
        """Creates a dictionary of all UCS Manager data from config."""
        multi_parser = cfg.MultiConfigParser()
        read_ok = multi_parser.read(cfg.CONF.config_file)

        if len(read_ok) != len(cfg.CONF.config_file):
            raise cfg.Error(_('Some config files were not parsed properly'))

        for parsed_file in multi_parser.parsed:
            for parsed_item in parsed_file.keys():
                dev_id, sep, dev_ip = parsed_item.partition(':')
                if dev_id.lower() == 'ml2_cisco_ucsm_ip':
                    ucsm_info = []
                    eth_ports = []
                    eth_port_list = []
                    for dev_key, value in parsed_file[parsed_item].items():
                        if dev_key != 'ucsm_virtio_eth_ports':
                            ucsm_info.append(value[0])
                        else:
                            eth_ports = value[0].split(',')
                            for eth_port in eth_ports:
                                eth_port_list.append(
                                    const.ETH_PREFIX + str(eth_port))
                    self.ucsm_dict[dev_ip] = ucsm_info
                    self.ucsm_port_dict[dev_ip] = eth_port_list
开发者ID:bdemers,项目名称:networking-cisco,代码行数:25,代码来源:config.py

示例11: dequeue

 def dequeue(self, qname):
     if qname not in self._queues:
         raise ValueError(_("queue %s is not defined"), qname)
     try:
         return self._queues[qname].get(block=False)
     except Queue.Empty:
         return None
开发者ID:abattye,项目名称:networking-cisco,代码行数:7,代码来源:service_helper.py

示例12: _build_flow_expr_str

def _build_flow_expr_str(flow_dict, cmd):
    flow_expr_arr = []
    actions = None

    if cmd == 'add':
        flow_expr_arr.append("hard_timeout=%s" %
                             flow_dict.pop('hard_timeout', '0'))
        flow_expr_arr.append("idle_timeout=%s" %
                             flow_dict.pop('idle_timeout', '0'))
        flow_expr_arr.append("priority=%s" %
                             flow_dict.pop('priority', '1'))
    elif 'priority' in flow_dict:
        msg = "Cannot match priority on flow deletion or modification"
        raise dfae.InvalidInput(error_message=msg)

    if cmd != 'del':
        if "actions" not in flow_dict:
            msg = _("Must specify one or more actions on flow addition"
                    " or modification")
            raise dfae.InvalidInput(error_message=msg)
        actions = "actions=%s" % flow_dict.pop('actions')

    for key, value in six.iteritems(flow_dict):
        if key == 'proto':
            flow_expr_arr.append(value)
        else:
            flow_expr_arr.append("%s=%s" % (key, str(value)))

    if actions:
        flow_expr_arr.append(actions)

    return ','.join(flow_expr_arr)
开发者ID:abattye,项目名称:networking-cisco,代码行数:32,代码来源:dfa_sys_lib.py

示例13: __init__

    def __init__(self):
        """Create a single UCSM or Multi-UCSM dict."""
        self._create_multi_ucsm_dicts()
        if cfg.CONF.ml2_cisco_ucsm.ucsm_ip and not self.ucsm_dict:
            self._create_single_ucsm_dicts()

        if not self.ucsm_dict:
            raise cfg.Error(_('Insufficient UCS Manager configuration has '
                              'been provided to the plugin'))
开发者ID:busterswt,项目名称:networking-cisco,代码行数:9,代码来源:config.py

示例14: get_plugin

 def get_plugin(self):
     plugin = manager.NeutronManager.get_service_plugins().get(
         cisco_constants.DEVICE_MANAGER)
     if not plugin:
         LOG.error(_LE('No Device manager service plugin registered to '
                       'handle hosting device scheduling'))
         msg = _('The resource could not be found.')
         raise webob.exc.HTTPNotFound(msg)
     return plugin
开发者ID:JoelCapitao,项目名称:networking-cisco,代码行数:9,代码来源:ciscocfgagentscheduler.py

示例15: get_plugin

 def get_plugin(self):
     plugin = manager.NeutronManager.get_service_plugins().get(
         svc_constants.L3_ROUTER_NAT)
     if not plugin:
         LOG.error(_LE('No L3 router service plugin registered to '
                       'handle routertype-aware scheduling'))
         msg = _('The resource could not be found.')
         raise webob.exc.HTTPNotFound(msg)
     return plugin
开发者ID:noironetworks,项目名称:networking-cisco,代码行数:9,代码来源:routertypeawarescheduler.py


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