Merge "fix update port bug" into stable/queens

This commit is contained in:
Zuul 2019-08-13 14:26:07 +00:00 committed by Gerrit Code Review
commit 16ea413805
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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()