Merge "Fix add same network on different type routers failed"
This commit is contained in:
commit
821cf77f21
@ -222,9 +222,10 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
|
||||
intf_ports = _nsxv_plugin.get_ports(context.elevated(),
|
||||
filters=port_filters)
|
||||
router_ids = [port['device_id'] for port in intf_ports]
|
||||
dist_router_filters = {'id': router_ids,
|
||||
'distributed': [True]}
|
||||
dist_routers = _nsxv_plugin.get_routers(context, dist_router_filters)
|
||||
all_routers = _nsxv_plugin.get_routers(context,
|
||||
filters={'id': router_ids})
|
||||
dist_routers = [router for router in all_routers
|
||||
if router.get('distributed') is True]
|
||||
if len(dist_routers) > 0:
|
||||
err_msg = _("network can only be attached to just one distributed "
|
||||
"router, the network is already attached to router "
|
||||
|
@ -3251,6 +3251,14 @@ class TestVdrTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
IPv6ExpectedFailuresTestMixin,
|
||||
NsxVPluginV2TestCase):
|
||||
|
||||
def setUp(self, plugin=PLUGIN_NAME, ext_mgr=None, service_plugins=None):
|
||||
super(TestVdrTestCase, self).setUp(
|
||||
plugin=plugin, ext_mgr=ext_mgr, service_plugins=service_plugins)
|
||||
self.plugin_instance.nsx_v.is_subnet_in_use = mock.Mock()
|
||||
self.plugin_instance.nsx_v.is_subnet_in_use.return_value = False
|
||||
self._default_tenant_id = self._tenant_id
|
||||
self._router_tenant_id = 'test-router-tenant'
|
||||
|
||||
@mock.patch.object(edge_utils.EdgeManager,
|
||||
'update_interface_addr')
|
||||
def test_router_update_gateway_with_different_external_subnet(self, mock):
|
||||
@ -3301,10 +3309,13 @@ class TestVdrTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
data['router'][arg] = kwargs[arg]
|
||||
|
||||
if 'distributed' in kwargs:
|
||||
data['router']['distributed'] = kwargs[arg]
|
||||
data['router']['distributed'] = kwargs['distributed']
|
||||
else:
|
||||
data['router']['distributed'] = True
|
||||
|
||||
if kwargs.get('router_type'):
|
||||
data['router']['router_type'] = kwargs.get('router_type')
|
||||
|
||||
router_req = self.new_create_request('routers', data, fmt)
|
||||
if set_context and tenant_id:
|
||||
# create a specific auth context for this request
|
||||
@ -3436,6 +3447,39 @@ class TestVdrTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
None,
|
||||
err_code)
|
||||
|
||||
def test_different_type_routers_add_interfaces_on_same_network_pass(self):
|
||||
with self.router() as dist, \
|
||||
self.router(distributed=False, router_type='shared') as shared, \
|
||||
self.router(distributed=False, router_type='exclusive') as excl:
|
||||
with self.network() as n:
|
||||
with self.subnet(network=n) as s1, \
|
||||
self.subnet(network=n, cidr='11.0.0.0/24') as s2, \
|
||||
self.subnet(network=n, cidr='12.0.0.0/24') as s3:
|
||||
self._router_interface_action('add',
|
||||
shared['router']['id'],
|
||||
s1['subnet']['id'],
|
||||
None)
|
||||
self._router_interface_action('add',
|
||||
excl['router']['id'],
|
||||
s2['subnet']['id'],
|
||||
None)
|
||||
self._router_interface_action('add',
|
||||
dist['router']['id'],
|
||||
s3['subnet']['id'],
|
||||
None)
|
||||
self._router_interface_action('remove',
|
||||
dist['router']['id'],
|
||||
s3['subnet']['id'],
|
||||
None)
|
||||
self._router_interface_action('remove',
|
||||
excl['router']['id'],
|
||||
s2['subnet']['id'],
|
||||
None)
|
||||
self._router_interface_action('remove',
|
||||
shared['router']['id'],
|
||||
s1['subnet']['id'],
|
||||
None)
|
||||
|
||||
def test_delete_ext_net_with_disassociated_floating_ips(self):
|
||||
with self.network() as net:
|
||||
net_id = net['network']['id']
|
||||
|
Loading…
Reference in New Issue
Block a user