Merge "Handle IpAddressAlreadyAllocated exception"
This commit is contained in:
commit
59c20e0caa
@ -443,7 +443,8 @@ class API(base_api.NetworkAPI):
|
||||
'network %(network_id)s.') %
|
||||
{'ip': fixed_ip, 'network_id': network_id})
|
||||
raise exception.InvalidInput(reason=msg)
|
||||
except neutron_client_exc.IpAddressInUseClient:
|
||||
except (neutron_client_exc.IpAddressInUseClient,
|
||||
neutron_client_exc.IpAddressAlreadyAllocatedClient):
|
||||
LOG.warning('Neutron error: Fixed IP %s is '
|
||||
'already in use.', fixed_ip, instance=instance)
|
||||
msg = _("Fixed IP %s is already in use.") % fixed_ip
|
||||
|
@ -3716,6 +3716,19 @@ class TestNeutronv2WithMock(test.TestCase):
|
||||
instance, uuids.my_netid1, fixed_ip=fake_ip)
|
||||
self.assertTrue(create_port_mock.called)
|
||||
|
||||
@mock.patch.object(client.Client, 'create_port',
|
||||
side_effect=exceptions.IpAddressAlreadyAllocatedClient())
|
||||
def test_create_port_minimal_raise_ip_already_allocated(self,
|
||||
create_port_mock):
|
||||
instance = fake_instance.fake_instance_obj(self.context)
|
||||
fake_ip = '1.1.1.1'
|
||||
|
||||
self.assertRaises(exception.FixedIpAlreadyInUse,
|
||||
self.api._create_port_minimal,
|
||||
neutronapi.get_client(self.context),
|
||||
instance, uuids.my_netid1, fixed_ip=fake_ip)
|
||||
self.assertTrue(create_port_mock.called)
|
||||
|
||||
@mock.patch.object(client.Client, 'create_port',
|
||||
side_effect=exceptions.InvalidIpForNetworkClient())
|
||||
def test_create_port_minimal_raise_invalid_ip(self, create_port_mock):
|
||||
|
Loading…
x
Reference in New Issue
Block a user