]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix bad call in port_update in linuxbridge agent
authorDarragh O'Reilly <dara2002-openstack@yahoo.com>
Mon, 2 Dec 2013 12:49:50 +0000 (12:49 +0000)
committerDarragh O'Reilly <dara2002-openstack@yahoo.com>
Tue, 3 Dec 2013 12:35:27 +0000 (12:35 +0000)
A call to update_device_down() was made on the wrong object.
Also adds unit tests for code paths to update_device_down() and
update_device_up().

Partial-Bug: 1256950
Change-Id: I34e364d4c29441d0b62b665a4ce1d02b5d08d465

neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py
neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py

index ee6e0b5de547b0de362a9011962d547f519112fa..54ce9959d2ec1e221b9e1a1a1effacd2ac9cc4b1 100755 (executable)
@@ -661,10 +661,12 @@ class LinuxBridgeRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
                                                            self.agent.agent_id,
                                                            cfg.CONF.host)
                 else:
-                    self.plugin_rpc.update_device_down(self.context,
-                                                       tap_device_name,
-                                                       self.agent.agent_id,
-                                                       cfg.CONF.host)
+                    self.agent.plugin_rpc.update_device_down(
+                        self.context,
+                        tap_device_name,
+                        self.agent.agent_id,
+                        cfg.CONF.host
+                    )
             else:
                 bridge_name = self.agent.br_mgr.get_bridge_name(
                     port['network_id'])
index 734b83a445315c43bca3619b6f45d62accdeb00d..0b96c8b2bc9dfa5e31d0eccb9595408e35f96b86 100644 (file)
@@ -770,6 +770,30 @@ class TestLinuxBridgeRpcCallbacks(base.BaseTestCase):
             addif_fn.assert_called_with(port["network_id"], lconst.TYPE_LOCAL,
                                         None, None, port["id"])
 
+            addif_fn.return_value = True
+            self.lb_rpc.port_update("unused_context", port=port,
+                                    network_type=lconst.TYPE_LOCAL,
+                                    segmentation_id=None,
+                                    physical_network=None)
+            rpc_obj.update_device_up.assert_called_with(
+                self.lb_rpc.context,
+                "tap123",
+                self.lb_rpc.agent.agent_id,
+                cfg.CONF.host
+            )
+
+            addif_fn.return_value = False
+            self.lb_rpc.port_update("unused_context", port=port,
+                                    network_type=lconst.TYPE_LOCAL,
+                                    segmentation_id=None,
+                                    physical_network=None)
+            rpc_obj.update_device_down.assert_called_with(
+                self.lb_rpc.context,
+                "tap123",
+                self.lb_rpc.agent.agent_id,
+                cfg.CONF.host
+            )
+
             port["admin_state_up"] = False
             port["security_groups"] = True
             getbr_fn.return_value = "br0"