Ensure that exception prints UUID and not pointer.
Fixes bug 1095648 Change-Id: I3effbc2e93d143ba7a5c3b047c1618f165c1b0b6
This commit is contained in:
parent
aef6a564b3
commit
d57a66ee61
@ -414,7 +414,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
subnet_id=subnet_id).delete()
|
||||
|
||||
@staticmethod
|
||||
def _generate_ip(context, network_id, subnets):
|
||||
def _generate_ip(context, subnets):
|
||||
"""Generate an IP address.
|
||||
|
||||
The IP address will be generated from one of the subnets defined on
|
||||
@ -445,7 +445,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
# increment the first free
|
||||
range['first_ip'] = str(netaddr.IPAddress(ip_address) + 1)
|
||||
return {'ip_address': ip_address, 'subnet_id': subnet['id']}
|
||||
raise q_exc.IpAddressGenerationFailure(net_id=network_id)
|
||||
raise q_exc.IpAddressGenerationFailure(net_id=subnets[0]['network_id'])
|
||||
|
||||
@staticmethod
|
||||
def _allocate_specific_ip(context, subnet_id, ip_address):
|
||||
@ -608,7 +608,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
else:
|
||||
subnets = [self._get_subnet(context, fixed['subnet_id'])]
|
||||
# IP address allocation
|
||||
result = self._generate_ip(context, network, subnets)
|
||||
result = self._generate_ip(context, subnets)
|
||||
ips.append({'ip_address': result['ip_address'],
|
||||
'subnet_id': result['subnet_id']})
|
||||
return ips
|
||||
@ -674,8 +674,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
version_subnets = [v4, v6]
|
||||
for subnets in version_subnets:
|
||||
if subnets:
|
||||
result = QuantumDbPluginV2._generate_ip(context, network,
|
||||
subnets)
|
||||
result = QuantumDbPluginV2._generate_ip(context, subnets)
|
||||
ips.append({'ip_address': result['ip_address'],
|
||||
'subnet_id': result['subnet_id']})
|
||||
return ips
|
||||
|
@ -873,6 +873,16 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
||||
self.assertEqual(res['port']['fixed_ips'],
|
||||
data['port']['fixed_ips'])
|
||||
|
||||
def test_no_more_port_exception(self):
|
||||
fmt = 'json'
|
||||
with self.subnet(cidr='10.0.0.0/32') as subnet:
|
||||
id = subnet['subnet']['network_id']
|
||||
res = self._create_port(fmt, id)
|
||||
data = self.deserialize(fmt, res)
|
||||
msg = str(q_exc.IpAddressGenerationFailure(net_id=id))
|
||||
self.assertEqual(data['QuantumError'], msg)
|
||||
self.assertEqual(res.status_int, 409)
|
||||
|
||||
def test_update_port_update_ip(self):
|
||||
"""Test update of port IP.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user