Browse Source

Merge "fix update port bug" into stable/queens

changes/56/677056/1
Zuul 1 month ago
parent
commit
16ea413805
2 changed files with 9 additions and 1 deletions
  1. 1
    1
      neutron/plugins/ml2/plugin.py
  2. 8
    0
      neutron/tests/unit/plugins/ml2/test_plugin.py

+ 1
- 1
neutron/plugins/ml2/plugin.py View File

@@ -392,7 +392,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
392 392
             binding.host = host
393 393
             changes = True
394 394
 
395
-        vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE)
395
+        vnic_type = attrs.get(portbindings.VNIC_TYPE) if attrs else None
396 396
         if (validators.is_attr_set(vnic_type) and
397 397
             binding.vnic_type != vnic_type):
398 398
             binding.vnic_type = vnic_type

+ 8
- 0
neutron/tests/unit/plugins/ml2/test_plugin.py View File

@@ -941,6 +941,14 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
941 941
                 plugin.update_port_status(ctx, short_id, 'UP')
942 942
                 mock_gbl.assert_called_once_with(mock.ANY, port_id, mock.ANY)
943 943
 
944
+    def test_update_port_with_empty_data(self):
945
+        ctx = context.get_admin_context()
946
+        plugin = directory.get_plugin()
947
+        with self.port() as port:
948
+            port_id = port['port']['id']
949
+            new_port = plugin.update_port(ctx, port_id, {"port": {}})
950
+            self.assertEqual(port["port"], new_port)
951
+
944 952
     def _add_fake_dhcp_agent(self):
945 953
         agent = mock.Mock()
946 954
         plugin = directory.get_plugin()

Loading…
Cancel
Save