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

Python _i18n._函数代码示例

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

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



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

示例1: _validate_integer

def _validate_integer(data, valid_values=None):
    """This function validates if the data is an integer.

    It checks both number or string provided to validate it's an
    integer and returns a message with the error if it's not

    :param data: The string or number to validate as integer
    :param valid_values: None (for future usage)
    :return: Message if not an integer.
    """

    if valid_values and (data not in valid_values):
        msg = (_("'%(data)s' is not within '%(valid_values)s'") %
               {'data': data, 'valid_values': valid_values})
        return msg

    msg = _("'%s' is not an integer") % data
    try:
        fl_n = float(data)
        int_n = int(data)
    except (ValueError, TypeError, OverflowError):
        LOG.debug(msg)
        return msg
    else:
        # Fail test if non equal or boolean
        if fl_n != int_n or isinstance(data, bool):
            LOG.debug(msg)
            return msg
开发者ID:F5Networks,项目名称:neutron-lbaas,代码行数:28,代码来源:loadbalancerv2.py


示例2: _wait_for_load_balancer_status

 def _wait_for_load_balancer_status(cls, load_balancer_id,
                                    provisioning_status='ACTIVE',
                                    operating_status='ONLINE',
                                    delete=False):
     interval_time = 1
     timeout = 600
     end_time = time.time() + timeout
     lb = {}
     # When running with no-op drivers there is no actual health to
     # observe, so disable operating_status checks when running no-op.
     if CONF.lbaas.test_with_noop:
         operating_status = None
     while time.time() < end_time:
         try:
             lb = cls.load_balancers_client.get_load_balancer(
                 load_balancer_id)
             if not lb:
                     # loadbalancer not found
                 if delete:
                     break
                 else:
                     raise Exception(
                         _("loadbalancer {lb_id} not"
                           " found").format(
                               lb_id=load_balancer_id))
             if lb.get('provisioning_status') == provisioning_status:
                 if operating_status is None:
                     break
                 elif lb.get('operating_status') == operating_status:
                     break
             time.sleep(interval_time)
         except exceptions.NotFound:
             # if wait is for delete operation do break
             if delete:
                 break
             else:
                 # raise original exception
                 raise
     else:
         if delete:
             raise exceptions.TimeoutException(
                 _("Waited for load balancer {lb_id} to be deleted for "
                   "{timeout} seconds but can still observe that it "
                   "exists.").format(
                       lb_id=load_balancer_id,
                       timeout=timeout))
         else:
             raise exceptions.TimeoutException(
                 _("Wait for load balancer ran for {timeout} seconds and "
                   "did not observe {lb_id} reach {provisioning_status} "
                   "provisioning status and {operating_status} "
                   "operating status.").format(
                       timeout=timeout,
                       lb_id=load_balancer_id,
                       provisioning_status=provisioning_status,
                       operating_status=operating_status))
     return lb
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:57,代码来源:base.py


示例3: _wait_for_load_balancer_status

 def _wait_for_load_balancer_status(
     cls, load_balancer_id, provisioning_status="ACTIVE", operating_status="ONLINE", delete=False
 ):
     interval_time = 1
     timeout = 600
     end_time = time.time() + timeout
     lb = {}
     while time.time() < end_time:
         try:
             lb = cls.load_balancers_client.get_load_balancer(load_balancer_id)
             if not lb:
                 # loadbalancer not found
                 if delete:
                     break
                 else:
                     raise Exception(_("loadbalancer {lb_id} not" " found").format(lb_id=load_balancer_id))
             if (
                 lb.get("provisioning_status") == provisioning_status
                 and lb.get("operating_status") == operating_status
             ):
                 break
             time.sleep(interval_time)
         except exceptions.NotFound:
             # if wait is for delete operation do break
             if delete:
                 break
             else:
                 # raise original exception
                 raise
     else:
         if delete:
             raise exceptions.TimeoutException(
                 _(
                     "Waited for load balancer {lb_id} to be deleted for "
                     "{timeout} seconds but can still observe that it "
                     "exists."
                 ).format(lb_id=load_balancer_id, timeout=timeout)
             )
         else:
             raise exceptions.TimeoutException(
                 _(
                     "Wait for load balancer ran for {timeout} seconds and "
                     "did not observe {lb_id} reach {provisioning_status} "
                     "provisioning status and {operating_status} "
                     "operating status."
                 ).format(
                     timeout=timeout,
                     lb_id=load_balancer_id,
                     provisioning_status=provisioning_status,
                     operating_status=operating_status,
                 )
             )
     return lb
