Add support to the port binding extension for the NVP plugin.
Also, this patch removes the non-serializable object for port profile. This went undetected for quite some time. Implements blueprint nvp-port-binding-extension Change-Id: I380570f08e92f75d6431dcda6fac2a770887bb48
This commit is contained in:
parent
709a509aa0
commit
c0f80bf720
@ -32,6 +32,7 @@ down_revision = 'grizzly'
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
|
@ -70,6 +70,10 @@ class PortBindingMixin(object):
|
||||
|
||||
def _process_portbindings_create_and_update(self, context, port_data,
|
||||
port):
|
||||
binding_profile = port.get(portbindings.PROFILE)
|
||||
binding_profile_set = attributes.is_attr_set(binding_profile)
|
||||
if not binding_profile_set and binding_profile is not None:
|
||||
del port[portbindings.PROFILE]
|
||||
host = port_data.get(portbindings.HOST_ID)
|
||||
host_set = attributes.is_attr_set(host)
|
||||
if not host_set:
|
||||
|
@ -46,11 +46,13 @@ from neutron.db import extraroute_db
|
||||
from neutron.db import l3_db
|
||||
from neutron.db import l3_gwmode_db
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import portbindings_db
|
||||
from neutron.db import portsecurity_db
|
||||
from neutron.db import quota_db # noqa
|
||||
from neutron.db import securitygroups_db
|
||||
from neutron.extensions import extraroute
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings as pbin
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
@ -130,6 +132,7 @@ class NVPRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
class NvpPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
extraroute_db.ExtraRoute_db_mixin,
|
||||
l3_gwmode_db.L3_NAT_db_mixin,
|
||||
portbindings_db.PortBindingMixin,
|
||||
portsecurity_db.PortSecurityDbMixin,
|
||||
securitygroups_db.SecurityGroupDbMixin,
|
||||
mac_db.MacLearningDbMixin,
|
||||
@ -145,6 +148,7 @@ class NvpPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
"""
|
||||
|
||||
supported_extension_aliases = ["agent",
|
||||
"binding",
|
||||
"dhcp_agent_scheduler",
|
||||
"ext_gw_mode",
|
||||
"extraroute",
|
||||
@ -196,6 +200,12 @@ class NvpPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self.nvp_opts.concurrent_connections,
|
||||
self.nvp_opts.nvp_gen_timeout)
|
||||
|
||||
self.extra_binding_dict = {
|
||||
pbin.VIF_TYPE: pbin.VIF_TYPE_OVS,
|
||||
pbin.CAPABILITIES: {
|
||||
pbin.CAP_PORT_FILTER:
|
||||
'security-group' in self.supported_extension_aliases}}
|
||||
|
||||
db.configure_db()
|
||||
# Extend the fault map
|
||||
self._extend_fault_map()
|
||||
@ -1079,8 +1089,7 @@ class NvpPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
return net
|
||||
|
||||
def get_ports(self, context, filters=None, fields=None):
|
||||
if filters is None:
|
||||
filters = {}
|
||||
filters = filters or {}
|
||||
with context.session.begin(subtransactions=True):
|
||||
neutron_lports = super(NvpPluginV2, self).get_ports(
|
||||
context, filters)
|
||||
@ -1256,6 +1265,8 @@ class NvpPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
del port_data[ext_qos.QUEUE]
|
||||
self._extend_port_port_security_dict(context, port_data)
|
||||
self._extend_port_qos_queue(context, port_data)
|
||||
self._process_portbindings_create_and_update(context,
|
||||
port, port_data)
|
||||
net = self.get_network(context, port_data['network_id'])
|
||||
self.schedule_network(context, net)
|
||||
if notify_dhcp_agent:
|
||||
@ -1360,6 +1371,9 @@ class NvpPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
# remove since it will be added in extend based on policy
|
||||
del ret_port[ext_qos.QUEUE]
|
||||
self._extend_port_qos_queue(context, ret_port)
|
||||
self._process_portbindings_create_and_update(context,
|
||||
port['port'],
|
||||
port)
|
||||
return ret_port
|
||||
|
||||
def delete_port(self, context, id, l3_port_check=True,
|
||||
|
@ -25,6 +25,7 @@ from neutron.common import constants
|
||||
import neutron.common.test_lib as test_lib
|
||||
from neutron import context
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import securitygroup as secgrp
|
||||
from neutron import manager
|
||||
@ -36,6 +37,7 @@ from neutron.plugins.nicira import NeutronPlugin
|
||||
from neutron.plugins.nicira import NvpApiClient
|
||||
from neutron.plugins.nicira.NvpApiClient import NVPVersion
|
||||
from neutron.plugins.nicira import nvplib
|
||||
from neutron.tests.unit import _test_extension_portbindings as test_bindings
|
||||
from neutron.tests.unit.nicira import fake_nvpapiclient
|
||||
import neutron.tests.unit.nicira.test_networkgw as test_l2_gw
|
||||
import neutron.tests.unit.test_db_plugin as test_plugin
|
||||
@ -105,7 +107,12 @@ class TestNiciraV2HTTPResponse(test_plugin.TestV2HTTPResponse,
|
||||
pass
|
||||
|
||||
|
||||
class TestNiciraPortsV2(test_plugin.TestPortsV2, NiciraPluginV2TestCase):
|
||||
class TestNiciraPortsV2(test_plugin.TestPortsV2,
|
||||
NiciraPluginV2TestCase,
|
||||
test_bindings.PortBindingsTestCase):
|
||||
|
||||
VIF_TYPE = portbindings.VIF_TYPE_OVS
|
||||
HAS_PORT_FILTER = True
|
||||
|
||||
def test_exhaust_ports_overlay_network(self):
|
||||
cfg.CONF.set_override('max_lp_per_overlay_ls', 1, group='NVP')
|
||||
|
Loading…
Reference in New Issue
Block a user