agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
host = kwargs.get('host')
- port = self.get_port_from_device.get_port(device)
+ port = self.get_port_from_device(device)
LOG.debug(_("Device %(device)s up on %(agent_id)s"),
{'device': device, 'agent_id': agent_id})
plugin = manager.NeutronManager.get_plugin()
# See the License for the specific language governing permissions and
# limitations under the License.
+import contextlib
+
+import mock
+
+from neutron.common import constants as q_const
from neutron.extensions import portbindings
+from neutron import manager
+from neutron.plugins.linuxbridge import lb_neutron_plugin
from neutron.tests.unit import _test_extension_portbindings as test_bindings
from neutron.tests.unit import test_db_plugin as test_plugin
from neutron.tests.unit import test_security_groups_rpc as test_sg_rpc
-
PLUGIN_NAME = ('neutron.plugins.linuxbridge.'
'lb_neutron_plugin.LinuxBridgePluginV2')
LinuxBridgePluginV2TestCase,
test_bindings.PortBindingsHostTestCaseMixin):
pass
+
+
+class TestLinuxBridgePluginRpcCallbacks(test_plugin.NeutronDbPluginV2TestCase):
+ def setUp(self):
+ super(TestLinuxBridgePluginRpcCallbacks, self).setUp(PLUGIN_NAME)
+ self.callbacks = lb_neutron_plugin.LinuxBridgeRpcCallbacks()
+
+ def test_update_device_down(self):
+ with contextlib.nested(
+ mock.patch.object(self.callbacks, "get_port_from_device",
+ return_value=None),
+ mock.patch.object(manager.NeutronManager, "get_plugin")
+ ) as (gpfd, gp):
+ self.assertEqual(
+ self.callbacks.update_device_down("fake_context",
+ agent_id="123",
+ device="device",
+ host="host"),
+ {'device': 'device', 'exists': False}
+ )
+ gpfd.return_value = {'id': 'fakeid',
+ 'status': q_const.PORT_STATUS_ACTIVE}
+ self.assertEqual(
+ self.callbacks.update_device_down("fake_context",
+ agent_id="123",
+ device="device",
+ host="host"),
+ {'device': 'device', 'exists': True}
+ )
+
+ def test_update_device_up(self):
+ with contextlib.nested(
+ mock.patch.object(self.callbacks, "get_port_from_device",
+ return_value=None),
+ mock.patch.object(manager.NeutronManager, "get_plugin")
+ ) as (gpfd, gp):
+ gpfd.return_value = {'id': 'fakeid',
+ 'status': q_const.PORT_STATUS_ACTIVE}
+ self.callbacks.update_device_up("fake_context",
+ agent_id="123",
+ device="device",
+ host="host")
+ gpfd.assert_called_once_with('device')