开发者ID:F5Networks,项目名称:neutron-lbaas,代码行数:53,代码来源:base.py


示例4: _check_session_persistence_info

    def _check_session_persistence_info(self, info):
        """Performs sanity check on session persistence info.

        :param info: Session persistence info
        """
        if info['type'] == 'APP_COOKIE':
            if not info.get('cookie_name'):
                raise ValueError(_("'cookie_name' should be specified for this"
                                   " type of session persistence."))
        else:
            if 'cookie_name' in info:
                raise ValueError(_("'cookie_name' is not allowed for this type"
                                   " of session persistence"))
开发者ID:Stef1010,项目名称:neutron-lbaas,代码行数:13,代码来源:loadbalancer_db.py


示例5: get_session

def get_session():
    """Initializes a Keystone session.

    :returns: a Keystone Session object
    :raises Exception: if the session cannot be established
    """
    global _SESSION
    if not _SESSION:

        auth_url = cfg.CONF.service_auth.auth_url
        kwargs = {'auth_url': auth_url,
                  'username': cfg.CONF.service_auth.admin_user,
                  'password': cfg.CONF.service_auth.admin_password}

        if cfg.CONF.service_auth.auth_version == '2':
            client = v2_client
            kwargs['tenant_name'] = cfg.CONF.service_auth.admin_tenant_name
        elif cfg.CONF.service_auth.auth_version == '3':
            client = v3_client
            kwargs['project_name'] = cfg.CONF.service_auth.admin_tenant_name
            kwargs['user_domain_name'] = (cfg.CONF.service_auth.
                                          admin_user_domain)
            kwargs['project_domain_name'] = (cfg.CONF.service_auth.
                                             admin_project_domain)
        else:
            raise Exception(_('Unknown keystone version!'))

        try:
            kc = client.Password(**kwargs)
            _SESSION = session.Session(auth=kc)
        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.exception(_LE("Error creating Keystone session."))

    return _SESSION
开发者ID:F5Networks,项目名称:neutron-lbaas,代码行数:35,代码来源:keystone.py


示例6: update_status

 def update_status(self, context, obj_type, obj_id,
                   provisioning_status=None, operating_status=None):
     if not provisioning_status and not operating_status:
         LOG.warning('update_status for %(obj_type)s %(obj_id)s called '
                     'without specifying provisioning_status or '
                     'operating_status' % {'obj_type': obj_type,
                                           'obj_id': obj_id})
         return
     model_mapping = {
         'loadbalancer': db_models.LoadBalancer,
         'pool': db_models.PoolV2,
         'listener': db_models.Listener,
         'member': db_models.MemberV2,
         'healthmonitor': db_models.HealthMonitorV2
     }
     if obj_type not in model_mapping:
         raise n_exc.Invalid(_('Unknown object type: %s') % obj_type)
     try:
         self.plugin.db.update_status(
             context, model_mapping[obj_type], obj_id,
             provisioning_status=provisioning_status,
             operating_status=operating_status)
     except n_exc.NotFound:
         # update_status may come from agent on an object which was
         # already deleted from db with other request
         LOG.warning('Cannot update status: %(obj_type)s %(obj_id)s '
                     'not found in the DB, it was probably deleted '
                     'concurrently',
                     {'obj_type': obj_type, 'obj_id': obj_id})
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:29,代码来源:agent_callbacks.py


