Ensures port is not created when database exception occurs
Fixes bug 1064261 The port creation code did not correctly treat a database error. That is, if there was an exception the port would be created and an error returned to the client. Change-Id: I6cf36d1c641b46716afb16f228b8daa631099a5d
This commit is contained in:
parent
d7a440abc9
commit
6d2bfa49e8
@ -1159,9 +1159,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
device_owner=p['device_owner'])
|
||||
context.session.add(port)
|
||||
|
||||
# Update the allocated IP's
|
||||
if ips:
|
||||
with context.session.begin(subtransactions=True):
|
||||
# Update the allocated IP's
|
||||
if ips:
|
||||
for ip in ips:
|
||||
LOG.debug("Allocated IP %s (%s/%s/%s)", ip['ip_address'],
|
||||
port['network_id'], ip['subnet_id'], port.id)
|
||||
|
@ -1193,6 +1193,19 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
||||
for p in ports_to_delete:
|
||||
self._delete('ports', p['port']['id'])
|
||||
|
||||
def test_duplicate_ips(self):
|
||||
fmt = 'json'
|
||||
with self.subnet() as subnet:
|
||||
# Allocate specific IP
|
||||
kwargs = {"fixed_ips": [{'subnet_id': subnet['subnet']['id'],
|
||||
'ip_address': '10.0.0.5'},
|
||||
{'subnet_id': subnet['subnet']['id'],
|
||||
'ip_address': '10.0.0.5'}]}
|
||||
net_id = subnet['subnet']['network_id']
|
||||
res = self._create_port(fmt, net_id=net_id, **kwargs)
|
||||
port2 = self.deserialize(fmt, res)
|
||||
self.assertEquals(res.status_int, 500)
|
||||
|
||||
def test_requested_ips_only(self):
|
||||
fmt = 'json'
|
||||
with self.subnet() as subnet:
|
||||
|
Loading…
x
Reference in New Issue
Block a user