diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 5c5742459c0..9a422b14e9f 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/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, diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index f6112fc24e4..f0ba81de963 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -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()