Merge "Make sure we can update when there is no gateway port linked to it"
This commit is contained in:
commit
ff8c9f82a5
@ -720,13 +720,11 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
|
||||
# must make sure we do not have any external gateway ports
|
||||
# (and thus, possible floating IPs) on this network before
|
||||
# allow it to be update to external=False
|
||||
try:
|
||||
context.session.query(models_v2.Port).filter_by(
|
||||
device_owner=DEVICE_OWNER_ROUTER_GW,
|
||||
network_id=net_id).first()
|
||||
port = context.session.query(models_v2.Port).filter_by(
|
||||
device_owner=DEVICE_OWNER_ROUTER_GW,
|
||||
network_id=net_id).first()
|
||||
if port:
|
||||
raise l3.ExternalNetworkInUse(net_id=net_id)
|
||||
except exc.NoResultFound:
|
||||
pass # expected
|
||||
|
||||
context.session.query(ExternalNetwork).filter_by(
|
||||
network_id=net_id).delete()
|
||||
|
@ -631,6 +631,35 @@ class L3NatDBTestCase(test_db_plugin.QuantumDbPluginV2TestCase):
|
||||
expected_code=exc.
|
||||
HTTPBadRequest.code)
|
||||
|
||||
def test_network_update_external_failure(self):
|
||||
with self.router() as r:
|
||||
with self.subnet() as s1:
|
||||
self._set_net_external(s1['subnet']['network_id'])
|
||||
self._add_external_gateway_to_router(
|
||||
r['router']['id'],
|
||||
s1['subnet']['network_id'])
|
||||
self._update('networks', s1['subnet']['network_id'],
|
||||
{'network': {'router:external': False}},
|
||||
expected_code=exc.HTTPConflict.code)
|
||||
self._remove_external_gateway_from_router(
|
||||
r['router']['id'],
|
||||
s1['subnet']['network_id'])
|
||||
|
||||
def test_network_update_external(self):
|
||||
with self.router() as r:
|
||||
with self.network('test_net') as testnet:
|
||||
self._set_net_external(testnet['network']['id'])
|
||||
with self.subnet() as s1:
|
||||
self._set_net_external(s1['subnet']['network_id'])
|
||||
self._add_external_gateway_to_router(
|
||||
r['router']['id'],
|
||||
s1['subnet']['network_id'])
|
||||
self._update('networks', testnet['network']['id'],
|
||||
{'network': {'router:external': False}})
|
||||
self._remove_external_gateway_from_router(
|
||||
r['router']['id'],
|
||||
s1['subnet']['network_id'])
|
||||
|
||||
def test_create_router_with_gwinfo(self):
|
||||
with self.subnet() as s:
|
||||
self._set_net_external(s['subnet']['network_id'])
|
||||
|
Loading…
Reference in New Issue
Block a user