Use config choices for replication_mode option
The oslo.config module permits using a choices parameter to specify the list of valid values for a particular option. The replication_mode mode can utilize this parameter and allow the removal of some validation checking code. Change-Id: I77baec69717019664e71ae2fd24be8e1d908374b
This commit is contained in:
parent
2984da38b3
commit
e09989d5aa
@ -74,6 +74,7 @@ base_opts = [
|
||||
deprecated_group='NVP',
|
||||
help=_("The mode used to implement DHCP/metadata services.")),
|
||||
cfg.StrOpt('replication_mode', default=ReplicationModes.SERVICE,
|
||||
choices=(ReplicationModes.SERVICE, ReplicationModes.SOURCE),
|
||||
help=_("The default option leverages service nodes to perform"
|
||||
" packet replication though one could set to this to "
|
||||
"'source' to perform replication locally. This is useful"
|
||||
@ -345,14 +346,6 @@ cfg.CONF.register_opts(base_opts, group="NSX")
|
||||
cfg.CONF.register_opts(sync_opts, group="NSX_SYNC")
|
||||
|
||||
|
||||
def validate_config_options():
|
||||
if cfg.CONF.NSX.replication_mode not in (ReplicationModes.SERVICE,
|
||||
ReplicationModes.SOURCE):
|
||||
error = (_("Invalid replication_mode: %s") %
|
||||
cfg.CONF.NSX.replication_mode)
|
||||
raise nsx_exc.NsxPluginException(err_msg=error)
|
||||
|
||||
|
||||
def validate_nsxv_config_options():
|
||||
if (cfg.CONF.nsxv.manager_uri is None or
|
||||
cfg.CONF.nsxv.user is None or
|
||||
|
@ -78,7 +78,6 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
|
||||
def __init__(self):
|
||||
super(NsxDvsV2, self).__init__()
|
||||
config.validate_config_options()
|
||||
LOG.debug('Driver support: DVS: %s' % dvs_utils.dvs_is_enabled())
|
||||
neutron_extensions.append_api_extensions_path(
|
||||
[vmware_nsx.NSX_EXT_PATH])
|
||||
|
@ -134,7 +134,6 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
|
||||
def __init__(self):
|
||||
super(NsxPluginV2, self).__init__()
|
||||
config.validate_config_options()
|
||||
# TODO(salv-orlando): Replace These dicts with
|
||||
# collections.defaultdict for better handling of default values
|
||||
# Routines for managing logical ports in NSX
|
||||
|
Loading…
Reference in New Issue
Block a user