NSX-v3: Add default tier0 router to AZ config
The nsx-v3 plugin can add default Tier-0 router configuration per availability zone. The Tier-0 rotuer will be used as a default for external networks creation in this AZ. Change-Id: I18e917a6b3deb40429626f7f0018e5da7ab72a8b
This commit is contained in:
parent
e83f4f7fdd
commit
3e6b548984
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
prelude: >
|
||||||
|
The nsx-v3 plugin can add default Tier-0 router configuration per
|
||||||
|
availability zone.
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The nsx-v3 plugin can add default Tier-0 router configuration per
|
||||||
|
availability zone. The Tier-0 rotuer will be used as a default for
|
||||||
|
external networks creation.
|
@ -841,6 +841,10 @@ nsxv3_az_opts = [
|
|||||||
help=_("(Optional) This is the name or UUID of the NSX dhcp "
|
help=_("(Optional) This is the name or UUID of the NSX dhcp "
|
||||||
"relay service that will be used to enable DHCP relay "
|
"relay service that will be used to enable DHCP relay "
|
||||||
"on router ports.")),
|
"on router ports.")),
|
||||||
|
cfg.StrOpt('default_tier0_router',
|
||||||
|
help=_("Name or UUID of the default tier0 router that will be "
|
||||||
|
"used for connecting to tier1 logical routers and "
|
||||||
|
"configuring external networks")),
|
||||||
]
|
]
|
||||||
|
|
||||||
nsx_tvd_opts = [
|
nsx_tvd_opts = [
|
||||||
|
@ -89,6 +89,10 @@ class NsxV3AvailabilityZone(common_az.ConfiguredAvailabilityZone):
|
|||||||
if self.dhcp_relay_service is None:
|
if self.dhcp_relay_service is None:
|
||||||
self.dhcp_relay_service = cfg.CONF.nsx_v3.dhcp_relay_service
|
self.dhcp_relay_service = cfg.CONF.nsx_v3.dhcp_relay_service
|
||||||
|
|
||||||
|
self.default_tier0_router = az_info.get('default_tier0_router')
|
||||||
|
if self.default_tier0_router is None:
|
||||||
|
self.default_tier0_router = cfg.CONF.nsx_v3.default_tier0_router
|
||||||
|
|
||||||
def init_default_az(self):
|
def init_default_az(self):
|
||||||
# use the default configuration
|
# use the default configuration
|
||||||
self.metadata_proxy = cfg.CONF.nsx_v3.metadata_proxy
|
self.metadata_proxy = cfg.CONF.nsx_v3.metadata_proxy
|
||||||
@ -100,6 +104,7 @@ class NsxV3AvailabilityZone(common_az.ConfiguredAvailabilityZone):
|
|||||||
self.default_vlan_tz = cfg.CONF.nsx_v3.default_vlan_tz
|
self.default_vlan_tz = cfg.CONF.nsx_v3.default_vlan_tz
|
||||||
self.switching_profiles = cfg.CONF.nsx_v3.switching_profiles
|
self.switching_profiles = cfg.CONF.nsx_v3.switching_profiles
|
||||||
self.dhcp_relay_service = cfg.CONF.nsx_v3.dhcp_relay_service
|
self.dhcp_relay_service = cfg.CONF.nsx_v3.dhcp_relay_service
|
||||||
|
self.default_tier0_router = cfg.CONF.nsx_v3.default_tier0_router
|
||||||
|
|
||||||
def translate_configured_names_to_uuids(self, nsxlib):
|
def translate_configured_names_to_uuids(self, nsxlib):
|
||||||
# Mandatory configurations (in AZ or inherited from global values)
|
# Mandatory configurations (in AZ or inherited from global values)
|
||||||
@ -205,6 +210,24 @@ class NsxV3AvailabilityZone(common_az.ConfiguredAvailabilityZone):
|
|||||||
self.dhcp_relay_service = None
|
self.dhcp_relay_service = None
|
||||||
self.dhcp_relay_servers = None
|
self.dhcp_relay_servers = None
|
||||||
|
|
||||||
|
if self.default_tier0_router:
|
||||||
|
rtr_id = None
|
||||||
|
if cfg.CONF.nsx_v3.init_objects_by_tags:
|
||||||
|
# Find the router by its tag
|
||||||
|
resource_type = (nsxlib.logical_router.resource_type +
|
||||||
|
' AND router_type:TIER0')
|
||||||
|
rtr_id = nsxlib.get_id_by_resource_and_tag(
|
||||||
|
resource_type,
|
||||||
|
cfg.CONF.nsx_v3.search_objects_scope,
|
||||||
|
self.default_tier0_router)
|
||||||
|
if not rtr_id:
|
||||||
|
# find the router by name or id
|
||||||
|
rtr_id = nsxlib.logical_router.get_id_by_name_or_id(
|
||||||
|
self.default_tier0_router)
|
||||||
|
self._default_tier0_router = rtr_id
|
||||||
|
else:
|
||||||
|
self._default_tier0_router = None
|
||||||
|
|
||||||
|
|
||||||
class NsxV3AvailabilityZones(common_az.ConfiguredAvailabilityZones):
|
class NsxV3AvailabilityZones(common_az.ConfiguredAvailabilityZones):
|
||||||
|
|
||||||
|
@ -439,24 +439,6 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
raise cfg.RequiredOptError("search_objects_scope",
|
raise cfg.RequiredOptError("search_objects_scope",
|
||||||
group=cfg.OptGroup('nsx_v3'))
|
group=cfg.OptGroup('nsx_v3'))
|
||||||
|
|
||||||
# default tier0 router
|
|
||||||
self._default_tier0_router = None
|
|
||||||
if cfg.CONF.nsx_v3.default_tier0_router:
|
|
||||||
rtr_id = None
|
|
||||||
if cfg.CONF.nsx_v3.init_objects_by_tags:
|
|
||||||
# Find the router by its tag
|
|
||||||
resource_type = (self.nsxlib.logical_router.resource_type +
|
|
||||||
' AND router_type:TIER0')
|
|
||||||
rtr_id = self.nsxlib.get_id_by_resource_and_tag(
|
|
||||||
resource_type,
|
|
||||||
cfg.CONF.nsx_v3.search_objects_scope,
|
|
||||||
cfg.CONF.nsx_v3.default_tier0_router)
|
|
||||||
if not rtr_id:
|
|
||||||
# find the router by name or id
|
|
||||||
rtr_id = self.nsxlib.logical_router.get_id_by_name_or_id(
|
|
||||||
cfg.CONF.nsx_v3.default_tier0_router)
|
|
||||||
self._default_tier0_router = rtr_id
|
|
||||||
|
|
||||||
# Validate and translate native dhcp profiles per az
|
# Validate and translate native dhcp profiles per az
|
||||||
if cfg.CONF.nsx_v3.native_dhcp_metadata:
|
if cfg.CONF.nsx_v3.native_dhcp_metadata:
|
||||||
if not cfg.CONF.nsx_v3.dhcp_profile:
|
if not cfg.CONF.nsx_v3.dhcp_profile:
|
||||||
@ -905,9 +887,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
tier0_info = self.tier0_groups_dict[tier0_uuid]
|
tier0_info = self.tier0_groups_dict[tier0_uuid]
|
||||||
return tier0_info['edge_cluster_uuid']
|
return tier0_info['edge_cluster_uuid']
|
||||||
|
|
||||||
def _validate_external_net_create(self, net_data):
|
def _validate_external_net_create(self, net_data, az):
|
||||||
if not validators.is_attr_set(net_data.get(pnet.PHYSICAL_NETWORK)):
|
if not validators.is_attr_set(net_data.get(pnet.PHYSICAL_NETWORK)):
|
||||||
tier0_uuid = self._default_tier0_router
|
tier0_uuid = az._default_tier0_router
|
||||||
else:
|
else:
|
||||||
tier0_uuid = net_data[pnet.PHYSICAL_NETWORK]
|
tier0_uuid = net_data[pnet.PHYSICAL_NETWORK]
|
||||||
if ((validators.is_attr_set(net_data.get(pnet.NETWORK_TYPE)) and
|
if ((validators.is_attr_set(net_data.get(pnet.NETWORK_TYPE)) and
|
||||||
@ -1090,7 +1072,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
if validators.is_attr_set(external) and external:
|
if validators.is_attr_set(external) and external:
|
||||||
self._assert_on_external_net_with_qos(net_data)
|
self._assert_on_external_net_with_qos(net_data)
|
||||||
is_provider_net, net_type, physical_net, vlan_id = (
|
is_provider_net, net_type, physical_net, vlan_id = (
|
||||||
self._validate_external_net_create(net_data))
|
self._validate_external_net_create(net_data, az))
|
||||||
else:
|
else:
|
||||||
is_provider_net, net_type, physical_net, vlan_id, nsx_net_id = (
|
is_provider_net, net_type, physical_net, vlan_id, nsx_net_id = (
|
||||||
self._create_network_at_the_backend(context, net_data, az,
|
self._create_network_at_the_backend(context, net_data, az,
|
||||||
@ -3184,7 +3166,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
return
|
return
|
||||||
network = self.get_network(context, network_id)
|
network = self.get_network(context, network_id)
|
||||||
if not network.get(pnet.PHYSICAL_NETWORK):
|
if not network.get(pnet.PHYSICAL_NETWORK):
|
||||||
return self._default_tier0_router
|
az = self.get_network_az_by_net_id(context, network_id)
|
||||||
|
return az._default_tier0_router
|
||||||
else:
|
else:
|
||||||
return network.get(pnet.PHYSICAL_NETWORK)
|
return network.get(pnet.PHYSICAL_NETWORK)
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
cfg.CONF.set_override("nameservers", ["10.1.1.1"], group="nsx_v3")
|
cfg.CONF.set_override("nameservers", ["10.1.1.1"], group="nsx_v3")
|
||||||
cfg.CONF.set_override("switching_profiles", ["uuid1"], group="nsx_v3")
|
cfg.CONF.set_override("switching_profiles", ["uuid1"], group="nsx_v3")
|
||||||
cfg.CONF.set_override("dhcp_relay_service", "service1", group="nsx_v3")
|
cfg.CONF.set_override("dhcp_relay_service", "service1", group="nsx_v3")
|
||||||
|
cfg.CONF.set_override(
|
||||||
|
"default_tier0_router", "uuidrtr1", group="nsx_v3")
|
||||||
|
|
||||||
def _config_az(self,
|
def _config_az(self,
|
||||||
metadata_proxy="metadata_proxy1",
|
metadata_proxy="metadata_proxy1",
|
||||||
@ -52,7 +54,8 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
default_overlay_tz='otz',
|
default_overlay_tz='otz',
|
||||||
default_vlan_tz='vtz',
|
default_vlan_tz='vtz',
|
||||||
switching_profiles=["uuid2"],
|
switching_profiles=["uuid2"],
|
||||||
dhcp_relay_service="service2"):
|
dhcp_relay_service="service2",
|
||||||
|
default_tier0_router="uuidrtr2"):
|
||||||
if metadata_proxy is not None:
|
if metadata_proxy is not None:
|
||||||
cfg.CONF.set_override("metadata_proxy", metadata_proxy,
|
cfg.CONF.set_override("metadata_proxy", metadata_proxy,
|
||||||
group=self.group_name)
|
group=self.group_name)
|
||||||
@ -81,6 +84,9 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
if dhcp_relay_service is not None:
|
if dhcp_relay_service is not None:
|
||||||
cfg.CONF.set_override("dhcp_relay_service", dhcp_relay_service,
|
cfg.CONF.set_override("dhcp_relay_service", dhcp_relay_service,
|
||||||
group=self.group_name)
|
group=self.group_name)
|
||||||
|
if default_tier0_router is not None:
|
||||||
|
cfg.CONF.set_override("default_tier0_router", default_tier0_router,
|
||||||
|
group=self.group_name)
|
||||||
|
|
||||||
def test_simple_availability_zone(self):
|
def test_simple_availability_zone(self):
|
||||||
self._config_az()
|
self._config_az()
|
||||||
@ -95,6 +101,7 @@ class Nsxv3AvailabilityZonesTestCase(base.BaseTestCase):
|
|||||||
self.assertEqual("vtz", az.default_vlan_tz)
|
self.assertEqual("vtz", az.default_vlan_tz)
|
||||||
self.assertEqual(["uuid2"], az.switching_profiles)
|
self.assertEqual(["uuid2"], az.switching_profiles)
|
||||||
self.assertEqual("service2", az.dhcp_relay_service)
|
self.assertEqual("service2", az.dhcp_relay_service)
|
||||||
|
self.assertEqual("uuidrtr2", az.default_tier0_router)
|
||||||
|
|
||||||
def test_missing_group_section(self):
|
def test_missing_group_section(self):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
|
Loading…
Reference in New Issue
Block a user