from neutron.db import external_net_db
from neutron.db import l3_db
from neutron.db import l3_rpc_base
+from neutron.db import portbindings_db
+from neutron.extensions import portbindings
from neutron.extensions import providernet
from neutron.openstack.common import log as logging
from neutron.openstack.common import rpc
class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
external_net_db.External_net_db_mixin,
l3_db.L3_NAT_db_mixin,
+ portbindings_db.PortBindingMixin,
n1kv_db_v2.NetworkProfile_db_mixin,
n1kv_db_v2.PolicyProfile_db_mixin,
network_db_v2.Credential_db_mixin,
supported_extension_aliases = ["provider", "agent",
"n1kv", "network_profile",
"policy_profile", "external-net", "router",
- "credential"]
+ "binding", "credential"]
def __init__(self, configfile=None):
"""
Initialize Nexus1000V Neutron plugin.
- 1. Initialize Nexus1000v and Credential DB
- 2. Establish communication with Cisco Nexus1000V
+ 1. Initialize VIF type to OVS
+ 2. Initialize Nexus1000v and Credential DB
+ 3. Establish communication with Cisco Nexus1000V
"""
super(N1kvNeutronPluginV2, self).__init__()
+ self.base_binding_dict = {
+ portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS,
+ portbindings.VIF_DETAILS: {
+ # TODO(rkukura): Replace with new VIF security details
+ portbindings.CAP_PORT_FILTER:
+ 'security-group' in self.supported_extension_aliases}}
c_cred.Store.initialize()
self._initialize_network_ranges()
self._setup_vsm()
port)
n1kv_db_v2.add_port_binding(session, pt['id'], profile_id)
self._extend_port_dict_profile(context, pt)
+ self._process_portbindings_create_and_update(context,
+ port['port'],
+ pt)
try:
self._send_create_port_request(context, pt)
except(cisco_exceptions.VSMError,
:returns: updated port object
"""
LOG.debug(_("Update port: %s"), id)
- if self.agent_vsm:
- super(N1kvNeutronPluginV2, self).get_port(context, id)
- port = super(N1kvNeutronPluginV2, self).update_port(context, id, port)
- self._extend_port_dict_profile(context, port)
- return port
+ with context.session.begin(subtransactions=True):
+ updated_port = super(N1kvNeutronPluginV2,
+ self).update_port(context, id, port)
+ self._process_portbindings_create_and_update(context,
+ port['port'],
+ updated_port)
+ self._extend_port_dict_profile(context, updated_port)
+ return updated_port
def delete_port(self, context, id, l3_port_check=True):
"""
:param context: neutron api request context
:param id: UUID representing the port to delete
- :returns: deleted port object
"""
# if needed, check to see if this is a port owned by
# and l3-router. If so, we should prevent deletion.
if l3_port_check:
self.prevent_l3_port_deletion(context, id)
- self.disassociate_floatingips(context, id)
- self._send_delete_port_request(context, id)
- return super(N1kvNeutronPluginV2, self).delete_port(context, id)
+ with context.session.begin(subtransactions=True):
+ self.disassociate_floatingips(context, id)
+ self._send_delete_port_request(context, id)
+ super(N1kvNeutronPluginV2, self).delete_port(context, id)
def get_port(self, context, id, fields=None):
"""
from neutron.api.v2 import attributes
from neutron import context
import neutron.db.api as db
+from neutron.extensions import portbindings
from neutron.plugins.cisco.db import n1kv_db_v2
from neutron.plugins.cisco.db import network_db_v2 as cdb
from neutron.plugins.cisco import extensions
from neutron.plugins.cisco.extensions import network_profile
from neutron.plugins.cisco.n1kv import n1kv_client
from neutron.plugins.cisco.n1kv import n1kv_neutron_plugin
+from neutron.tests.unit import _test_extension_portbindings as test_bindings
from neutron.tests.unit import test_api_v2
from neutron.tests.unit import test_db_plugin as test_plugin
class TestN1kvPorts(test_plugin.TestPortsV2,
- N1kvPluginTestCase):
+ N1kvPluginTestCase,
+ test_bindings.PortBindingsTestCase):
+ VIF_TYPE = portbindings.VIF_TYPE_OVS
+ HAS_PORT_FILTER = False
def test_create_port_with_default_n1kv_policy_profile_id(self):
"""Test port create without passing policy profile id."""