Merge "Narrow down DBError to DBReferenceError in DHCP action handler"

This commit is contained in:
Jenkins 2016-08-31 06:51:18 +00:00 committed by Gerrit Code Review
commit 1d4a621718
2 changed files with 9 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import operator
from neutron_lib import constants
from neutron_lib import exceptions
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_log import log as logging
import oslo_messaging
from oslo_utils import excutils
@ -100,7 +101,8 @@ class DhcpRpcCallback(object):
else:
msg = _('Unrecognized action')
raise exceptions.Invalid(message=msg)
except (exceptions.NetworkNotFound,
except (db_exc.DBReferenceError,
exceptions.NetworkNotFound,
exceptions.SubnetNotFound,
exceptions.InvalidInput,
exceptions.IpAddressGenerationFailure) as e:

View File

@ -16,6 +16,7 @@
import mock
from neutron_lib import constants
from neutron_lib import exceptions as n_exc
from oslo_db import exception as db_exc
from neutron.api.rpc.handlers import dhcp_rpc
from neutron.callbacks import resources
@ -139,6 +140,11 @@ class TestDhcpRpcCallback(base.BaseTestCase):
exc=n_exc.SubnetNotFound(subnet_id='foo_subnet_id'),
action='create_port')
def test_create_port_catch_db_reference_error(self):
self._test__port_action_with_failures(
exc=db_exc.DBReferenceError('a', 'b', 'c', 'd'),
action='create_port')
def test_create_port_catch_ip_generation_failure_reraise(self):
self.assertRaises(
n_exc.IpAddressGenerationFailure,