Skip to content

Commit

Permalink
Embrane LBaaS Driver
Browse files Browse the repository at this point in the history
Implements blueprint embrane-lbaas-driver

This commit implements Embrane's driver for LBaaS,
which uses Embrane's heleos(tm) appliances to provide Load Balancing.

Change-Id: Ia76fbc8881d178cfe6df11a2cfe8e77d3f36094f
  • Loading branch information
Ivar Lazzaro committed Mar 12, 2014
1 parent 3067748 commit ff7623f
Show file tree
Hide file tree
Showing 20 changed files with 1,133 additions and 7 deletions.
4 changes: 3 additions & 1 deletion etc/neutron.conf
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ notification_driver = neutron.openstack.common.notifier.rpc_notifier
# quota_health_monitors = -1

# Number of routers allowed per tenant. A negative value means unlimited.
# quota_router = 10
# quota_router = 10

# Number of floating IPs allowed per tenant. A negative value means unlimited.
# quota_floatingip = 50
Expand Down Expand Up @@ -427,3 +427,5 @@ service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVP
# service_provider=LOADBALANCER:NetScaler:neutron.services.loadbalancer.drivers.netscaler.netscaler_driver.NetScalerPluginDriver
# Uncomment the following line (and comment out the OpenSwan VPN line) to enable Cisco's VPN driver.
# service_provider=VPN:cisco:neutron.services.vpn.service_drivers.cisco_ipsec.CiscoCsrIPsecVPNDriver:default
# Uncomment the line below to use Embrane heleos as Load Balancer service provider.
# service_provider=LOADBALANCER:Embrane:neutron.services.loadbalancer.drivers.embrane.driver.EmbraneLbaas:default
14 changes: 14 additions & 0 deletions etc/services.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,17 @@
#netscaler_ncc_uri = https://ncc_server.acme.org/ncc/v1/api
#netscaler_ncc_username = admin
#netscaler_ncc_password = secret

[heleoslb]
#esm_mgmt =
#admin_username =
#admin_password =
#lb_image =
#inband_id =
#oob_id =
#mgmt_id =
#dummy_utif_id =
#resource_pool_id =
#async_requests =
#lb_flavor = small
#sync_interval = 60
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright 2014 OpenStack Foundation
#
# 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.
#

"""embrane_lbaas_driver
Revision ID: 33dd0a9fa487
Revises: 19180cf98af6
Create Date: 2014-02-25 00:15:35.567111
"""

# revision identifiers, used by Alembic.
revision = '33dd0a9fa487'
down_revision = '19180cf98af6'

# Change to ['*'] if this migration applies to all plugins

migration_for_plugins = [
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin'
]

from alembic import op
import sqlalchemy as sa

from neutron.db import migration


def upgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return

op.create_table(
u'embrane_pool_port',
sa.Column(u'pool_id', sa.String(length=36), nullable=False),
sa.Column(u'port_id', sa.String(length=36), nullable=False),
sa.ForeignKeyConstraint(['pool_id'], [u'pools.id'],
name=u'embrane_pool_port_ibfk_1'),
sa.ForeignKeyConstraint(['port_id'], [u'ports.id'],
name=u'embrane_pool_port_ibfk_2'),
sa.PrimaryKeyConstraint(u'pool_id'))


def downgrade(active_plugins=None, options=None):
if not migration.should_run(active_plugins, migration_for_plugins):
return

op.drop_table(u'embrane_pool_port')
10 changes: 5 additions & 5 deletions neutron/plugins/embrane/agent/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, plugin, async=True):
def dispatch_l3(self, d_context, args=(), kwargs={}):
item = d_context.item
event = d_context.event
q_context = d_context.q_context
n_context = d_context.n_context
chain = d_context.chain

