fix update port bug
when update port set body={"port": {}}, neutron server will return 500. In function _process_port_binding_attributes(plugins/ml2/plugin.py), when update port body={"port": {}} attrs={} vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE) vnic_type = {} because attrs as False, will not execute attrs.get(portbindings.VNIC_TYPE) vnic_type will be replicated as attrs. Change-Id: I40d388543387ebdd72f26d761339c1829bef9413 Partial-bug: #1838396
This commit is contained in:
parent
6b420aa938
commit
dd080c70b4
|
@ -442,7 +442,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
|
||||
|
|
|
@ -1103,6 +1103,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()
|
||||
|
|
Loading…
Reference in New Issue