Merge "Decomposition phase2 of NEC plugin"

This commit is contained in:
Jenkins 2015-08-25 10:49:15 +00:00 committed by Gerrit Code Review
commit a324b22821
16 changed files with 14 additions and 619 deletions

View File

@ -1,63 +0,0 @@
# Sample Configurations
[ovs]
# Do not change this parameter unless you have a good reason to.
# This is the name of the OVS integration bridge. There is one per hypervisor.
# The integration bridge acts as a virtual "patch port". All VM VIFs are
# attached to this bridge and then "patched" according to their network
# connectivity.
# integration_bridge = br-int
[agent]
# Agent's polling interval in seconds
# polling_interval = 2
[securitygroup]
# Firewall driver for realizing neutron security group function
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
# Controls if neutron security group is enabled or not.
# It should be false when you use nova security group.
# enable_security_group = True
[ofc]
# Specify OpenFlow Controller Host, Port and Driver to connect.
# host = 127.0.0.1
# port = 8888
# Base URL of OpenFlow Controller REST API.
# It is prepended to a path of each API request.
# path_prefix =
# Drivers are in neutron/plugins/nec/drivers/ .
# driver = trema
# PacketFilter is available when it's enabled in this configuration
# and supported by the driver.
# enable_packet_filter = true
# Support PacketFilter on OFC router interface
# support_packet_filter_on_ofc_router = true
# Use SSL to connect
# use_ssl = false
# Key file
# key_file =
# Certificate file
# cert_file =
# Disable SSL certificate verification
# insecure_ssl = false
# Maximum attempts per OFC API request. NEC plugin retries
# API request to OFC when OFC returns ServiceUnavailable (503).
# The value must be greater than 0.
# api_max_attempts = 3
[provider]
# Default router provider to use.
# default_router_provider = l3-agent
# List of enabled router providers.
# router_providers = l3-agent,openflow

View File

@ -1,12 +0,0 @@
# neutron-rootwrap command filters for nodes on which neutron is
# expected to control network
#
# This file should be owned by (and only-writeable by) the root user
# format seems to be
# cmd-name: filter-name, raw-command, user, args
[Filters]
# nec_neutron_agent
ovs-vsctl: CommandFilter, ovs-vsctl, root

View File

@ -1,28 +0,0 @@
# Copyright 2012 NEC Corporation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sys
from networking_nec.plugins.openflow.agent import l2_agent
from neutron.common import config as common_config
from neutron.plugins.nec import config as nec_config
def main():
nec_config.register_agent_opts()
common_config.init(sys.argv[1:])
common_config.setup_logging()
l2_agent.run()

View File

@ -85,7 +85,20 @@ REPO_VMWARE_TABLES = [
'vcns_router_bindings',
]
# NEC models moved to stackforge/networking-nec
REPO_NEC_TABLES = [
'ofcnetworkmappings',
'ofcportmappings',
'ofcroutermappings',
'ofcfiltermappings',
'ofctenantmappings',
'portinfos',
'routerproviders',
'packetfilters',
]
TABLES = (FWAAS_TABLES + LBAAS_TABLES + VPNAAS_TABLES +
REPO_ARISTA_TABLES +
REPO_CISCO_TABLES +
REPO_VMWARE_TABLES)
REPO_VMWARE_TABLES +
REPO_NEC_TABLES)

View File

@ -60,7 +60,6 @@ from neutron.plugins.ml2.drivers import type_gre # noqa
from neutron.plugins.ml2.drivers import type_vlan # noqa
from neutron.plugins.ml2.drivers import type_vxlan # noqa
from neutron.plugins.ml2 import models # noqa
from neutron.plugins.nec.db import models as nec_models # noqa
from neutron.plugins.nuage import nuage_models # noqa

View File

@ -1,11 +0,0 @@
Neutron NEC OpenFlow Plugin
===========================
Neutron plugins for NEC OpenFlow networking products and
Trema Sliceable Switch (reference implementation).
* Main Page: https://wiki.openstack.org/wiki/Neutron/NEC_OpenFlow_Plugin
* Repository:
* http://git.openstack.org/cgit/stackforge/networking-nec/
* https://github.com/stackforge/networking-nec

View File

