本文整理匯總了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
示例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
示例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)
示例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)