From 561e2651d42be7c3f87b5373cc3d8b36ef97be36 Mon Sep 17 00:00:00 2001 From: Aaron Rosen Date: Mon, 8 Sep 2014 11:23:50 -0700 Subject: [PATCH] NSX: Correct allowed_address_pair return value on create_port This patch fixes the NSX plugin to return [] rather than None for a port does not have any allowed_address_pairs when a create_port api call is made. Currently the NSX plugin is failing every patch because now tempest is checking for this value to be []. Change-Id: Ic82c564ff62000c367c544f44a76694be9375790 Closes-bug: 1366921 --- neutron/plugins/vmware/plugins/base.py | 2 +- .../tests/unit/vmware/extensions/test_addresspairs.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/neutron/plugins/vmware/plugins/base.py b/neutron/plugins/vmware/plugins/base.py index e9bc8a6453..cb4c5456e7 100644 --- a/neutron/plugins/vmware/plugins/base.py +++ b/neutron/plugins/vmware/plugins/base.py @@ -1105,7 +1105,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, port_data[addr_pair.ADDRESS_PAIRS]) else: # remove ATTR_NOT_SPECIFIED - port_data[addr_pair.ADDRESS_PAIRS] = None + port_data[addr_pair.ADDRESS_PAIRS] = [] # security group extension checks if port_security and has_ip: diff --git a/neutron/tests/unit/vmware/extensions/test_addresspairs.py b/neutron/tests/unit/vmware/extensions/test_addresspairs.py index be30b5bc48..11d84fea75 100644 --- a/neutron/tests/unit/vmware/extensions/test_addresspairs.py +++ b/neutron/tests/unit/vmware/extensions/test_addresspairs.py @@ -13,10 +13,19 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron.extensions import allowedaddresspairs as addr_pair from neutron.tests.unit import test_extension_allowedaddresspairs as ext_pairs from neutron.tests.unit.vmware import test_nsx_plugin class TestAllowedAddressPairs(test_nsx_plugin.NsxPluginV2TestCase, ext_pairs.TestAllowedAddressPairs): - pass + + # TODO(arosen): move to ext_pairs.TestAllowedAddressPairs once all + # plugins do this correctly. + def test_create_port_no_allowed_address_pairs(self): + with self.network() as net: + res = self._create_port(self.fmt, net['network']['id']) + port = self.deserialize(self.fmt, res) + self.assertEqual(port['port'][addr_pair.ADDRESS_PAIRS], []) + self._delete('ports', port['port']['id'])