item_id = item["id"]
Expand All @@ -52,7 +52,7 @@ def dispatch_l3(self, d_context, args=(), kwargs={}):
self.sync_items[item_id] = (queue.Queue(),)
first_run = True
self.sync_items[item_id][0].put(
ctx.OperationContext(event, q_context, item, chain, f,
ctx.OperationContext(event, n_context, item, chain, f,
args, kwargs))
t = None
if first_run:
Expand Down Expand Up @@ -93,7 +93,7 @@ def _consume_l3(self, sync_item, sync_queue, plugin, a_sync):
try:
dva_state = operation_context.function(
plugin._esm_api,
operation_context.q_context.tenant_id,
operation_context.n_context.tenant_id,
operation_context.item,
*operation_context.args,
**operation_context.kwargs)
Expand Down Expand Up @@ -122,12 +122,12 @@ def _consume_l3(self, sync_item, sync_queue, plugin, a_sync):
if transient_state:
if transient_state == p_con.Status.DELETED:
current_state = plugin._delete_router(
operation_context.q_context,
operation_context.n_context,
operation_context.item["id"])
# Error state cannot be reverted
elif transient_state != p_con.Status.ERROR:
current_state = plugin._update_neutron_state(
operation_context.q_context,
operation_context.n_context,
operation_context.item,
transient_state)
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion neutron/plugins/embrane/common/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DispatcherContext(object):
def __init__(self, event, item, neutron_context, chain=None):
self.event = event
self.item = item
self.q_context = neutron_context
self.n_context = neutron_context
self.chain = chain


Expand Down
4 changes: 4 additions & 0 deletions neutron/plugins/embrane/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@

class EmbranePluginException(neutron_exec.NeutronException):
message = _("An unexpected error occurred:%(err_msg)s")


class UnsupportedException(EmbranePluginException):
message = _("%(err_msg)s")
9 changes: 9 additions & 0 deletions neutron/services/loadbalancer/drivers/embrane/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Embrane LBaaS Driver

This DRIVER interfaces OpenStack Neutron with Embrane's heleos platform,
Load Balancing appliances for cloud environments.

L2 connectivity is leveraged by one of the supported existing plugins.

For more details on use, configuration and implementation please refer to:
https://wiki.openstack.org/wiki/Neutron/LBaaS/EmbraneDriver
Empty file.
Empty file.
108 changes: 108 additions & 0 deletions neutron/services/loadbalancer/drivers/embrane/agent/dispatcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Copyright 2014 Embrane, Inc.
# 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.
#
# @author: Ivar Lazzaro, Embrane, Inc. ivar@embrane.com

from eventlet import greenthread
from eventlet import queue
from heleosapi import exceptions as h_exc

from neutron.openstack.common import log as logging
from neutron.plugins.embrane.common import contexts as ctx
from neutron.services.loadbalancer.drivers.embrane.agent import lb_operations
from neutron.services.loadbalancer.drivers.embrane import constants as econ

LOG = logging.getLogger(__name__)


class Dispatcher(object):
def __init__(self, driver, async=True):
self._async = async
self._driver = driver
self.sync_items = dict()
self.handlers = lb_operations.handlers

def dispatch_lb(self, d_context, *args, **kwargs):
item = d_context.item
event = d_context.event
n_context = d_context.n_context
chain = d_context.chain

item_id = item["id"]
if event in self.handlers:
for f in self.handlers[event]:
first_run = False
if item_id not in self.sync_items:
self.sync_items[item_id] = [queue.Queue()]
first_run = True
self.sync_items[item_id][0].put(
ctx.OperationContext(event, n_context, item, chain, f,
args, kwargs))
if first_run:
t = greenthread.spawn(self._consume_lb,
item_id,
self.sync_items[item_id][0],
self._driver,
self._async)
self.sync_items[item_id].append(t)
if not self._async:
t = self.sync_items[item_id][1]
t.wait()

def _consume_lb(self, sync_item, sync_queue, driver, a_sync):
current_state = None
while True:
try:
if current_state == econ.DELETED:
del self.sync_items[sync_item]
return
try:
operation_context = sync_queue.get(
block=a_sync,
timeout=econ.QUEUE_TIMEOUT)
except queue.Empty:
del self.sync_items[sync_item]
return

(operation_context.chain and
operation_context.chain.execute_all())

transient_state = None
try:
transient_state = operation_context.function(
driver, operation_context.n_context,
operation_context.item, *operation_context.args,
**operation_context.kwargs)
except (h_exc.PendingDva, h_exc.DvaNotFound,
h_exc.BrokenInterface, h_exc.DvaCreationFailed,
h_exc.BrokenDva, h_exc.ConfigurationFailed) as ex:
LOG.warning(econ.error_map[type(ex)], ex.message)
except h_exc.DvaDeleteFailed as ex:
LOG.warning(econ.error_map[type(ex)], ex.message)
transient_state = econ.DELETED
finally:
# if the returned transient state is None, no operations
# are required on the DVA status
if transient_state == econ.DELETED:
current_state = driver._delete_vip(
operation_context.n_context,
operation_context.item)
# Error state cannot be reverted
else:
driver._update_vip_graph_state(
operation_context.n_context,
operation_context.item)
except Exception:
LOG.exception(_('Unhandled exception occurred'))
Loading

0 comments on commit ff7623f

Please sign in to comment.