~thedac/ubuntu/vivid/neutron-lbaas/2015.1.1

« back to all changes in this revision

Viewing changes to neutron_lbaas/services/loadbalancer/drivers/driver_base.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-01-14 11:31:23 UTC
  • Revision ID: package-import@ubuntu.com-20150114113123-t0ymuw5vm45jn8gu
Tags: upstream-2015.1~b1
ImportĀ upstreamĀ versionĀ 2015.1~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014 A10 Networks
 
2
#
 
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
 
6
#
 
7
#         http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
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
 
13
#    under the License.
 
14
 
 
15
from neutron_lbaas.db.loadbalancer import loadbalancer_db as lb_db
 
16
from neutron_lbaas.services.loadbalancer.drivers import driver_mixins
 
17
 
 
18
 
 
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.
 
22
    """
 
23
 
 
24
    def create(self, context, obj):
 
25
        raise NotImplementedError()
 
26
 
 
27
    def update(self, context, old_obj, obj):
 
28
        raise NotImplementedError()
 
29
 
 
30
    def delete(self, context, obj):
 
31
        raise NotImplementedError()
 
32
 
 
33
 
 
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.
 
38
    """
 
39
 
 
40
    load_balancer = NotImplementedManager()
 
41
    listener = NotImplementedManager()
 
42
    pool = NotImplementedManager()
 
43
    member = NotImplementedManager()
 
44
    health_monitor = NotImplementedManager()
 
45
 
 
46
    def __init__(self, plugin):
 
47
        self.plugin = plugin
 
48
 
 
49
 
 
50
class BaseLoadBalancerManager(driver_mixins.BaseRefreshMixin,
 
51
                              driver_mixins.BaseStatsMixin,
 
52
                              driver_mixins.BaseStatusUpdateMixin,
 
53
                              driver_mixins.BaseManagerMixin):
 
54
 
 
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
 
62
 
 
63
 
 
64
class BaseListenerManager(driver_mixins.BaseManagerMixin):
 
65
    pass
 
66
 
 
67
 
 
68
class BasePoolManager(driver_mixins.BaseStatusUpdateMixin,
 
69
                      driver_mixins.BaseManagerMixin):
 
70
 
 
71
    def __init__(self, driver):
 
72
        super(BasePoolManager, self).__init__(driver)
 
73
        self.model_class = lb_db.Pool
 
74
 
 
75
 
 
76
class BaseMemberManager(driver_mixins.BaseStatusUpdateMixin,
 
77
                        driver_mixins.BaseManagerMixin):
 
78
 
 
79
    def __init__(self, driver):
 
80
        super(BaseMemberManager, self).__init__(driver)
 
81
        self.model_class = lb_db.Member
 
82
 
 
83
 
 
84
class BaseHealthMonitorManager(
 
85
                              driver_mixins.BaseHealthMonitorStatusUpdateMixin,
 
86
                              driver_mixins.BaseManagerMixin):
 
87
    pass