1
# Copyright 2014 A10 Networks
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
15
from neutron_lbaas.db.loadbalancer import loadbalancer_db as lb_db
16
from neutron_lbaas.services.loadbalancer.drivers import driver_mixins
19
class NotImplementedManager(object):
20
"""Helper class to make any subclass of LBAbstractDriver explode if it
21
is missing any of the required object managers.
24
def create(self, context, obj):
25
raise NotImplementedError()
27
def update(self, context, old_obj, obj):
28
raise NotImplementedError()
30
def delete(self, context, obj):
31
raise NotImplementedError()
34
class LoadBalancerBaseDriver(object):
35
"""LBaaSv2 object model drivers should subclass LBAbstractDriver, and
36
initialize the following manager classes to create, update, and delete
37
the various load balancer objects.
40
load_balancer = NotImplementedManager()
41
listener = NotImplementedManager()
42
pool = NotImplementedManager()
43
member = NotImplementedManager()
44
health_monitor = NotImplementedManager()
46
def __init__(self, plugin):
50
class BaseLoadBalancerManager(driver_mixins.BaseRefreshMixin,
51
driver_mixins.BaseStatsMixin,
52
driver_mixins.BaseStatusUpdateMixin,
53
driver_mixins.BaseManagerMixin):
55
def __init__(self, driver):
56
super(BaseLoadBalancerManager, self).__init__(driver)
57
# TODO(dougw), use lb_db.LoadBalancer when v2 lbaas
58
# TODO(dougw), get rid of __init__() in StatusHelperManager, and
59
# the if is not None clauses; after fixing this next line,
60
# it can become a mandatory variable for that subclass.
61
self.model_class = None
64
class BaseListenerManager(driver_mixins.BaseManagerMixin):
68
class BasePoolManager(driver_mixins.BaseStatusUpdateMixin,
69
driver_mixins.BaseManagerMixin):
71
def __init__(self, driver):
72
super(BasePoolManager, self).__init__(driver)
73
self.model_class = lb_db.Pool
76
class BaseMemberManager(driver_mixins.BaseStatusUpdateMixin,
77
driver_mixins.BaseManagerMixin):
79
def __init__(self, driver):
80
super(BaseMemberManager, self).__init__(driver)
81
self.model_class = lb_db.Member
84
class BaseHealthMonitorManager(
85
driver_mixins.BaseHealthMonitorStatusUpdateMixin,
86
driver_mixins.BaseManagerMixin):