diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 94af52f17df..aa92d91e50e 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -392,7 +392,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, binding.host = host changes = True - vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE) + vnic_type = attrs.get(portbindings.VNIC_TYPE) if attrs else None if (validators.is_attr_set(vnic_type) and binding.vnic_type != vnic_type): binding.vnic_type = vnic_type diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index 49778d0832a..2c480bb7e94 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -941,6 +941,14 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase): plugin.update_port_status(ctx, short_id, 'UP') mock_gbl.assert_called_once_with(mock.ANY, port_id, mock.ANY) + def test_update_port_with_empty_data(self): + ctx = context.get_admin_context() + plugin = directory.get_plugin() + with self.port() as port: + port_id = port['port']['id'] + new_port = plugin.update_port(ctx, port_id, {"port": {}}) + self.assertEqual(port["port"], new_port) + def _add_fake_dhcp_agent(self): agent = mock.Mock() plugin = directory.get_plugin()