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


Python types.String方法代码示例

本文整理汇总了Python中oslo_config.types.String方法的典型用法代码示例。如果您正苦于以下问题:Python types.String方法的具体用法?Python types.String怎么用?Python types.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_config.types的用法示例。


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

示例1: __init__

# 需要导入模块: from oslo_config import types [as 别名]
# 或者: from oslo_config.types import String [as 别名]
def __init__(self, min_ip=0, max_ip=MAX_SUPPORTED_IP_PER_VFS,
                 type_name='FPG'):
        types.String.__init__(self, type_name=type_name)
        types.IPAddress.__init__(self, type_name=type_name)

        if max_ip < min_ip:
            msg = _("Pool's max acceptable IP cannot be less than min.")
            raise exception.HPE3ParInvalid(err=msg)

        if min_ip < 0:
            msg = _("Pools must be configured with zero or more IPs.")
            raise exception.HPE3ParInvalid(err=msg)

        if max_ip > FPG.MAX_SUPPORTED_IP_PER_VFS:
            msg = (_("Pool's max acceptable IP cannot be greater than "
                     "supported value=%s.") % FPG.MAX_SUPPORTED_IP_PER_VFS)
            raise exception.HPE3ParInvalid(err=msg)

        self.min_ip = min_ip
        self.max_ip = max_ip 
开发者ID:openstack,项目名称:manila,代码行数:22,代码来源:hpe_3par_driver.py

示例2: __call__

# 需要导入模块: from oslo_config import types [as 别名]
# 或者: from oslo_config.types import String [as 别名]
def __call__(self, value):
        if value is None or value.strip(' ') == '':
            message = _("Invalid configuration. hpe3par_fpg must be set.")
            LOG.error(message)
            raise exception.HPE3ParInvalid(err=message)

        ips = []
        values = value.split(",")
        # Extract pool name
        pool_name = values.pop(0).strip()

        # values will now be ['ip1', ...]
        if len(values) < self.min_ip:
            msg = (_("Require at least %s IPs configured per "
                     "pool") % self.min_ip)
            raise exception.HPE3ParInvalid(err=msg)
        if len(values) > self.max_ip:
            msg = (_("Cannot configure IPs more than max supported "
                     "%s IPs per pool") % self.max_ip)
            raise exception.HPE3ParInvalid(err=msg)

        for ip_addr in values:
            ip_addr = types.String.__call__(self, ip_addr.strip())
            try:
                ips.append(types.IPAddress.__call__(self, ip_addr))
            except ValueError as verror:
                raise exception.HPE3ParInvalid(err=verror)
        fpg = {pool_name: ips}
        return fpg 
开发者ID:openstack,项目名称:manila,代码行数:31,代码来源:hpe_3par_driver.py

示例3: _register_sensor_container_opts

# 需要导入模块: from oslo_config import types [as 别名]
# 或者: from oslo_config.types import String [as 别名]
def _register_sensor_container_opts():
    partition_opts = [
        cfg.StrOpt(
            'sensor_node_name', default='sensornode1',
            help='name of the sensor node.'),
        cfg.Opt(
            'partition_provider',
            type=types.Dict(value_type=types.String()),
            default={'name': DEFAULT_PARTITION_LOADER},
            help='Provider of sensor node partition config.')
    ]

    _register_opts(partition_opts, group='sensorcontainer')

    # Other options
    other_opts = [
        cfg.BoolOpt(
            'single_sensor_mode', default=False,
            help='Run in a single sensor mode where parent process exits when a sensor crashes / '
                 'dies. This is useful in environments where partitioning, sensor process life '
                 'cycle and failover is handled by a 3rd party service such as kubernetes.')
    ]

    _register_opts(other_opts, group='sensorcontainer')

    # CLI options
    cli_opts = [
        cfg.StrOpt(
            'sensor-ref',
            help='Only run sensor with the provided reference. Value is of the form '
                 '<pack>.<sensor-name> (e.g. linux.FileWatchSensor).'),
        cfg.BoolOpt(
            'single-sensor-mode', default=False,
            help='Run in a single sensor mode where parent process exits when a sensor crashes / '
                 'dies. This is useful in environments where partitioning, sensor process life '
                 'cycle and failover is handled by a 3rd party service such as kubernetes.')
    ]

    _register_cli_opts(cli_opts) 
开发者ID:StackStorm,项目名称:st2,代码行数:41,代码来源:config.py

示例4: _register_sensor_container_opts

# 需要导入模块: from oslo_config import types [as 别名]
# 或者: from oslo_config.types import String [as 别名]
def _register_sensor_container_opts(ignore_errors=False):
    logging_opts = [
        cfg.StrOpt(
            'logging', default='/etc/st2/logging.sensorcontainer.conf',
            help='location of the logging.conf file')
    ]

    st2cfg.do_register_opts(logging_opts, group='sensorcontainer', ignore_errors=ignore_errors)

    # Partitioning options
    partition_opts = [
        cfg.StrOpt(
            'sensor_node_name', default='sensornode1',
            help='name of the sensor node.'),
        cfg.Opt(
            'partition_provider',
            type=types.Dict(value_type=types.String()),
            default={'name': DEFAULT_PARTITION_LOADER},
            help='Provider of sensor node partition config.')
    ]

    st2cfg.do_register_opts(partition_opts, group='sensorcontainer', ignore_errors=ignore_errors)

    # Other options
    other_opts = [
        cfg.BoolOpt(
            'single_sensor_mode', default=False,
            help='Run in a single sensor mode where parent process exits when a sensor crashes / '
                 'dies. This is useful in environments where partitioning, sensor process life '
                 'cycle and failover is handled by a 3rd party service such as kubernetes.')
    ]

    st2cfg.do_register_opts(other_opts, group='sensorcontainer', ignore_errors=ignore_errors)

    # CLI options
    cli_opts = [
        cfg.StrOpt(
            'sensor-ref',
            help='Only run sensor with the provided reference. Value is of the form '
                 '<pack>.<sensor-name> (e.g. linux.FileWatchSensor).'),
        cfg.BoolOpt(
            'single-sensor-mode', default=False,
            help='Run in a single sensor mode where parent process exits when a sensor crashes / '
                 'dies. This is useful in environments where partitioning, sensor process life '
                 'cycle and failover is handled by a 3rd party service such as kubernetes.')
    ]

    st2cfg.do_register_cli_opts(cli_opts, ignore_errors=ignore_errors) 
开发者ID:StackStorm,项目名称:st2,代码行数:50,代码来源:config.py


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