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
This commit is contained in:
Salvatore 2014-09-16 17:28:55 +02:00
parent 5555829060
commit 27af7b6948
2 changed files with 12 additions and 1 deletions

View 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()

View 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