示例7: _validate_connection_limit

def _validate_connection_limit(data, min_value=lb_const.MIN_CONNECT_VALUE):
    if int(data) < min_value:
        msg = (_("'%(data)s' is not a valid value, "
                 "because it cannot be less than %(min_value)s") %
               {'data': data, 'min_value': min_value})
        LOG.debug(msg)
        return msg
开发者ID:richbrowne,项目名称:neutron-lbaas,代码行数:7,代码来源:loadbalancerv2.py


示例8: run

    def run(self):
        while not self.stoprequest.isSet():
            try:
                oper = self.queue.get(timeout=1)

                # Get the current queue size (N) and set the counter with it.
                # Handle N operations with no intermission.
                # Once N operations handles, get the size again and repeat.
                if self.opers_to_handle_before_rest <= 0:
                    self.opers_to_handle_before_rest = self.queue.qsize() + 1

                LOG.debug('Operation consumed from the queue: %s', oper)
                # check the status - if oper is done: update the db ,
                # else push the oper again to the queue
                if not self.handle_operation_completion(oper):
                    LOG.debug('Operation %s is not completed yet..', oper)
                    # Not completed - push to the queue again
                    self.queue.put_nowait(oper)

                self.queue.task_done()
                self.opers_to_handle_before_rest -= 1

                # Take one second rest before start handling
                # new operations or operations handled before
                if self.opers_to_handle_before_rest <= 0:
                    time.sleep(1)

            except Queue.Empty:
                continue
            except Exception:
                m = _("Exception was thrown inside OperationCompletionHandler")
                LOG.exception(m)
开发者ID:F5Networks,项目名称:neutron-lbaas,代码行数:32,代码来源:driver.py


示例9: l7policy_rule

    def l7policy_rule(self, l7policy_id, fmt=None, value='value1',
                      type=lb_const.L7_RULE_TYPE_HOST_NAME,
                      compare_type=lb_const.L7_RULE_COMPARE_TYPE_EQUAL_TO,
                      no_delete=False, **kwargs):
        if not fmt:
            fmt = self.fmt
        res = self._create_l7policy_rule(fmt,
                                         l7policy_id=l7policy_id,
                                         type=type,
                                         compare_type=compare_type,
                                         value=value,
                                         **kwargs)
        if res.status_int >= webob.exc.HTTPClientError.code:
            raise webob.exc.HTTPClientError(
                explanation=_("Unexpected error code: %s") % res.status_int
            )

        rule = self.deserialize(fmt or self.fmt, res)
        yield rule
        if not no_delete:
            self.plugin.db.update_status(context.get_admin_context(),
                                         models.L7Rule,
                                         rule['rule']['id'],
                                         constants.ACTIVE)
            del_req = self.new_delete_request(
                'l7policies',
                fmt=fmt,
                id=l7policy_id,
                subresource='rules',
                sub_id=rule['rule']['id'])
            del_res = del_req.get_response(self.ext_api)
            self.assertEqual(del_res.status_int,
                             webob.exc.HTTPNoContent.code)
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:33,代码来源:util.py


示例10: l7policy

    def l7policy(self, listener_id, fmt=None,
                 action=lb_const.L7_POLICY_ACTION_REJECT,
                 no_delete=False, **kwargs):
        if not fmt:
            fmt = self.fmt

        res = self._create_l7policy(fmt,
                                    listener_id=listener_id,
                                    action=action,
                                    **kwargs)
        if res.status_int >= webob.exc.HTTPClientError.code:
            raise webob.exc.HTTPClientError(
                explanation=_("Unexpected error code: %s") % res.status_int
            )

        l7policy = self.deserialize(fmt or self.fmt, res)
        yield l7policy
        if not no_delete:
            self.plugin.db.update_status(context.get_admin_context(),
                                         models.L7Policy,
                                         l7policy['l7policy']['id'],
                                         constants.ACTIVE)
            del_req = self.new_delete_request(
                'l7policies',
                fmt=fmt,
                id=l7policy['l7policy']['id'])
            del_res = del_req.get_response(self.ext_api)
            self.assertEqual(del_res.status_int,
                             webob.exc.HTTPNoContent.code)
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:29,代码来源:util.py