@ -1,78 +0,0 @@
# Copyright 2012 NEC Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from neutron.agent.common import config
ovs_opts = [
cfg.StrOpt('integration_bridge', default='br-int',
help=_("Integration bridge to use.")),
]
agent_opts = [
cfg.IntOpt('polling_interval', default=2,
help=_("The number of seconds the agent will wait between "
"polling for local device changes.")),
]
ofc_opts = [
cfg.StrOpt('host', default='127.0.0.1',
help=_("Host to connect to.")),
cfg.StrOpt('path_prefix', default='',
help=_("Base URL of OFC REST API. "
"It is prepended to each API request.")),
cfg.StrOpt('port', default='8888',
help=_("Port to connect to.")),
cfg.StrOpt('driver', default='trema',
help=_("Driver to use.")),
cfg.BoolOpt('enable_packet_filter', default=True,
help=_("Enable packet filter.")),
cfg.BoolOpt('support_packet_filter_on_ofc_router', default=True,
help=_("Support packet filter on OFC router interface.")),
cfg.BoolOpt('use_ssl', default=False,
help=_("Use SSL to connect.")),
cfg.StrOpt('key_file',
help=_("Location of key file.")),
cfg.StrOpt('cert_file',
help=_("Location of certificate file.")),
cfg.BoolOpt('insecure_ssl', default=False,
help=_("Disable SSL certificate verification.")),
cfg.IntOpt('api_max_attempts', default=3,
help=_("Maximum attempts per OFC API request. "
"NEC plugin retries API request to OFC "
"when OFC returns ServiceUnavailable (503). "
"The value must be greater than 0.")),
]
provider_opts = [
cfg.StrOpt('default_router_provider',
default='l3-agent',
help=_('Default router provider to use.')),
cfg.ListOpt('router_providers',
default=['l3-agent', 'openflow'],
help=_('List of enabled router providers.'))
]
def register_plugin_opts():
cfg.CONF.register_opts(ofc_opts, "OFC")
cfg.CONF.register_opts(provider_opts, "PROVIDER")
def register_agent_opts():
cfg.CONF.register_opts(agent_opts, "AGENT")
cfg.CONF.register_opts(ovs_opts, "OVS")
config.register_agent_state_opts_helper(cfg.CONF)

View File

@ -1,117 +0,0 @@
# Copyright 2012 NEC Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sqlalchemy as sa
from sqlalchemy import orm
from neutron.db import l3_db
from neutron.db import model_base
from neutron.db import models_v2
# New mapping tables.
class OFCId(object):
"""Resource ID on OpenFlow Controller."""
ofc_id = sa.Column(sa.String(255), unique=True, nullable=False)
class NeutronId(object):
"""Logical ID on Neutron."""
neutron_id = sa.Column(sa.String(36), primary_key=True)
class OFCTenantMapping(model_base.BASEV2, NeutronId, OFCId):
"""Represents a Tenant on OpenFlow Network/Controller."""
class OFCNetworkMapping(model_base.BASEV2, NeutronId, OFCId):
"""Represents a Network on OpenFlow Network/Controller."""
class OFCPortMapping(model_base.BASEV2, NeutronId, OFCId):
"""Represents a Port on OpenFlow Network/Controller."""
class OFCRouterMapping(model_base.BASEV2, NeutronId, OFCId):
"""Represents a router on OpenFlow Network/Controller."""
class OFCFilterMapping(model_base.BASEV2, NeutronId, OFCId):
"""Represents a Filter on OpenFlow Network/Controller."""
class PortInfo(model_base.BASEV2):
"""Represents a Virtual Interface."""
id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
primary_key=True)
datapath_id = sa.Column(sa.String(36), nullable=False)
port_no = sa.Column(sa.Integer, nullable=False)
vlan_id = sa.Column(sa.Integer, nullable=False)
mac = sa.Column(sa.String(32), nullable=False)
port = orm.relationship(
models_v2.Port,
backref=orm.backref("portinfo",
lazy='joined', uselist=False,
cascade='delete'))
class RouterProvider(models_v2.model_base.BASEV2):
"""Represents a binding of router_id to provider."""
provider = sa.Column(sa.String(255))
router_id = sa.Column(sa.String(36),
sa.ForeignKey('routers.id', ondelete="CASCADE"),
primary_key=True)
router = orm.relationship(l3_db.Router, uselist=False,
backref=orm.backref('provider', uselist=False,
lazy='joined',
cascade='delete'))
class PacketFilter(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
"""Represents a packet filter."""
name = sa.Column(sa.String(255))
network_id = sa.Column(sa.String(36),
sa.ForeignKey('networks.id', ondelete="CASCADE"),
nullable=False)
priority = sa.Column(sa.Integer, nullable=False)
action = sa.Column(sa.String(16), nullable=False)
# condition
in_port = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
nullable=True)
src_mac = sa.Column(sa.String(32), nullable=False)
dst_mac = sa.Column(sa.String(32), nullable=False)
eth_type = sa.Column(sa.Integer, nullable=False)
src_cidr = sa.Column(sa.String(64), nullable=False)
dst_cidr = sa.Column(sa.String(64), nullable=False)
protocol = sa.Column(sa.String(16), nullable=False)
src_port = sa.Column(sa.Integer, nullable=False)
dst_port = sa.Column(sa.Integer, nullable=False)
# status
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
status = sa.Column(sa.String(16), nullable=False)
network = orm.relationship(
models_v2.Network,
backref=orm.backref('packetfilters', lazy='joined', cascade='delete'),
uselist=False)
in_port_ref = orm.relationship(
models_v2.Port,
backref=orm.backref('packetfilters', lazy='joined', cascade='delete'),
primaryjoin="Port.id==PacketFilter.in_port",
uselist=False)

