NEC plugin: Ensure to delete portinfo when port_removed RPC.

Fixes bug #1187249

Change-Id: Iaccfd1d4918df5dc4ba1c0478689fd4c833da7b3
This commit is contained in:
Akihiro MOTOKI 2013-06-04 12:45:23 +09:00
parent 7d18755b51
commit d98f8141a1
2 changed files with 13 additions and 1 deletions

View File

@ -667,7 +667,7 @@ class NECPluginV2RPCCallbacks(object):
"due to portinfo for port_id=%s was not "
"registered"), id)
continue
if portinfo.datapath_id is not datapath_id:
if portinfo.datapath_id != datapath_id:
LOG.debug(_("update_ports(): ignore port_removed message "
"received from different host "
"(registered_datapath_id=%(registered)s, "

View File

@ -19,6 +19,7 @@ from quantum.common import topics
from quantum import context as q_context
from quantum.extensions import portbindings
from quantum import manager
from quantum.plugins.nec.db import api as ndb
from quantum.plugins.nec import nec_plugin
from quantum.tests.unit import _test_extension_portbindings as test_bindings
from quantum.tests.unit import test_db_plugin as test_plugin
@ -110,17 +111,22 @@ class TestNecPortsV2Callback(NecPluginV2TestCase):
'port_added': added, 'port_removed': removed}
self.callbacks.update_ports(self.context, **kwargs)
def _get_portinfo(self, port_id):
return ndb.get_portinfo(self.context.session, port_id)
def test_port_create(self):
with self.port() as port:
port_id = port['port']['id']
sport = self.plugin.get_port(self.context, port_id)
self.assertEqual(sport['status'], 'DOWN')
self.assertIsNone(self._get_portinfo(port_id))
portinfo = {'id': port_id, 'port_no': 123}
self._rpcapi_update_ports(added=[portinfo])
sport = self.plugin.get_port(self.context, port_id)
self.assertEqual(sport['status'], 'ACTIVE')
self.assertIsNotNone(self._get_portinfo(port_id))
expected = [
mock.call.exists_ofc_port(mock.ANY, port_id),
@ -132,7 +138,13 @@ class TestNecPortsV2Callback(NecPluginV2TestCase):
with self.port() as port:
port_id = port['port']['id']
portinfo = {'id': port_id, 'port_no': 456}
self.assertIsNone(self._get_portinfo(port_id))
self._rpcapi_update_ports(added=[portinfo])
self.assertIsNotNone(self._get_portinfo(port_id))
self._rpcapi_update_ports(removed=[port_id])
self.assertIsNone(self._get_portinfo(port_id))
expected = [
mock.call.exists_ofc_port(mock.ANY, port_id),