示例11: member

    def member(self, fmt=None, pool_id='pool1id', address='127.0.0.1',
               protocol_port=80, subnet=None, no_delete=False,
               **kwargs):
        if not fmt:
            fmt = self.fmt
        subnet = subnet or self.test_subnet
        with test_db_base_plugin_v2.optional_ctx(
                subnet, self.subnet) as tmp_subnet:

            res = self._create_member(fmt,
                                      pool_id=pool_id,
                                      address=address,
                                      protocol_port=protocol_port,
                                      subnet_id=tmp_subnet['subnet']['id'],
                                      **kwargs)
            if res.status_int >= webob.exc.HTTPClientError.code:
                raise webob.exc.HTTPClientError(
                    explanation=_("Unexpected error code: %s") % res.status_int
                )

            member = self.deserialize(fmt or self.fmt, res)
        yield member
        if not no_delete:
            self._delete('pools', id=pool_id, subresource='members',
                         sub_id=member['member']['id'])
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:25,代码来源:util.py


示例12: pool

    def pool(self, fmt=None, protocol='HTTP', lb_algorithm='ROUND_ROBIN',
             no_delete=False, listener_id=None,
             loadbalancer_id=None, **kwargs):
        if not fmt:
            fmt = self.fmt

        if listener_id and loadbalancer_id:
            res = self._create_pool(fmt,
                                    protocol=protocol,
                                    lb_algorithm=lb_algorithm,
                                    listener_id=listener_id,
                                    loadbalancer_id=loadbalancer_id,
                                    **kwargs)
        elif listener_id:
            res = self._create_pool(fmt,
                                    protocol=protocol,
                                    lb_algorithm=lb_algorithm,
                                    listener_id=listener_id,
                                    **kwargs)
        else:
            res = self._create_pool(fmt,
                                    protocol=protocol,
                                    lb_algorithm=lb_algorithm,
                                    loadbalancer_id=loadbalancer_id,
                                    **kwargs)
        if res.status_int >= webob.exc.HTTPClientError.code:
            raise webob.exc.HTTPClientError(
                explanation=_("Unexpected error code: %s") % res.status_int
            )

        pool = self.deserialize(fmt or self.fmt, res)
        yield pool
        if not no_delete:
            self._delete('pools', pool['pool']['id'])
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:34,代码来源:util.py


示例13: listener

    def listener(self, fmt=None, protocol='HTTP', loadbalancer_id=None,
                 protocol_port=80, default_pool_id=None, no_delete=False,
                 **kwargs):
        if not fmt:
            fmt = self.fmt

        if loadbalancer_id and default_pool_id:
            res = self._create_listener(fmt, protocol, protocol_port,
                                        loadbalancer_id=loadbalancer_id,
                                        default_pool_id=default_pool_id,
                                        **kwargs)
        elif loadbalancer_id:
            res = self._create_listener(fmt, protocol, protocol_port,
                                        loadbalancer_id=loadbalancer_id,
                                        **kwargs)
        else:
            res = self._create_listener(fmt, protocol, protocol_port,
                                        default_pool_id=default_pool_id,
                                        **kwargs)
        if res.status_int >= webob.exc.HTTPClientError.code:
            raise webob.exc.HTTPClientError(
                explanation=_("Unexpected error code: %s") % res.status_int
            )

        listener = self.deserialize(fmt or self.fmt, res)
        yield listener
        if not no_delete:
            self._delete('listeners', listener['listener']['id'])
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:28,代码来源:util.py


示例14: _validate_db_limit

def _validate_db_limit(data, max_value=db_const.DB_INTEGER_MAX_VALUE):
    if int(data) > max_value:
        msg = (_("'%(data)s' is not a valid value, "
                 "because it is more than %(max_value)s") %
               {'data': data, 'max_value': max_value})
        LOG.debug(msg)
        return msg
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:7,代码来源:loadbalancerv2.py


