NSX|P support selection tier1 edge cluster
Change-Id: I92e4006ce47fa23307ef1a17e21b8397a1bc29fa
This commit is contained in:
parent
cd85073e7e
commit
1ac3b568e9
@ -917,6 +917,10 @@ nsx_v3_and_p_az_opts = [
|
||||
help=_("Name or UUID of the default tier0 router that will be "
|
||||
"used for connecting to tier1 logical routers and "
|
||||
"configuring external networks")),
|
||||
cfg.StrOpt('edge_cluster',
|
||||
help=_("(Optional) Specifying an edge cluster for Tier1 "
|
||||
"routers to connect other that the one connected to"
|
||||
" the Tier0 router")),
|
||||
]
|
||||
|
||||
nsxv3_az_opts = nsx_v3_and_p_az_opts + [
|
||||
@ -931,10 +935,6 @@ nsxv3_az_opts = nsx_v3_and_p_az_opts + [
|
||||
help=_("Name or UUID of the default tier0 router that will be "
|
||||
"used for connecting to tier1 logical routers and "
|
||||
"configuring external networks")),
|
||||
cfg.StrOpt('edge_cluster',
|
||||
help=_("(Optional) Specifying an edge cluster for Tier1 "
|
||||
"routers to connect other that the one connected to"
|
||||
" the Tier0 router")),
|
||||
]
|
||||
|
||||
nsxp_az_opts = nsx_v3_and_p_az_opts
|
||||
|
@ -85,6 +85,10 @@ class NsxV3AvailabilityZone(common_az.ConfiguredAvailabilityZone):
|
||||
if nameservers:
|
||||
self.nameservers = nameservers
|
||||
|
||||
edge_cluster = az_info.get('edge_cluster')
|
||||
if edge_cluster:
|
||||
self.edge_cluster = edge_cluster
|
||||
|
||||
def init_defaults(self):
|
||||
# Should be implemented by children
|
||||
pass
|
||||
|
@ -42,6 +42,7 @@ class NsxPAvailabilityZone(v3_az.NsxV3AvailabilityZone):
|
||||
self.default_tier0_router = cfg.CONF.nsx_p.default_tier0_router
|
||||
self.dns_domain = cfg.CONF.nsx_p.dns_domain
|
||||
self.nameservers = cfg.CONF.nsx_p.nameservers
|
||||
self.edge_cluster = cfg.CONF.nsx_p.edge_cluster
|
||||
|
||||
def _init_default_resource(self, nsxpolicy, resource_api, config_name,
|
||||
filter_list_results=None,
|
||||
@ -129,6 +130,11 @@ class NsxPAvailabilityZone(v3_az.NsxV3AvailabilityZone):
|
||||
auto_config=True, is_mandatory=True,
|
||||
search_scope=search_scope)
|
||||
|
||||
self._edge_cluster_uuid = self._init_default_resource(
|
||||
nsxpolicy, nsxpolicy.edge_cluster, 'edge_cluster',
|
||||
auto_config=True, is_mandatory=False,
|
||||
search_scope=search_scope)
|
||||
|
||||
# If passthrough api is supported, also initialize those NSX objects
|
||||
if nsxlib:
|
||||
self._translate_dhcp_profile(nsxlib, search_scope=search_scope)
|
||||
|
@ -1052,7 +1052,14 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
||||
nat_rule_id=self._get_snat_rule_id(subnet))
|
||||
|
||||
def _get_edge_cluster_path(self, tier0_uuid, router):
|
||||
# TODO(asarfaty): Add support for edge cluster from the AZ config
|
||||
# Take the AZ edge cluster if configured
|
||||
az = self._get_router_az_obj(router)
|
||||
if az and az._edge_cluster_uuid:
|
||||
ec_id = az._edge_cluster_uuid
|
||||
# get the full path of the edge cluster (no backend call)
|
||||
return self.nsxpolicy.edge_cluster.get_path(ec_id)
|
||||
|
||||
# Get the current tier0 edge cluster (cached call)
|
||||
return self.nsxpolicy.tier0.get_edge_cluster_path(
|
||||
tier0_uuid)
|
||||
|
||||
|
@ -1767,3 +1767,24 @@ class NsxPTestL3NatTestCase(NsxPTestL3NatTest,
|
||||
with self.router(name=name, availability_zone_hints=zone) as rtr:
|
||||
az_hints = rtr['router']['availability_zone_hints']
|
||||
self.assertListEqual(zone, az_hints)
|
||||
|
||||
def test_update_router_distinct_edge_cluster(self):
|
||||
# define an edge cluster in the config
|
||||
edge_cluster = uuidutils.generate_uuid()
|
||||
cfg.CONF.set_override('edge_cluster', edge_cluster, 'nsx_p')
|
||||
self._initialize_azs()
|
||||
path_prefix = ("/infra/sites/default/enforcement-points/default/"
|
||||
"edge-clusters/")
|
||||
# create a router and external network
|
||||
with self.router() as r,\
|
||||
self._create_l3_ext_network() as ext_net,\
|
||||
self.subnet(network=ext_net, cidr='10.0.1.0/24',
|
||||
enable_dhcp=False) as s,\
|
||||
mock.patch("vmware_nsxlib.v3.policy.core_resources."
|
||||
"NsxPolicyTier1Api.set_edge_cluster_path"
|
||||
) as add_srv_router:
|
||||
self._add_external_gateway_to_router(
|
||||
r['router']['id'],
|
||||
s['subnet']['network_id'])
|
||||
add_srv_router.assert_called_once_with(
|
||||
mock.ANY, '%s%s' % (path_prefix, edge_cluster))
|
||||
|
@ -3027,6 +3027,7 @@ class TestL3NatTestCase(L3NatTest,
|
||||
self._add_external_gateway_to_router(
|
||||
router_id, ext_subnet['network_id'])
|
||||
change_sr.assert_called_once_with(mock.ANY, edge_cluster)
|
||||
self.mock_get_edge_cluster.start()
|
||||
|
||||
|
||||
class ExtGwModeTestCase(test_ext_gw_mode.ExtGwModeIntTestCase,
|
||||
|
Loading…
x
Reference in New Issue
Block a user