Merge "TVD availability zones"
This commit is contained in:
commit
c594154fd8
@ -36,9 +36,6 @@ NATIVE_DHCP_METADATA=${NATIVE_DHCP_METADATA:-True}
|
|||||||
NATIVE_METADATA_ROUTE=${NATIVE_METADATA_ROUTE:-169.254.169.254/31}
|
NATIVE_METADATA_ROUTE=${NATIVE_METADATA_ROUTE:-169.254.169.254/31}
|
||||||
METADATA_PROXY_SHARED_SECRET=${METADATA_PROXY_SHARED_SECRET:-}
|
METADATA_PROXY_SHARED_SECRET=${METADATA_PROXY_SHARED_SECRET:-}
|
||||||
|
|
||||||
# Default AZ
|
|
||||||
NSX_DEFAULT_AZ=${NSX_DEFAULT_AZ:-defaultv3}
|
|
||||||
|
|
||||||
# Save trace setting
|
# Save trace setting
|
||||||
NSX_XTRACE=$(set +o | grep xtrace)
|
NSX_XTRACE=$(set +o | grep xtrace)
|
||||||
set +o xtrace
|
set +o xtrace
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
from oslo_config import cfg
|
|
||||||
|
|
||||||
from neutron_lib.api.definitions import availability_zone as az_def
|
from neutron_lib.api.definitions import availability_zone as az_def
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.exceptions import availability_zone as az_exc
|
from neutron_lib.exceptions import availability_zone as az_exc
|
||||||
@ -78,7 +76,7 @@ class ConfiguredAvailabilityZones(object):
|
|||||||
|
|
||||||
default_name = DEFAULT_NAME
|
default_name = DEFAULT_NAME
|
||||||
|
|
||||||
def __init__(self, az_conf, az_class, validate_default=True):
|
def __init__(self, az_conf, az_class, default_availability_zones=None):
|
||||||
self.availability_zones = {}
|
self.availability_zones = {}
|
||||||
|
|
||||||
# Add the configured availability zones
|
# Add the configured availability zones
|
||||||
@ -91,24 +89,20 @@ class ConfiguredAvailabilityZones(object):
|
|||||||
self.availability_zones[obj.name] = obj
|
self.availability_zones[obj.name] = obj
|
||||||
|
|
||||||
# validate the default az:
|
# validate the default az:
|
||||||
if cfg.CONF.default_availability_zones:
|
if default_availability_zones:
|
||||||
# we support only 1 default az
|
# we support only 1 default az
|
||||||
if len(cfg.CONF.default_availability_zones) > 1:
|
if len(default_availability_zones) > 1:
|
||||||
raise nsx_exc.NsxInvalidConfiguration(
|
raise nsx_exc.NsxInvalidConfiguration(
|
||||||
opt_name="default_availability_zones",
|
opt_name="default_availability_zones",
|
||||||
opt_value=cfg.CONF.default_availability_zones,
|
opt_value=default_availability_zones,
|
||||||
reason=_("The NSX plugin supports only 1 default AZ"))
|
reason=_("The NSX plugin supports only 1 default AZ"))
|
||||||
default_az_name = cfg.CONF.default_availability_zones[0]
|
default_az_name = default_availability_zones[0]
|
||||||
if (default_az_name not in self.availability_zones):
|
if (default_az_name not in self.availability_zones):
|
||||||
if validate_default:
|
raise nsx_exc.NsxInvalidConfiguration(
|
||||||
raise nsx_exc.NsxInvalidConfiguration(
|
opt_name="default_availability_zones",
|
||||||
opt_name="default_availability_zones",
|
opt_value=default_availability_zones,
|
||||||
opt_value=cfg.CONF.default_availability_zones,
|
reason=_("The default AZ is not defined in the NSX "
|
||||||
reason=_("The default AZ is not defined in the NSX "
|
"plugin"))
|
||||||
"plugin"))
|
|
||||||
else:
|
|
||||||
self._default_az = self.availability_zones[
|
|
||||||
self.default_name]
|
|
||||||
else:
|
else:
|
||||||
self._default_az = self.availability_zones[default_az_name]
|
self._default_az = self.availability_zones[default_az_name]
|
||||||
else:
|
else:
|
||||||
|
@ -845,6 +845,16 @@ nsx_tvd_opts = [
|
|||||||
choices=projectpluginmap.VALID_TYPES,
|
choices=projectpluginmap.VALID_TYPES,
|
||||||
help=_("The default plugin that will be used for new projects "
|
help=_("The default plugin that will be used for new projects "
|
||||||
"that were not added to the projects plugin mapping.")),
|
"that were not added to the projects plugin mapping.")),
|
||||||
|
cfg.ListOpt('nsx_v_default_availability_zones',
|
||||||
|
default=[],
|
||||||
|
help=_("The default availability zones that will be used for "
|
||||||
|
"NSX-V networks and routers creation under the TVD "
|
||||||
|
"plugin.")),
|
||||||
|
cfg.ListOpt('nsx_v3_default_availability_zones',
|
||||||
|
default=[],
|
||||||
|
help=_("The default availability zones that will be used for "
|
||||||
|
"NSX-V3 networks and routers creation under the TVD "
|
||||||
|
"plugin.")),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Register the configuration options
|
# Register the configuration options
|
||||||
|
@ -162,6 +162,9 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
LOG.info("NSX-TVD plugin will use %s as the default plugin",
|
LOG.info("NSX-TVD plugin will use %s as the default plugin",
|
||||||
self.default_plugin)
|
self.default_plugin)
|
||||||
|
|
||||||
|
# validate the availability zones configuration
|
||||||
|
self.init_availability_zones()
|
||||||
|
|
||||||
def get_plugin_by_type(self, plugin_type):
|
def get_plugin_by_type(self, plugin_type):
|
||||||
return self.plugins.get(plugin_type)
|
return self.plugins.get(plugin_type)
|
||||||
|
|
||||||
@ -192,6 +195,15 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
self._unsupported_fields[plugin_type]['port'] = [
|
self._unsupported_fields[plugin_type]['port'] = [
|
||||||
'mac_learning_enabled', 'provider_security_groups']
|
'mac_learning_enabled', 'provider_security_groups']
|
||||||
|
|
||||||
|
def init_availability_zones(self):
|
||||||
|
# Make sure there are no overlaps between v/t availability zones
|
||||||
|
if (self.plugins.get(projectpluginmap.NsxPlugins.NSX_V) and
|
||||||
|
self.plugins.get(projectpluginmap.NsxPlugins.NSX_T) and
|
||||||
|
bool(set(cfg.CONF.nsxv.availability_zones) &
|
||||||
|
set(cfg.CONF.nsx_v3.availability_zones))):
|
||||||
|
msg = _("Cannot use the same availability zones in NSX-V and T")
|
||||||
|
raise nsx_exc.NsxPluginException(err_msg=msg)
|
||||||
|
|
||||||
def _unsubscribe_callback_events(self):
|
def _unsubscribe_callback_events(self):
|
||||||
# unsubscribe the callback that should be called on all plugins
|
# unsubscribe the callback that should be called on all plugins
|
||||||
# other that NSX-T.
|
# other that NSX-T.
|
||||||
|
@ -204,11 +204,15 @@ class NsxVAvailabilityZone(common_az.ConfiguredAvailabilityZone):
|
|||||||
|
|
||||||
class NsxVAvailabilityZones(common_az.ConfiguredAvailabilityZones):
|
class NsxVAvailabilityZones(common_az.ConfiguredAvailabilityZones):
|
||||||
|
|
||||||
def __init__(self, validate_default=False):
|
def __init__(self, use_tvd_config=False):
|
||||||
|
if use_tvd_config:
|
||||||
|
default_azs = cfg.CONF.nsx_tvd.nsx_v_default_availability_zones
|
||||||
|
else:
|
||||||
|
default_azs = cfg.CONF.default_availability_zones
|
||||||
super(NsxVAvailabilityZones, self).__init__(
|
super(NsxVAvailabilityZones, self).__init__(
|
||||||
cfg.CONF.nsxv.availability_zones,
|
cfg.CONF.nsxv.availability_zones,
|
||||||
NsxVAvailabilityZone,
|
NsxVAvailabilityZone,
|
||||||
validate_default=validate_default)
|
default_availability_zones=default_azs)
|
||||||
|
|
||||||
def get_inventory(self):
|
def get_inventory(self):
|
||||||
"""Return a set of relevant resources in all the availability zones
|
"""Return a set of relevant resources in all the availability zones
|
||||||
|
@ -1023,9 +1023,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
return '%s.%03d' % (device_id, port_index)
|
return '%s.%03d' % (device_id, port_index)
|
||||||
|
|
||||||
def init_availability_zones(self):
|
def init_availability_zones(self):
|
||||||
validate_default = not self._is_sub_plugin
|
|
||||||
self._availability_zones_data = nsx_az.NsxVAvailabilityZones(
|
self._availability_zones_data = nsx_az.NsxVAvailabilityZones(
|
||||||
validate_default=validate_default)
|
use_tvd_config=self._is_sub_plugin)
|
||||||
|
|
||||||
def _list_availability_zones(self, context, filters=None):
|
def _list_availability_zones(self, context, filters=None):
|
||||||
#TODO(asarfaty): We may need to use the filters arg, but now it
|
#TODO(asarfaty): We may need to use the filters arg, but now it
|
||||||
|
@ -210,11 +210,15 @@ class NsxV3AvailabilityZones(common_az.ConfiguredAvailabilityZones):
|
|||||||
|
|
||||||
default_name = DEFAULT_NAME
|
default_name = DEFAULT_NAME
|
||||||
|
|
||||||
def __init__(self, validate_default=False):
|
def __init__(self, use_tvd_config=False):
|
||||||
|
if use_tvd_config:
|
||||||
|
default_azs = cfg.CONF.nsx_tvd.nsx_v3_default_availability_zones
|
||||||
|
else:
|
||||||
|
default_azs = cfg.CONF.default_availability_zones
|
||||||
super(NsxV3AvailabilityZones, self).__init__(
|
super(NsxV3AvailabilityZones, self).__init__(
|
||||||
cfg.CONF.nsx_v3.availability_zones,
|
cfg.CONF.nsx_v3.availability_zones,
|
||||||
NsxV3AvailabilityZone,
|
NsxV3AvailabilityZone,
|
||||||
validate_default=validate_default)
|
default_availability_zones=default_azs)
|
||||||
|
|
||||||
def dhcp_relay_configured(self):
|
def dhcp_relay_configured(self):
|
||||||
for az in self.availability_zones.values():
|
for az in self.availability_zones.values():
|
||||||
|
@ -375,9 +375,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
return lb_driver_v2.DummyLoadbalancerDriverV2()
|
return lb_driver_v2.DummyLoadbalancerDriverV2()
|
||||||
|
|
||||||
def init_availability_zones(self):
|
def init_availability_zones(self):
|
||||||
validate_default = not self._is_sub_plugin
|
|
||||||
self._availability_zones_data = nsx_az.NsxV3AvailabilityZones(
|
self._availability_zones_data = nsx_az.NsxV3AvailabilityZones(
|
||||||
validate_default=validate_default)
|
use_tvd_config=self._is_sub_plugin)
|
||||||
|
|
||||||
def _init_nsx_profiles(self):
|
def _init_nsx_profiles(self):
|
||||||
LOG.debug("Initializing NSX v3 port spoofguard switching profile")
|
LOG.debug("Initializing NSX v3 port spoofguard switching profile")
|
||||||
@ -4411,10 +4410,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
# as the hint (or default if none)
|
# as the hint (or default if none)
|
||||||
if hints:
|
if hints:
|
||||||
az_name = hints[0]
|
az_name = hints[0]
|
||||||
elif cfg.CONF.default_availability_zones:
|
|
||||||
az_name = cfg.CONF.default_availability_zones[0]
|
|
||||||
else:
|
else:
|
||||||
az_name = nsx_az.DEFAULT_NAME
|
az_name = self.get_default_az().name
|
||||||
return [az_name]
|
return [az_name]
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
@ -44,6 +44,14 @@ class NsxTVDPluginTestCase(v_tests.NsxVPluginV2TestCase,
|
|||||||
cfg.CONF.set_override('default_plugin', self.plugin_type,
|
cfg.CONF.set_override('default_plugin', self.plugin_type,
|
||||||
group="nsx_tvd")
|
group="nsx_tvd")
|
||||||
|
|
||||||
|
# set the default availability zones
|
||||||
|
cfg.CONF.set_override('nsx_v_default_availability_zones',
|
||||||
|
['default'],
|
||||||
|
group="nsx_tvd")
|
||||||
|
cfg.CONF.set_override('nsx_v3_default_availability_zones',
|
||||||
|
['defaultv3'],
|
||||||
|
group="nsx_tvd")
|
||||||
|
|
||||||
super(NsxTVDPluginTestCase, self).setUp(
|
super(NsxTVDPluginTestCase, self).setUp(
|
||||||
plugin=plugin,
|
plugin=plugin,
|
||||||
ext_mgr=ext_mgr)
|
ext_mgr=ext_mgr)
|
||||||
|
Loading…
Reference in New Issue
Block a user