示例15: __init__

 def __init__(self, cert_container):
     if not isinstance(cert_container,
                       barbican_client.containers.CertificateContainer):
         raise TypeError(_(
             "Retrieved Barbican Container is not of the correct type "
             "(certificate)."))
     self._cert_container = cert_container
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:7,代码来源:barbican_cert_manager.py


示例16: healthmonitor

    def healthmonitor(self, fmt=None, pool_id='pool1id', type='TCP', delay=1,
                      timeout=1, max_retries=2, no_delete=False, **kwargs):
        if not fmt:
            fmt = self.fmt

        res = self._create_healthmonitor(fmt,
                                         pool_id=pool_id,
                                         type=type,
                                         delay=delay,
                                         timeout=timeout,
                                         max_retries=max_retries,
                                         **kwargs)
        if res.status_int >= webob.exc.HTTPClientError.code:
            raise webob.exc.HTTPClientError(
                explanation=_("Unexpected error code: %s") % res.status_int
            )

        healthmonitor = self.deserialize(fmt or self.fmt, res)
        yield healthmonitor
        if not no_delete:
            del_req = self.new_delete_request(
                'healthmonitors', fmt=fmt,
                id=healthmonitor['healthmonitor']['id'])
            del_res = del_req.get_response(self.ext_api)
            self.assertEqual(webob.exc.HTTPNoContent.code, del_res.status_int)
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:25,代码来源:util.py


示例17: _load_drivers

    def _load_drivers(self):
        self.device_drivers = {}
        for driver in self.conf.device_driver:
            driver = provconfig.get_provider_driver_class(driver, DEVICE_DRIVERS)
            try:
                driver_inst = importutils.import_object(driver, self.conf, self.plugin_rpc)
            except ImportError:
                msg = _("Error importing loadbalancer device driver: %s")
                raise SystemExit(msg % driver)

            driver_name = driver_inst.get_name()
            if driver_name not in self.device_drivers:
                self.device_drivers[driver_name] = driver_inst
            else:
                msg = _("Multiple device drivers with the same name found: %s")
                raise SystemExit(msg % driver_name)
开发者ID:F5Networks,项目名称:neutron-lbaas,代码行数:16,代码来源:agent_manager.py


示例18: validate_non_negative_int

 def validate_non_negative_int(self, key, value):
     if value < 0:
         data = {'key': key, 'value': value}
         raise ValueError(_('The %(key)s field can not have '
                            'negative value. '
                            'Current value is %(value)d.') % data)
     return value
开发者ID:Stef1010,项目名称:neutron-lbaas,代码行数:7,代码来源:loadbalancer_db.py


示例19: delete_entity

 def delete_entity(self, context, pool):
     """Delete a pool on a NetScaler device."""
     resource_path = "%s/%s/%s" % (RESOURCE_PREFIX, POOLS_RESOURCE,
                                   pool.id)
     msg = _("NetScaler driver pool removal: %s") % pool.id
     LOG.debug(msg)
     self.client.remove_resource(context.tenant_id, resource_path)
开发者ID:gongwayne,项目名称:Openstack,代码行数:7,代码来源:netscaler_driver_v2.py


示例20: create_entity

 def create_entity(self, context, hm):
     ncc_hm = self.payload_preparer.prepare_healthmonitor_for_creation(hm)
     msg = _("NetScaler driver healthmonitor creation: %s") % repr(ncc_hm)
     LOG.debug(msg)
     resource_path = "%s/%s" % (RESOURCE_PREFIX, MONITORS_RESOURCE)
     self.client.create_resource(context.tenant_id, resource_path,
                                 MONITOR_RESOURCE, ncc_hm)
开发者ID:gongwayne,项目名称:Openstack,代码行数:7,代码来源:netscaler_driver_v2.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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