Merge "Handle a NeutronClientException 404 Error for floating ips"

This commit is contained in:
Jenkins 2015-11-12 12:57:22 +00:00 committed by Gerrit Code Review
commit 3be51f19ae
2 changed files with 9 additions and 2 deletions

View File

@ -1468,7 +1468,11 @@ class API(base_api.NetworkAPI):
# list_floatingips will be raised.
except neutron_client_exc.NotFound:
return []
except neutron_client_exc.NeutronClientException:
except neutron_client_exc.NeutronClientException as e:
# bug/1513879 neutron client is currently using
# NeutronClientException when there is no L3 API
if e.status_code == 404:
return []
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Unable to access floating IP for %s'),
', '.join(['%s %s' % (k, v)

View File

@ -3585,7 +3585,10 @@ class TestNeutronv2WithMock(test.TestCase):
def test_get_floating_ips_by_project_not_found(self, mock_ntrn):
mock_nc = mock.Mock()
mock_ntrn.return_value = mock_nc
mock_nc.list_floatingips.side_effect = exceptions.NotFound()
# neutronclient doesn't raise NotFound in this scenario, it raises a
# NeutronClientException with status_code=404
notfound = exceptions.NeutronClientException(status_code=404)
mock_nc.list_floatingips.side_effect = notfound
fips = self.api.get_floating_ips_by_project(self.context)
self.assertEqual([], fips)