/usr/lib/python2.7/dist-packages/neutron_lbaas/services/loadbalancer/drivers/a10networks/driver_v1.py is in python-neutron-lbaas 2:8.0.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | # Copyright 2014, Doug Wiegley (dougwig), A10 Networks
#
# 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 a10_neutron_lbaas
from neutron.db import l3_db
from neutron.plugins.common import constants
from oslo_log import log as logging
from neutron_lbaas.db.loadbalancer import loadbalancer_db as lb_db
from neutron_lbaas.services.loadbalancer.drivers import abstract_driver
VERSION = "1.0.0"
LOG = logging.getLogger(__name__)
# Most driver calls below are straight passthroughs to the A10 package
# 'a10_neutron_lbaas'. Any function that has not been fully abstracted
# into the openstack driver/plugin interface is NOT passed through, to
# make it obvious which hidden interfaces/db calls that we rely on.
class ThunderDriver(abstract_driver.LoadBalancerAbstractDriver):
def __init__(self, plugin):
LOG.debug("A10Driver: init version=%s", VERSION)
self.plugin = plugin
# Map the string types to neutron classes/functions, in order to keep
# from reaching into the bowels of Neutron from anywhere but this file.
self.neutron_map = {
'member': {
'model': lb_db.Member,
'delete_func': self.plugin._delete_db_member,
},
'pool': {
'model': lb_db.Pool,
'delete_func': self.plugin._delete_db_pool,
},
'vip': {
'model': lb_db.Vip,
'delete_func': self.plugin._delete_db_vip,
},
}
LOG.debug("A10Driver: initializing, version=%s, lbaas_manager=%s",
VERSION, a10_neutron_lbaas.VERSION)
self.a10 = a10_neutron_lbaas.A10OpenstackLBV1(self)
# The following private helper methods are used by a10_neutron_lbaas,
# and reflect the neutron interfaces required by that package.
def _hm_binding_count(self, context, hm_id):
return context.session.query(lb_db.PoolMonitorAssociation).filter_by(
monitor_id=hm_id).join(lb_db.Pool).count()
def _member_count(self, context, member):
return context.session.query(lb_db.Member).filter_by(
tenant_id=member['tenant_id'],
address=member['address']).count()
def _member_get(self, context, member_id):
return self.plugin.get_member(context, member_id)
def _member_get_ip(self, context, member, use_float=False):
ip_address = member['address']
if use_float:
fip_qry = context.session.query(l3_db.FloatingIP)
if fip_qry.filter_by(fixed_ip_address=ip_address).count() > 0:
float_address = fip_qry.filter_by(
fixed_ip_address=ip_address).first()
ip_address = str(float_address.floating_ip_address)
return ip_address
def _pool_get_hm(self, context, hm_id):
return self.plugin.get_health_monitor(context, hm_id)
def _pool_get_tenant_id(self, context, pool_id):
pool_qry = context.session.query(lb_db.Pool).filter_by(id=pool_id)
z = pool_qry.first()
if z:
return z.tenant_id
else:
return ''
def _pool_get_vip_id(self, context, pool_id):
pool_qry = context.session.query(lb_db.Pool).filter_by(id=pool_id)
z = pool_qry.first()
if z:
return z.vip_id
else:
return ''
def _pool_total(self, context, tenant_id):
return context.session.query(lb_db.Pool).filter_by(
tenant_id=tenant_id).count()
def _vip_get(self, context, vip_id):
return self.plugin.get_vip(context, vip_id)
def _active(self, context, model_type, model_id):
self.plugin.update_status(context,
self.neutron_map[model_type]['model'],
model_id,
constants.ACTIVE)
def _failed(self, context, model_type, model_id):
self.plugin.update_status(context,
self.neutron_map[model_type]['model'],
model_id,
constants.ERROR)
def _db_delete(self, context, model_type, model_id):
self.neutron_map[model_type]['delete_func'](context, model_id)
def _hm_active(self, context, hm_id, pool_id):
self.plugin.update_pool_health_monitor(context, hm_id, pool_id,
constants.ACTIVE)
def _hm_failed(self, context, hm_id, pool_id):
self.plugin.update_pool_health_monitor(context, hm_id, pool_id,
constants.ERROR)
def _hm_db_delete(self, context, hm_id, pool_id):
self.plugin._delete_db_pool_health_monitor(context, hm_id, pool_id)
# Pass-through driver
def create_vip(self, context, vip):
self.a10.vip.create(context, vip)
def update_vip(self, context, old_vip, vip):
self.a10.vip.update(context, old_vip, vip)
def delete_vip(self, context, vip):
self.a10.vip.delete(context, vip)
def create_pool(self, context, pool):
self.a10.pool.create(context, pool)
def update_pool(self, context, old_pool, pool):
self.a10.pool.update(context, old_pool, pool)
def delete_pool(self, context, pool):
self.a10.pool.delete(context, pool)
def stats(self, context, pool_id):
return self.a10.pool.stats(context, pool_id)
def create_member(self, context, member):
self.a10.member.create(context, member)
def update_member(self, context, old_member, member):
self.a10.member.update(context, old_member, member)
def delete_member(self, context, member):
self.a10.member.delete(context, member)
def update_pool_health_monitor(self, context, old_hm, hm, pool_id):
self.a10.hm.update(context, old_hm, hm, pool_id)
def create_pool_health_monitor(self, context, hm, pool_id):
self.a10.hm.create(context, hm, pool_id)
def delete_pool_health_monitor(self, context, hm, pool_id):
self.a10.hm.delete(context, hm, pool_id)
|