Handle all portbinding attrs in case of bulk port creation
Bulk port creation should honor binding:vnic_type and binding:profile attributes from request. Closes-Bug: #1940074 Change-Id: I99d27d568f66c6330f6373843d096c6ee1b4ec54 (cherry picked from commit3640ffa0c6
) (cherry picked from commit85126425c5
)
This commit is contained in:
parent
c968f40967
commit
ae2d009866
@ -1566,6 +1566,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,
|
||||
|
@ -1360,6 +1360,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…
Reference in New Issue
Block a user