From 59d4c264bdcf056eb44d9d137336fde7c00f3a1b Mon Sep 17 00:00:00 2001 From: Salvatore Date: Tue, 16 Sep 2014 17:28:55 +0200 Subject: [PATCH] NSX plugin: set VNIC_TYPE port binding attribute A recent change has made this attribute required for nova integration. This patch adds this attribute to responses generated by the NSX plugin, and also ensures relevant unit tests are executed for the vmware NSX plugin. Change-Id: Ieebab01b406909f66a40cc683763292a9ef6f218 Closes-Bug: #1370112 --- neutron/plugins/vmware/plugins/base.py | 10 ++++++++++ neutron/tests/unit/vmware/test_nsx_plugin.py | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/neutron/plugins/vmware/plugins/base.py b/neutron/plugins/vmware/plugins/base.py index cb4c5456e..6dbf8ae35 100644 --- a/neutron/plugins/vmware/plugins/base.py +++ b/neutron/plugins/vmware/plugins/base.py @@ -831,6 +831,10 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, pnet.SEGMENTATION_ID: binding.vlan_id} for binding in bindings] + def extend_port_dict_binding(self, port_res, port_db): + super(NsxPluginV2, self).extend_port_dict_binding(port_res, port_db) + port_res[pbin.VNIC_TYPE] = pbin.VNIC_NORMAL + def _handle_lswitch_selection(self, context, cluster, network, network_bindings, max_ports, allow_extra_lswitches): @@ -1128,6 +1132,12 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, self._process_portbindings_create_and_update(context, port['port'], port_data) + # For some reason the port bindings DB mixin does not handle + # the VNIC_TYPE attribute, which is required by nova for + # setting up VIFs. + context.session.flush() + port_data[pbin.VNIC_TYPE] = pbin.VNIC_NORMAL + # DB Operation is complete, perform NSX operation try: port_data = port['port'].copy() diff --git a/neutron/tests/unit/vmware/test_nsx_plugin.py b/neutron/tests/unit/vmware/test_nsx_plugin.py index 650f7e114..192ea5784 100644 --- a/neutron/tests/unit/vmware/test_nsx_plugin.py +++ b/neutron/tests/unit/vmware/test_nsx_plugin.py @@ -124,7 +124,8 @@ class TestV2HTTPResponse(test_plugin.TestV2HTTPResponse, NsxPluginV2TestCase): class TestPortsV2(NsxPluginV2TestCase, test_plugin.TestPortsV2, test_bindings.PortBindingsTestCase, - test_bindings.PortBindingsHostTestCaseMixin): + test_bindings.PortBindingsHostTestCaseMixin, + test_bindings.PortBindingsVnicTestCaseMixin): VIF_TYPE = portbindings.VIF_TYPE_OVS HAS_PORT_FILTER = True