View File

@ -1,200 +0,0 @@
# Copyright 2012-2013 NEC Corporation.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron.api.v2 import base
from neutron.common import constants
from neutron.common import exceptions
from neutron import manager
from neutron.quota import resource as quota_resource
from neutron.quota import resource_registry
quota_packet_filter_opts = [
cfg.IntOpt('quota_packet_filter',
default=100,
help=_("Number of packet_filters allowed per tenant, "
"-1 for unlimited"))
]
cfg.CONF.register_opts(quota_packet_filter_opts, 'QUOTAS')
class PacketFilterNotFound(exceptions.NotFound):
message = _("PacketFilter %(id)s could not be found")
class PacketFilterIpVersionNonSupported(exceptions.BadRequest):
message = _("IP version %(version)s is not supported for %(field)s "
"(%(value)s is specified)")
class PacketFilterInvalidPriority(exceptions.BadRequest):
message = _("Packet Filter priority should be %(min)s-%(max)s (included)")
class PacketFilterUpdateNotSupported(exceptions.BadRequest):
message = _("%(field)s field cannot be updated")
class PacketFilterDuplicatedPriority(exceptions.BadRequest):
message = _("The backend does not support duplicated priority. "
"Priority %(priority)s is in use")
class PacketFilterEtherTypeProtocolMismatch(exceptions.Conflict):
message = _("Ether Type '%(eth_type)s' conflicts with protocol "
"'%(protocol)s'. Update or clear protocol before "
"changing ether type.")
def convert_to_int_dec_and_hex(data):
try:
return int(data, 0)
except (ValueError, TypeError):
pass
try:
return int(data)
except (ValueError, TypeError):
msg = _("'%s' is not a integer") % data
raise exceptions.InvalidInput(error_message=msg)
def convert_to_int_or_none(data):
if data is None:
return
return convert_to_int_dec_and_hex(data)
PROTO_NAME_ARP = 'arp'
SUPPORTED_PROTOCOLS = [constants.PROTO_NAME_ICMP,
constants.PROTO_NAME_TCP,
constants.PROTO_NAME_UDP,
PROTO_NAME_ARP]
ALLOW_ACTIONS = ['allow', 'accept']
DROP_ACTIONS = ['drop', 'deny']
SUPPORTED_ACTIONS = ALLOW_ACTIONS + DROP_ACTIONS
ALIAS = 'packet-filter'
RESOURCE = 'packet_filter'
COLLECTION = 'packet_filters'
PACKET_FILTER_ACTION_REGEX = '(?i)^(%s)$' % '|'.join(SUPPORTED_ACTIONS)
PACKET_FILTER_PROTOCOL_REGEX = ('(?i)^(%s|0x[0-9a-fA-F]+|[0-9]+|)$' %
'|'.join(SUPPORTED_PROTOCOLS))
PACKET_FILTER_ATTR_PARAMS = {
'id': {'allow_post': False, 'allow_put': False,
'validate': {'type:uuid': None},
'is_visible': True},
'name': {'allow_post': True, 'allow_put': True, 'default': '',
'validate': {'type:string': attributes.NAME_MAX_LEN},
'is_visible': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': attributes.TENANT_ID_MAX_LEN},
'required_by_policy': True,
'is_visible': True},
'network_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:uuid': None},
'is_visible': True},
'admin_state_up': {'allow_post': True, 'allow_put': True,
'default': True,
'convert_to': attributes.convert_to_boolean,
'is_visible': True},
'status': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'action': {'allow_post': True, 'allow_put': True,
'validate': {'type:regex': PACKET_FILTER_ACTION_REGEX},
'is_visible': True},
'priority': {'allow_post': True, 'allow_put': True,
'convert_to': convert_to_int_dec_and_hex,
'is_visible': True},
'in_port': {'allow_post': True, 'allow_put': False,
'default': attributes.ATTR_NOT_SPECIFIED,
'validate': {'type:uuid': None},
'is_visible': True},
'src_mac': {'allow_post': True, 'allow_put': True,
'default': attributes.ATTR_NOT_SPECIFIED,
'validate': {'type:mac_address_or_none': None},
'is_visible': True},
'dst_mac': {'allow_post': True, 'allow_put': True,
'default': attributes.ATTR_NOT_SPECIFIED,
'validate': {'type:mac_address_or_none': None},
'is_visible': True},
'eth_type': {'allow_post': True, 'allow_put': True,
'default': attributes.ATTR_NOT_SPECIFIED,
'convert_to': convert_to_int_or_none,
'is_visible': True},
'src_cidr': {'allow_post': True, 'allow_put': True,
'default': attributes.ATTR_NOT_SPECIFIED,
'validate': {'type:subnet_or_none': None},
'is_visible': True},
'dst_cidr': {'allow_post': True, 'allow_put': True,
'default': attributes.ATTR_NOT_SPECIFIED,
'validate': {'type:subnet_or_none': None},
'is_visible': True},
'protocol': {'allow_post': True, 'allow_put': True,
'default': attributes.ATTR_NOT_SPECIFIED,
'validate': {'type:regex_or_none':
PACKET_FILTER_PROTOCOL_REGEX},
'is_visible': True},
'src_port': {'allow_post': True, 'allow_put': True,
'default': attributes.ATTR_NOT_SPECIFIED,
'convert_to': convert_to_int_or_none,
'is_visible': True},
'dst_port': {'allow_post': True, 'allow_put': True,
'default': attributes.ATTR_NOT_SPECIFIED,
'convert_to': convert_to_int_or_none,
'is_visible': True},
}
PACKET_FILTER_ATTR_MAP = {COLLECTION: PACKET_FILTER_ATTR_PARAMS}
class Packetfilter(extensions.ExtensionDescriptor):
@classmethod
def get_name(cls):
return ALIAS
@classmethod
def get_alias(cls):
return ALIAS
@classmethod
def get_description(cls):
return "PacketFilters on OFC"
@classmethod
def get_updated(cls):
return "2013-07-16T00:00:00+09:00"
@classmethod
def get_resources(cls):
qresource = quota_resource.CountableResource(
RESOURCE, quota_resource._count_resource, 'quota_%s' % RESOURCE)
resource_registry.register_resource(qresource)
resource = base.create_resource(COLLECTION, RESOURCE,
manager.NeutronManager.get_plugin(),
PACKET_FILTER_ATTR_PARAMS)
pf_ext = extensions.ResourceExtension(
COLLECTION, resource, attr_map=PACKET_FILTER_ATTR_PARAMS)
return [pf_ext]
def get_extended_resources(self, version):
if version == "2.0":
return PACKET_FILTER_ATTR_MAP
else:
return {}

