Merge pull request #57 from rodis/feature/update_nsx_to_juno

Feature/update nsx to juno
This commit is contained in:
markmcclain 2015-03-23 14:35:40 -04:00
commit 729eb014f5
4 changed files with 14 additions and 196 deletions

View File

@ -28,9 +28,7 @@ from neutron.db import l3_db
from neutron import manager
from neutron.plugins.common import constants
from sqlalchemy.orm import exc
from akanda.neutron.db import models_v2 as akmodels
IPV6_ASSIGNMENT_ATTEMPTS = 1000
LOG = logging.getLogger(__name__)
@ -51,29 +49,7 @@ akanda_opts = [
cfg.CONF.register_opts(akanda_opts)
SUPPORTED_EXTENSIONS = [
'dhportforward', 'dhaddressgroup', 'dhaddressentry', 'dhfilterrule',
'dhportalias', 'dhrouterstatus'
]
# Provide a list of the default port aliases to be
# created for a tenant.
# FIXME(dhellmann): This list should come from
# a configuration file somewhere.
DEFAULT_PORT_ALIASES = [
('tcp', 0, 'Any TCP'),
('udp', 0, 'Any UDP'),
('tcp', 22, 'ssh'),
('udp', 53, 'DNS'),
('tcp', 80, 'HTTP'),
('tcp', 443, 'HTTPS'),
]
# Provide a list of the default address entries
# to be created for a tenant.
# FIXME(dhellmann): This list should come from
# a configuration file somewhere.
DEFAULT_ADDRESS_GROUPS = [
('Any', [('Any', '0.0.0.0/0')]),
'dhrouterstatus',
]
@ -110,18 +86,6 @@ def sync_subnet_gateway_port(f):
return wrapper
def auto_add_other_resources(f):
@functools.wraps(f)
def wrapper(self, context, *args, **kwargs):
LOG.debug('auto_add_other_resources')
retval = f(self, context, *args, **kwargs)
if not context.is_admin:
_auto_add_port_aliases(context)
_auto_add_address_groups(context)
return retval
return wrapper
def check_subnet_cidr_meets_policy(context, subnet):
if context.is_admin:
return
@ -354,71 +318,3 @@ def _generate_ipv6_address(cidr, mac_address):
# the bit inversion is required by the RFC
return str(netaddr.IPAddress(network.value + (eui64 ^ 0x0200000000000000)))
def _auto_add_address_groups(context):
"""Create default address groups if the tenant does not have them. """
for ag_name, entries in DEFAULT_ADDRESS_GROUPS:
ag_q = context.session.query(akmodels.AddressGroup)
ag_q = ag_q.filter_by(
tenant_id=context.tenant_id,
name=ag_name,
)
try:
address_group = ag_q.one()
except exc.NoResultFound:
with context.session.begin(subtransactions=True):
address_group = akmodels.AddressGroup(
name=ag_name,
tenant_id=context.tenant_id,
)
context.session.add(address_group)
LOG.debug('Created default address group %s',
address_group.name)
for entry_name, cidr in entries:
entry_q = context.session.query(akmodels.AddressEntry)
entry_q = entry_q.filter_by(
group=address_group,
name=entry_name,
cidr=cidr,
)
try:
entry_q.one()
except exc.NoResultFound:
with context.session.begin(subtransactions=True):
entry = akmodels.AddressEntry(
name=entry_name,
group=address_group,
cidr=cidr,
tenant_id=context.tenant_id,
)
context.session.add(entry)
LOG.debug(
'Created default entry for %s in address group %s',
cidr, address_group.name)
def _auto_add_port_aliases(context):
"""Create the default port aliases for the current tenant, if
they don't already exist.
"""
for protocol, port, name in DEFAULT_PORT_ALIASES:
pa_q = context.session.query(akmodels.PortAlias)
pa_q = pa_q.filter_by(
tenant_id=context.tenant_id,
port=port,
protocol=protocol,
)
try:
pa_q.one()
except exc.NoResultFound:
with context.session.begin(subtransactions=True):
alias = akmodels.PortAlias(
name=name,
protocol=protocol,
port=port,
tenant_id=context.tenant_id,
)
context.session.add(alias)
LOG.debug('Created default port alias %s', alias.name)

View File

@ -30,13 +30,6 @@ class Ml2Plugin(floatingip.ExplicitFloatingIPAllocationMixin,
["dhrouterstatus"]
)
# The auto_add_other_resources decorator enable the automatic
# creation of a bunch of resources. These resources are in the
# form of neutron extensions and need to be registered with the
# plugin. Since we are not enabling those extension right now,
# lets comment out the decorator
# @akanda.auto_add_other_resources
@akanda.auto_add_ipv6_subnet
def create_network(self, context, network):
return super(Ml2Plugin, self).create_network(context, network)

View File

@ -18,18 +18,18 @@ import functools
from sqlalchemy import exc as sql_exc
from neutron.api.rpc.handlers import dhcp_rpc, l3_rpc
from neutron.common import constants
from neutron.common import exceptions as n_exc
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.db import agents_db
from neutron.db import l3_db
from neutron.db import l3_rpc_base as l3_rpc
from neutron.openstack.common import log as logging
from neutron.openstack.common import rpc
from neutron.openstack.common.db import exception as db_exc
from oslo.db import exception as db_exc
from neutron.plugins.vmware.api_client import exception as api_exc
from neutron.plugins.vmware.common import nsx_utils
from neutron.plugins.vmware.common import sync as nsx_sync
from neutron.plugins.vmware.dhcp_meta import rpc as nsx_rpc
from neutron.plugins.vmware.dbexts import db as nsx_db
from neutron.plugins.vmware.nsxlib import switch as switchlib
from neutron.plugins.vmware.plugins import base
@ -78,12 +78,6 @@ base.switchlib._configure_extensions = akanda_nvp_ipv6_port_security_wrapper(
)
class AkandaNsxRpcCallbacks(l3_rpc.L3RpcCallbackMixin,
nsx_rpc.NSXRpcCallbacks):
""" Class TODO:(rods)"""
pass
class AkandaNsxSynchronizer(nsx_sync.NsxSynchronizer):
"""
The NsxSynchronizer class in Neutron runs a synchronization thread to
@ -225,22 +219,27 @@ class NsxPluginV2(floatingip.ExplicitFloatingIPAllocationMixin,
def setup_dhcpmeta_access(self):
# Ok, so we're going to add L3 here too with the DHCP
self.conn = rpc.create_connection(new=True)
self.conn = n_rpc.create_connection(new=True)
self.conn.create_consumer(
topics.PLUGIN,
AkandaNsxRpcCallbacks().create_rpc_dispatcher(),
[dhcp_rpc.DhcpRpcCallback(), agents_db.AgentExtRpcCallback()],
fanout=False
)
self.conn.create_consumer(
topics.L3PLUGIN,
[l3_rpc.L3RpcCallback()],
fanout=False
)
# Consume from all consumers in a thread
self.conn.consume_in_thread()
self.conn.consume_in_threads()
self.handle_network_dhcp_access_delegate = noop
self.handle_port_dhcp_access_delegate = noop
self.handle_port_metadata_access_delegate = noop
self.handle_metadata_access_delegate = noop
@akanda.auto_add_other_resources
@akanda.auto_add_ipv6_subnet
def create_network(self, context, network):
return super(NsxPluginV2, self).create_network(context, network)

View File

@ -1,70 +0,0 @@
# Copyright 2014 DreamHost, LLC
#
# Author: DreamHost, LLC
#
# 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 neutron.plugins.openvswitch import ovs_neutron_plugin
from akanda.neutron.plugins import decorators as akanda
from akanda.neutron.plugins import floatingip
akanda.monkey_patch_ipv6_generator()
class OVSNeutronPluginV2(floatingip.ExplicitFloatingIPAllocationMixin,
ovs_neutron_plugin.OVSNeutronPluginV2):
_supported_extension_aliases = (
ovs_neutron_plugin.OVSNeutronPluginV2._supported_extension_aliases +
["dhportforward", "dhaddressgroup", "dhaddressentry",
"dhfilterrule", "dhportalias", "dhrouterstatus"])
try:
_supported_extension_aliases.remove('agent_scheduler')
except ValueError:
pass
@akanda.auto_add_other_resources
@akanda.auto_add_ipv6_subnet
def create_network(self, context, network):
return super(OVSNeutronPluginV2, self).create_network(context, network)
@akanda.auto_add_subnet_to_router
def create_subnet(self, context, subnet):
return super(OVSNeutronPluginV2, self).create_subnet(context, subnet)
@akanda.sync_subnet_gateway_port
def update_subnet(self, context, id, subnet):
return super(OVSNeutronPluginV2, self).update_subnet(
context, id, subnet)
def list_routers_on_l3_agent(self, context, agent_id):
return {
'routers': self.get_routers(context),
}
def list_active_sync_routers_on_active_l3_agent(
self, context, host, router_ids):
# Override L3AgentSchedulerDbMixin method
filters = {}
if router_ids:
filters['id'] = router_ids
routers = self.get_routers(context, filters=filters)
new_router_ids = [r['id'] for r in routers]
if new_router_ids:
return self.get_sync_data(
context,
router_ids=new_router_ids,
active=True,
)
return []