Fix incorrect NotImplementedError

neutron.common.exceptions doesn't define NotImplementedError, but
some codes still use it. We should use builtin
exceptions.NotImplementedError instead.

Note: this patch also fixes a never run code in nvp.

Closes-Bug: #1221500
Change-Id: I5f367ab5edc1e7fbbc2e4eba5fe36d148d4d062d
This commit is contained in:
ZhiQiang Fan 2013-09-06 13:27:19 +08:00
parent 1a25274e7a
commit 0739b2fe82
3 changed files with 14 additions and 7 deletions

View File

@ -285,7 +285,7 @@ class RouterPluginBase(object):
pass
def get_routers_count(self, context, filters=None):
raise qexception.NotImplementedError()
raise NotImplementedError()
def get_floatingips_count(self, context, filters=None):
raise qexception.NotImplementedError()
raise NotImplementedError()

View File

@ -1086,11 +1086,9 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
def update_network(self, context, id, network):
pnet._raise_if_updates_provider_attributes(network['network'])
if network["network"].get("admin_state_up"):
if network['network']["admin_state_up"] is False:
raise q_exc.NotImplementedError(_("admin_state_up=False "
"networks are not "
"supported."))
if network["network"].get("admin_state_up") is False:
raise NotImplementedError(_("admin_state_up=False networks "
"are not supported."))
with context.session.begin(subtransactions=True):
net = super(NvpPluginV2, self).update_network(context, id, network)
if psec.PORTSECURITY in network['network']:

View File

@ -324,6 +324,15 @@ class TestNiciraNetworksV2(test_plugin.TestNetworksV2,
self.assertEqual(webob.exc.HTTPServiceUnavailable.code,
res.status_int)
def test_update_network_with_admin_false(self):
data = {'network': {'admin_state_up': False}}
with self.network() as net:
plugin = manager.NeutronManager.get_plugin()
self.assertRaises(NotImplementedError,
plugin.update_network,
context.get_admin_context(),
net['network']['id'], data)
class NiciraPortSecurityTestCase(psec.PortSecurityDBTestCase):