Browse Source

Merge "fix update port bug" into stable/rocky

changes/22/676922/1
Zuul 1 month ago
parent
commit
1d053a63ba
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

@@ -413,7 +413,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
413 413
             binding.host = host
414 414
             changes = True
415 415
 
416
-        vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE)
416
+        vnic_type = attrs.get(portbindings.VNIC_TYPE) if attrs else None
417 417
         if (validators.is_attr_set(vnic_type) and
418 418
                 binding.vnic_type != vnic_type):
419 419
             binding.vnic_type = vnic_type

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

@@ -965,6 +965,14 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
965 965
                 plugin.update_port_status(ctx, short_id, 'UP')
966 966
                 mock_gbl.assert_called_once_with(mock.ANY, port_id, mock.ANY)
967 967
 
968
+    def test_update_port_with_empty_data(self):
969
+        ctx = context.get_admin_context()
970
+        plugin = directory.get_plugin()
971
+        with self.port() as port:
972
+            port_id = port['port']['id']
973
+            new_port = plugin.update_port(ctx, port_id, {"port": {}})
974
+            self.assertEqual(port["port"], new_port)
975
+
968 976
     def _add_fake_dhcp_agent(self):
969 977
         agent = mock.Mock()
970 978
         plugin = directory.get_plugin()

Loading…
Cancel
Save