]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixes port status hanging to build status
authorPetrut Lucian <lpetrut@cloudbasesolutions.com>
Wed, 25 Sep 2013 17:07:01 +0000 (20:07 +0300)
committerThierry Carrez <thierry@openstack.org>
Fri, 11 Oct 2013 08:10:20 +0000 (10:10 +0200)
ML2 plugin changes the port status to "build" when get_device_details
is called. For this reason, the port status must be updated once the
port details are processed.

Fixes bug: #1224991

Change-Id: I2c0321073cc07e1764fedbfbecbc844557ac6bc9
(cherry picked from commit 01194b356e39e3b0affca67015efb7634bf28697)

neutron/plugins/hyperv/agent/hyperv_neutron_agent.py
neutron/tests/unit/hyperv/test_hyperv_neutron_agent.py

index 209b9122c432fd315928e0c357a642c664fd9671..0944ca39e6819e80f987929b53acb6719f61d1a8 100644 (file)
@@ -310,6 +310,10 @@ class HyperVNeutronAgent(object):
                     device_details['physical_network'],
                     device_details['segmentation_id'],
                     device_details['admin_state_up'])
+                self.plugin_rpc.update_device_up(self.context,
+                                                 device,
+                                                 self.agent_id,
+                                                 cfg.CONF.host)
         return resync
 
     def _treat_devices_removed(self, devices):
index 59cdcb896a43ed9664b3200f816cc671b68e5766..c622968ef3a07f08a3b0f1214857e4a18208ce77 100644 (file)
@@ -111,8 +111,20 @@ class TestHyperVNeutronAgent(base.BaseTestCase):
     def test_treat_devices_added_updates_known_port(self):
         details = mock.MagicMock()
         details.__contains__.side_effect = lambda x: True
-        self.assertTrue(self.mock_treat_devices_added(details,
-                                                      '_treat_vif_port'))
+        with mock.patch.object(self.agent.plugin_rpc,
+                               "update_device_up") as func:
+            self.assertTrue(self.mock_treat_devices_added(details,
+                                                          '_treat_vif_port'))
+            self.assertTrue(func.called)
+
+    def test_treat_devices_added_missing_port_id(self):
+        details = mock.MagicMock()
+        details.__contains__.side_effect = lambda x: False
+        with mock.patch.object(self.agent.plugin_rpc,
+                               "update_device_up") as func:
+            self.assertFalse(self.mock_treat_devices_added(details,
+                                                           '_treat_vif_port'))
+            self.assertFalse(func.called)
 
     def test_treat_devices_removed_returns_true_for_missing_device(self):
         attrs = {'update_device_down.side_effect': Exception()}