]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
NSX plugin: set VNIC_TYPE port binding attribute
authorSalvatore <salv.orlando@gmail.com>
Tue, 16 Sep 2014 15:28:55 +0000 (17:28 +0200)
committerSalvatore <salv.orlando@gmail.com>
Tue, 16 Sep 2014 15:28:55 +0000 (17:28 +0200)
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
neutron/tests/unit/vmware/test_nsx_plugin.py

index cb4c5456e717af26cf6c89f38cea44af6895b3e5..6dbf8ae3568556d01a48040d3c4017c3f853a37c 100644 (file)
@@ -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()
index 650f7e114a52d97193ac258d59ad8d3c9e6f4fbf..192ea5784a3b97ea138076342c5e205c1a60a78b 100644 (file)
@@ -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