View File

@ -1,56 +0,0 @@
# Copyright 2013 NEC Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from neutron.api import extensions
from neutron.api.v2 import attributes
LOG = logging.getLogger(__name__)
ROUTER_PROVIDER = 'provider'
ROUTER_PROVIDER_ATTRIBUTE = {
'routers': {ROUTER_PROVIDER:
{'allow_post': True,
'allow_put': False,
'is_visible': True,
'default': attributes.ATTR_NOT_SPECIFIED}
}
}
class Router_provider(extensions.ExtensionDescriptor):
@classmethod
def get_name(cls):
return "Router Provider"
@classmethod
def get_alias(cls):
return "router_provider"
@classmethod
def get_description(cls):
return "Router Provider Support"
@classmethod
def get_updated(cls):
return "2013-08-20T10:00:00-00:00"
def get_extended_resources(self, version):
if version == "2.0":
return ROUTER_PROVIDER_ATTRIBUTE
else:
return {}

View File

@ -1,47 +0,0 @@
# Copyright 2012-2013 NEC Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from networking_nec.plugins.openflow import plugin
from neutron.plugins.nec import config as nec_config
class NECPluginV2(plugin.NECPluginV2Impl):
_supported_extension_aliases = ["agent",
"allowed-address-pairs",
"binding",
"dhcp_agent_scheduler",
"external-net",
"ext-gw-mode",
"extraroute",
"l3_agent_scheduler",
"packet-filter",
"quotas",
"router",
"router_provider",
"security-group",
]
@property
def supported_extension_aliases(self):
if not hasattr(self, '_aliases'):
aliases = self._supported_extension_aliases[:]
self.setup_extension_aliases(aliases)
self._aliases = aliases
return self._aliases
def __init__(self):
nec_config.register_plugin_opts()
super(NECPluginV2, self).__init__()

