Merge "Handle all portbinding attrs in case of bulk port creation"

changes/76/787876/7
Zuul 1 year ago committed by Gerrit Code Review
commit a2ffbfa552
  1. 4
      neutron/plugins/ml2/plugin.py
  2. 20
      neutron/tests/unit/plugins/ml2/test_plugin.py

@ -1592,6 +1592,10 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
process_extensions=False)
port_dict[portbindings.HOST_ID] = pdata.get(
portbindings.HOST_ID)
port_dict[portbindings.VNIC_TYPE] = pdata.get(
portbindings.VNIC_TYPE)
port_dict[portbindings.PROFILE] = pdata.get(
portbindings.PROFILE)
# Activities immediately post-port-creation
self.extension_manager.process_create_port(context, pdata,

@ -1388,6 +1388,26 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
else:
self.assertTrue('ports' in ports)
def test_create_ports_bulk_with_portbinding_attrs(self):
ctx = context.get_admin_context()
with self.network() as net:
overrides = {0: {portbindings.HOST_ID: 'host1',
portbindings.VNIC_TYPE: 'direct',
portbindings.PROFILE: {'foo': 'foo'}},
1: {portbindings.HOST_ID: 'host2',
portbindings.VNIC_TYPE: 'macvtap',
portbindings.PROFILE: {'bar': 'bar'}}}
res = self._create_port_bulk(self.fmt, 2, net['network']['id'],
'test', True, context=ctx,
override=overrides)
ports = self.deserialize(self.fmt, res)['ports']
self.assertCountEqual(['direct', 'macvtap'],
[p[portbindings.VNIC_TYPE] for p in ports])
self.assertCountEqual([{'foo': 'foo'}, {'bar': 'bar'}],
[p[portbindings.PROFILE] for p in ports])
self.assertCountEqual(['host1', 'host2'],
[p[portbindings.HOST_ID] for p in ports])
def test_create_ports_bulk_with_sec_grp_member_provider_update(self):
ctx = context.get_admin_context()
plugin = directory.get_plugin()

Loading…
Cancel
Save