summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBence Romsics <bence.romsics@gmail.com>2023-01-20 16:26:21 +0100
committerelajkat <lajos.katona@est.tech>2023-03-14 10:40:25 +0100
commit2c7391c82315f73ca1a3a03d4ec4142a42f61fd9 (patch)
treeabc1f5ce368b01f0d9b41ee5d44e3c51899728dd
parenta5324c83c7e3548b84b2332fc5ceb0fa496e4aca (diff)
downloadneutron-2c7391c82315f73ca1a3a03d4ec4142a42f61fd9.tar.gz
Do not ignore attributes in bulk port create
With unit tests that would have caught the bug. Conflicts: neutron/tests/unit/plugins/ml2/test_plugin.py Change-Id: Ia4a68bdccecfbcb9d1aa49e2b14e06d139891c0f Closes-Bug: #2003553 (cherry-picked from commit fb49c57e5d2c3c4fa6843c97f87772f70ff67927) (cherry picked from commit ed68ba4a4cb622a67a4b28065da7f1ef7777e0dd) (cherry picked from commit 1b086f1c1fd0879224e61b05e3d4bb54486ea62c)
-rw-r--r--neutron/plugins/ml2/plugin.py6
-rw-r--r--neutron/tests/unit/plugins/ml2/test_plugin.py49
2 files changed, 52 insertions, 3 deletions
diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py
index 1c8e794311..19d7043c25 100644
--- a/neutron/plugins/ml2/plugin.py
+++ b/neutron/plugins/ml2/plugin.py
@@ -1593,13 +1593,13 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self._process_port_binding(mech_context, port_dict)
# process allowed address pairs
- db_port_obj[addr_apidef.ADDRESS_PAIRS] = (
+ port_dict[addr_apidef.ADDRESS_PAIRS] = (
self._process_create_allowed_address_pairs(
context, port_dict,
- port_dict.get(addr_apidef.ADDRESS_PAIRS)))
+ pdata.get(addr_apidef.ADDRESS_PAIRS)))
# handle DHCP setup
- dhcp_opts = port_dict.get(edo_ext.EXTRADHCPOPTS, [])
+ dhcp_opts = pdata.get(edo_ext.EXTRADHCPOPTS, [])
self._process_port_create_extra_dhcp_opts(context, port_dict,
dhcp_opts)
# send PRECOMMIT_CREATE notification
diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py
index 46a93d793a..031a2ccb3a 100644
--- a/neutron/tests/unit/plugins/ml2/test_plugin.py
+++ b/neutron/tests/unit/plugins/ml2/test_plugin.py
@@ -1457,6 +1457,55 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
self.assertEqual(2, deallocate_mock.call_count)
+ def test_create_ports_bulk_with_allowed_address_pairs(self):
+ ctx = context.get_admin_context()
+ with self.network() as net:
+
+ aap = [{
+ 'ip_address': '1.2.3.4',
+ 'mac_address': '01:23:45:67:89:ab',
+ }]
+ ports_in = {
+ 'ports': [{'port': {
+ 'allowed_address_pairs': aap,
+ 'network_id': net['network']['id'],
+ 'tenant_id': self._tenant_id,
+
+ 'admin_state_up': True,
+ 'device_id': '',
+ 'device_owner': '',
+ 'fixed_ips': constants.ATTR_NOT_SPECIFIED,
+ 'name': '',
+ 'security_groups': constants.ATTR_NOT_SPECIFIED,
+ }}]}
+ ports_out = self.plugin.create_port_bulk(ctx, ports_in)
+ self.assertEqual(aap, ports_out[0]['allowed_address_pairs'])
+
+ def test_create_ports_bulk_with_extra_dhcp_opts(self):
+ ctx = context.get_admin_context()
+ with self.network() as net:
+
+ edo = [{
+ 'opt_name': 'domain-name-servers',
+ 'opt_value': '10.0.0.1',
+ 'ip_version': 4,
+ }]
+ ports_in = {
+ 'ports': [{'port': {
+ 'extra_dhcp_opts': edo,
+ 'network_id': net['network']['id'],
+ 'tenant_id': self._tenant_id,
+
+ 'admin_state_up': True,
+ 'device_id': '',
+ 'device_owner': '',
+ 'fixed_ips': constants.ATTR_NOT_SPECIFIED,
+ 'name': '',
+ 'security_groups': constants.ATTR_NOT_SPECIFIED,
+ }}]}
+ ports_out = self.plugin.create_port_bulk(ctx, ports_in)
+ self.assertEqual(edo, ports_out[0]['extra_dhcp_opts'])
+
def test_delete_port_no_notify_in_disassociate_floatingips(self):
ctx = context.get_admin_context()
plugin = directory.get_plugin()