neutron-lbaas/neutron_lbaas/agent/agent_device_driver.py
Nir Magnezi 8c01eff53b Implements ProcessMonitor in the haproxy driver
The ProcessMonitor class will monitor spawned external processes.

This patch enhances the HaproxyNSDriver class (v2) to utilize the
external_process module in order to monitor and respawn the haproxy
processes if and when needed.

With this patch the LBaaS agent (v2) will load external_process related
options in order to take a configured action when haproxy process
dies unexpectedly.

This is the second attempt to introduce ProcessMonitor in the haproxy
driver. The first attempt I420ca20b2620487909885e0e9f08dae60ebec2bf
caused an issue where haproxy failed to acquire new configuration, due
to the lack of -sf flags which should be provided when haproxy.conf is
being updated. More information about the flags here[1]

[1] http://www.haproxy.org/download/1.2/doc/haproxy-en.txt

Co-Authored-By: Thomas Herve <therve@redhat.com>
Closes-Bug: #1565801
Related-Bug: #1603860

Change-Id: Ia47b1586be17be421e01c131859dd0d50b1d7db6
2017-01-11 20:37:24 +00:00

110 lines
2.5 KiB
Python

# Copyright 2013 OpenStack Foundation. All rights reserved
# Copyright 2015 Rackspace
#
# 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 abc
import six
@six.add_metaclass(abc.ABCMeta)
class AgentDeviceDriver(object):
"""Abstract device driver that defines the API required by LBaaS agent."""
def __init__(self, conf, plugin_rpc, process_monitor=None):
self.conf = conf
self.plugin_rpc = plugin_rpc
self.process_monitor = process_monitor
@abc.abstractproperty
def loadbalancer(self):
pass
@abc.abstractproperty
def listener(self):
pass
@abc.abstractproperty
def pool(self):
pass
@abc.abstractproperty
def member(self):
pass
@abc.abstractproperty
def healthmonitor(self):
pass
@abc.abstractmethod
def get_name(self):
"""Returns unique name across all LBaaS device drivers."""
pass
@abc.abstractmethod
def deploy_instance(self, loadbalancer):
"""Fully deploys a loadbalancer instance from a given loadbalancer."""
pass
@abc.abstractmethod
def undeploy_instance(self, loadbalancer_id, **kwargs):
"""Fully undeploys the loadbalancer instance."""
pass
def remove_orphans(self, known_loadbalancer_ids):
# Not all drivers will support this
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class BaseManager(object):
def __init__(self, driver):
self.driver = driver
@abc.abstractmethod
def create(self, obj):
pass
@abc.abstractmethod
def update(self, old_obj, obj):
pass
@abc.abstractmethod
def delete(self, obj):
pass
class BaseLoadBalancerManager(BaseManager):
@abc.abstractmethod
def get_stats(self, loadbalancer_id):
pass
class BaseListenerManager(BaseManager):
pass
class BasePoolManager(BaseManager):
pass
class BaseMemberManager(BaseManager):
pass
class BaseHealthMonitorManager(BaseManager):
pass