Skip to content

Commit

Permalink
Merge "Handle all portbinding attrs in case of bulk port creation"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Aug 31, 2021
2 parents 7012144 + 3640ffa commit a2ffbfa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions neutron/plugins/ml2/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,10 @@ def create_port_bulk(self, context, ports):
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,
Expand Down
20 changes: 20 additions & 0 deletions neutron/tests/unit/plugins/ml2/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,26 @@ def test_create_ports_bulk_with_sec_grp(self):
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()
Expand Down

0 comments on commit a2ffbfa

Please sign in to comment.