View File

@ -1 +0,0 @@
networking-nec>=2015.1,<2015.2

View File

@ -38,7 +38,6 @@ data_files =
etc/neutron/rootwrap.d/ipset-firewall.filters
etc/neutron/rootwrap.d/l3.filters
etc/neutron/rootwrap.d/linuxbridge-plugin.filters
etc/neutron/rootwrap.d/nec-plugin.filters
etc/neutron/rootwrap.d/openvswitch-plugin.filters
etc/init.d = etc/init.d/neutron-server
etc/neutron/plugins/bigswitch =
@ -70,7 +69,6 @@ data_files =
etc/neutron/plugins/ml2/ml2_conf_sriov.ini
etc/neutron/plugins/ml2/openvswitch_agent.ini
etc/neutron/plugins/mlnx = etc/neutron/plugins/mlnx/mlnx_conf.ini
etc/neutron/plugins/nec = etc/neutron/plugins/nec/nec.ini
etc/neutron/plugins/nuage = etc/neutron/plugins/nuage/nuage_plugin.ini
etc/neutron/plugins/oneconvergence = etc/neutron/plugins/oneconvergence/nvsdplugin.ini
etc/neutron/plugins/plumgrid = etc/neutron/plugins/plumgrid/plumgrid.ini
@ -92,7 +90,6 @@ console_scripts =
neutron-linuxbridge-agent = neutron.plugins.ml2.drivers.linuxbridge.agent.linuxbridge_neutron_agent:main
neutron-metadata-agent = neutron.cmd.eventlet.agents.metadata:main
neutron-mlnx-agent = neutron.cmd.eventlet.plugins.mlnx_neutron_agent:main
neutron-nec-agent = neutron.cmd.eventlet.plugins.nec_neutron_agent:main
neutron-netns-cleanup = neutron.cmd.netns_cleanup:main
neutron-ns-metadata-proxy = neutron.cmd.eventlet.agents.metadata_proxy:main
neutron-ovsvapp-agent = neutron.cmd.eventlet.plugins.ovsvapp_neutron_agent:main
@ -115,7 +112,6 @@ neutron.core_plugins =
ibm = neutron.plugins.ibm.sdnve_neutron_plugin:SdnvePluginV2
midonet = neutron.plugins.midonet.plugin:MidonetPluginV2
ml2 = neutron.plugins.ml2.plugin:Ml2Plugin
nec = neutron.plugins.nec.nec_plugin:NECPluginV2
nuage = neutron.plugins.nuage.plugin:NuagePlugin
oneconvergence = neutron.plugins.oneconvergence.plugin:OneConvergencePluginV2
plumgrid = neutron.plugins.plumgrid.plumgrid_plugin.plumgrid_plugin:NeutronPluginPLUMgridV2