NSXv: LBaaSv2 shared pools
Support shared pool fuctionality of LBaaSv2 for NSXv driver. Change-Id: If3368b341658fe0f6073d19e6d2ca2eadb2222d3
This commit is contained in:
parent
af8cd3f2ca
commit
4383b9d391
@ -1 +1 @@
|
|||||||
dbe29d208ac6
|
d49ac91b560e
|
@ -0,0 +1,45 @@
|
|||||||
|
# Copyright 2016 VMware, Inc.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
"""Support shared pools with NSXv LBaaSv2 driver
|
||||||
|
|
||||||
|
Revision ID: d49ac91b560e
|
||||||
|
Revises: dbe29d208ac6
|
||||||
|
Create Date: 2016-07-21 05:03:35.369938
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'd49ac91b560e'
|
||||||
|
down_revision = 'dbe29d208ac6'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
from sqlalchemy.engine import reflection
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
change_pk_constraint('nsxv_lbaas_pool_bindings', ['loadbalancer_id',
|
||||||
|
'pool_id'])
|
||||||
|
change_pk_constraint('nsxv_lbaas_monitor_bindings', ['loadbalancer_id',
|
||||||
|
'pool_id',
|
||||||
|
'hm_id',
|
||||||
|
'edge_id'])
|
||||||
|
|
||||||
|
|
||||||
|
def change_pk_constraint(table_name, columns):
|
||||||
|
inspector = reflection.Inspector.from_engine(op.get_bind())
|
||||||
|
pk_constraint = inspector.get_pk_constraint(table_name)
|
||||||
|
op.drop_constraint(pk_constraint, table_name, type_='primary')
|
||||||
|
op.drop_column(table_name, 'listener_id')
|
||||||
|
op.create_primary_key(None, table_name, columns)
|
@ -677,44 +677,38 @@ def del_nsxv_lbaas_listener_binding(session, loadbalancer_id, listener_id):
|
|||||||
listener_id=listener_id).delete())
|
listener_id=listener_id).delete())
|
||||||
|
|
||||||
|
|
||||||
def add_nsxv_lbaas_pool_binding(session, loadbalancer_id, listener_id,
|
def add_nsxv_lbaas_pool_binding(session, loadbalancer_id, pool_id,
|
||||||
pool_id, edge_pool_id):
|
edge_pool_id):
|
||||||
with session.begin(subtransactions=True):
|
with session.begin(subtransactions=True):
|
||||||
binding = nsxv_models.NsxvLbaasPoolBinding(
|
binding = nsxv_models.NsxvLbaasPoolBinding(
|
||||||
loadbalancer_id=loadbalancer_id,
|
loadbalancer_id=loadbalancer_id,
|
||||||
listener_id=listener_id,
|
|
||||||
pool_id=pool_id,
|
pool_id=pool_id,
|
||||||
edge_pool_id=edge_pool_id)
|
edge_pool_id=edge_pool_id)
|
||||||
session.add(binding)
|
session.add(binding)
|
||||||
return binding
|
return binding
|
||||||
|
|
||||||
|
|
||||||
def get_nsxv_lbaas_pool_binding(session, loadbalancer_id, listener_id,
|
def get_nsxv_lbaas_pool_binding(session, loadbalancer_id, pool_id):
|
||||||
pool_id):
|
|
||||||
try:
|
try:
|
||||||
return session.query(
|
return session.query(
|
||||||
nsxv_models.NsxvLbaasPoolBinding).filter_by(
|
nsxv_models.NsxvLbaasPoolBinding).filter_by(
|
||||||
loadbalancer_id=loadbalancer_id,
|
loadbalancer_id=loadbalancer_id,
|
||||||
listener_id=listener_id,
|
|
||||||
pool_id=pool_id).one()
|
pool_id=pool_id).one()
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def del_nsxv_lbaas_pool_binding(session, loadbalancer_id, listener_id,
|
def del_nsxv_lbaas_pool_binding(session, loadbalancer_id, pool_id):
|
||||||
pool_id):
|
|
||||||
return (session.query(nsxv_models.NsxvLbaasPoolBinding).
|
return (session.query(nsxv_models.NsxvLbaasPoolBinding).
|
||||||
filter_by(loadbalancer_id=loadbalancer_id,
|
filter_by(loadbalancer_id=loadbalancer_id,
|
||||||
listener_id=listener_id,
|
|
||||||
pool_id=pool_id).delete())
|
pool_id=pool_id).delete())
|
||||||
|
|
||||||
|
|
||||||
def add_nsxv_lbaas_monitor_binding(session, loadbalancer_id, listener_id,
|
def add_nsxv_lbaas_monitor_binding(session, loadbalancer_id, pool_id, hm_id,
|
||||||
pool_id, hm_id, edge_id, edge_mon_id):
|
edge_id, edge_mon_id):
|
||||||
with session.begin(subtransactions=True):
|
with session.begin(subtransactions=True):
|
||||||
binding = nsxv_models.NsxvLbaasMonitorBinding(
|
binding = nsxv_models.NsxvLbaasMonitorBinding(
|
||||||
loadbalancer_id=loadbalancer_id,
|
loadbalancer_id=loadbalancer_id,
|
||||||
listener_id=listener_id,
|
|
||||||
pool_id=pool_id,
|
pool_id=pool_id,
|
||||||
hm_id=hm_id,
|
hm_id=hm_id,
|
||||||
edge_id=edge_id,
|
edge_id=edge_id,
|
||||||
@ -723,13 +717,12 @@ def add_nsxv_lbaas_monitor_binding(session, loadbalancer_id, listener_id,
|
|||||||
return binding
|
return binding
|
||||||
|
|
||||||
|
|
||||||
def get_nsxv_lbaas_monitor_binding(session, loadbalancer_id, listener_id,
|
def get_nsxv_lbaas_monitor_binding(session, loadbalancer_id, pool_id, hm_id,
|
||||||
pool_id, hm_id, edge_id):
|
edge_id):
|
||||||
try:
|
try:
|
||||||
return session.query(
|
return session.query(
|
||||||
nsxv_models.NsxvLbaasMonitorBinding).filter_by(
|
nsxv_models.NsxvLbaasMonitorBinding).filter_by(
|
||||||
loadbalancer_id=loadbalancer_id,
|
loadbalancer_id=loadbalancer_id,
|
||||||
listener_id=listener_id,
|
|
||||||
pool_id=pool_id,
|
pool_id=pool_id,
|
||||||
hm_id=hm_id,
|
hm_id=hm_id,
|
||||||
edge_id=edge_id).one()
|
edge_id=edge_id).one()
|
||||||
@ -737,11 +730,10 @@ def get_nsxv_lbaas_monitor_binding(session, loadbalancer_id, listener_id,
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def del_nsxv_lbaas_monitor_binding(session, loadbalancer_id, listener_id,
|
def del_nsxv_lbaas_monitor_binding(session, loadbalancer_id, pool_id, hm_id,
|
||||||
pool_id, hm_id, edge_id):
|
edge_id):
|
||||||
return (session.query(nsxv_models.NsxvLbaasMonitorBinding).
|
return (session.query(nsxv_models.NsxvLbaasMonitorBinding).
|
||||||
filter_by(loadbalancer_id=loadbalancer_id,
|
filter_by(loadbalancer_id=loadbalancer_id,
|
||||||
listener_id=listener_id,
|
|
||||||
pool_id=pool_id,
|
pool_id=pool_id,
|
||||||
hm_id=hm_id,
|
hm_id=hm_id,
|
||||||
edge_id=edge_id).delete())
|
edge_id=edge_id).delete())
|
||||||
|
@ -298,7 +298,6 @@ class NsxvLbaasPoolBinding(model_base.BASEV2, models.TimestampMixin):
|
|||||||
__tablename__ = 'nsxv_lbaas_pool_bindings'
|
__tablename__ = 'nsxv_lbaas_pool_bindings'
|
||||||
|
|
||||||
loadbalancer_id = sa.Column(sa.String(36), primary_key=True)
|
loadbalancer_id = sa.Column(sa.String(36), primary_key=True)
|
||||||
listener_id = sa.Column(sa.String(36), primary_key=True)
|
|
||||||
pool_id = sa.Column(sa.String(36),
|
pool_id = sa.Column(sa.String(36),
|
||||||
sa.ForeignKey('lbaas_pools.id',
|
sa.ForeignKey('lbaas_pools.id',
|
||||||
name='fk_lbaas_pools_id',
|
name='fk_lbaas_pools_id',
|
||||||
@ -313,7 +312,6 @@ class NsxvLbaasMonitorBinding(model_base.BASEV2, models.TimestampMixin):
|
|||||||
__tablename__ = 'nsxv_lbaas_monitor_bindings'
|
__tablename__ = 'nsxv_lbaas_monitor_bindings'
|
||||||
|
|
||||||
loadbalancer_id = sa.Column(sa.String(36), primary_key=True)
|
loadbalancer_id = sa.Column(sa.String(36), primary_key=True)
|
||||||
listener_id = sa.Column(sa.String(36), primary_key=True)
|
|
||||||
pool_id = sa.Column(sa.String(36), primary_key=True)
|
pool_id = sa.Column(sa.String(36), primary_key=True)
|
||||||
hm_id = sa.Column(sa.String(36),
|
hm_id = sa.Column(sa.String(36),
|
||||||
sa.ForeignKey('lbaas_healthmonitors.id',
|
sa.ForeignKey('lbaas_healthmonitors.id',
|
||||||
|
@ -55,18 +55,17 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
def create(self, context, hm):
|
def create(self, context, hm):
|
||||||
listener = hm.pool.listener
|
lb_id = hm.pool.loadbalancer_id
|
||||||
lb_id = listener.loadbalancer_id
|
|
||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, listener.id, hm.pool.id)
|
context.session, lb_id, hm.pool.id)
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
edge_pool_id = pool_binding['edge_pool_id']
|
edge_pool_id = pool_binding['edge_pool_id']
|
||||||
|
|
||||||
hm_binding = nsxv_db.get_nsxv_lbaas_monitor_binding(
|
hm_binding = nsxv_db.get_nsxv_lbaas_monitor_binding(
|
||||||
context.session, lb_id, listener.id, hm.pool.id, hm.id, edge_id)
|
context.session, lb_id, hm.pool.id, hm.id, edge_id)
|
||||||
edge_mon_id = None
|
edge_mon_id = None
|
||||||
|
|
||||||
if hm_binding:
|
if hm_binding:
|
||||||
@ -80,8 +79,8 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
edge_mon_id = lb_common.extract_resource_id(h['location'])
|
edge_mon_id = lb_common.extract_resource_id(h['location'])
|
||||||
|
|
||||||
nsxv_db.add_nsxv_lbaas_monitor_binding(
|
nsxv_db.add_nsxv_lbaas_monitor_binding(
|
||||||
context.session, lb_id, listener.id, hm.pool.id, hm.id,
|
context.session, lb_id, hm.pool.id, hm.id, edge_id,
|
||||||
edge_id, edge_mon_id)
|
edge_mon_id)
|
||||||
|
|
||||||
except nsxv_exc.VcnsApiException:
|
except nsxv_exc.VcnsApiException:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
@ -112,16 +111,14 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
def update(self, context, old_hm, new_hm):
|
def update(self, context, old_hm, new_hm):
|
||||||
listener = new_hm.pool.listener
|
lb_id = new_hm.pool.loadbalancer_id
|
||||||
lb_id = listener.loadbalancer_id
|
|
||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
|
|
||||||
hm_binding = nsxv_db.get_nsxv_lbaas_monitor_binding(
|
hm_binding = nsxv_db.get_nsxv_lbaas_monitor_binding(
|
||||||
context.session, lb_id, listener.id, new_hm.pool.id, new_hm.id,
|
context.session, lb_id, new_hm.pool.id, new_hm.id, edge_id)
|
||||||
edge_id)
|
|
||||||
|
|
||||||
edge_monitor = self._convert_lbaas_monitor(new_hm)
|
edge_monitor = self._convert_lbaas_monitor(new_hm)
|
||||||
|
|
||||||
@ -142,18 +139,17 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
def delete(self, context, hm):
|
def delete(self, context, hm):
|
||||||
listener = hm.pool.listener
|
lb_id = hm.pool.loadbalancer_id
|
||||||
lb_id = listener.loadbalancer_id
|
|
||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, listener.id, hm.pool.id)
|
context.session, lb_id, hm.pool.id)
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
edge_pool_id = pool_binding['edge_pool_id']
|
edge_pool_id = pool_binding['edge_pool_id']
|
||||||
|
|
||||||
hm_binding = nsxv_db.get_nsxv_lbaas_monitor_binding(
|
hm_binding = nsxv_db.get_nsxv_lbaas_monitor_binding(
|
||||||
context.session, lb_id, listener.id, hm.pool.id, hm.id, edge_id)
|
context.session, lb_id, hm.pool.id, hm.id, edge_id)
|
||||||
|
|
||||||
edge_pool = self.vcns.get_pool(edge_id, edge_pool_id)[1]
|
edge_pool = self.vcns.get_pool(edge_id, edge_pool_id)[1]
|
||||||
edge_pool['monitorId'].remove(hm_binding['edge_mon_id'])
|
edge_pool['monitorId'].remove(hm_binding['edge_mon_id'])
|
||||||
@ -182,6 +178,6 @@ class EdgeHealthMonitorManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
_LE('Failed to delete monitor on edge: %s'), edge_id)
|
_LE('Failed to delete monitor on edge: %s'), edge_id)
|
||||||
|
|
||||||
nsxv_db.del_nsxv_lbaas_monitor_binding(
|
nsxv_db.del_nsxv_lbaas_monitor_binding(
|
||||||
context.session, lb_id, listener.id, hm.pool.id, hm.id, edge_id)
|
context.session, lb_id, hm.pool.id, hm.id, edge_id)
|
||||||
self.lbv2_driver.health_monitor.successful_completion(
|
self.lbv2_driver.health_monitor.successful_completion(
|
||||||
context, hm, delete=True)
|
context, hm, delete=True)
|
||||||
|
@ -50,23 +50,23 @@ def listener_to_edge_app_profile(listener, edge_cert_id):
|
|||||||
edge_app_profile['sslPassthrough'] = True
|
edge_app_profile['sslPassthrough'] = True
|
||||||
|
|
||||||
if listener.default_pool:
|
if listener.default_pool:
|
||||||
persistence = None
|
if listener.default_pool.sessionpersistence:
|
||||||
if listener.pool.sessionpersistence:
|
|
||||||
persistence = {
|
persistence = {
|
||||||
'method':
|
'method':
|
||||||
lb_const.SESSION_PERSISTENCE_METHOD_MAP.get(
|
lb_const.SESSION_PERSISTENCE_METHOD_MAP.get(
|
||||||
listener.pool.sessionpersistence.type)}
|
listener.default_pool.sessionpersistence.type)}
|
||||||
|
|
||||||
if (listener.pool.sessionpersistence.type in
|
if (listener.default_pool.sessionpersistence.type in
|
||||||
lb_const.SESSION_PERSISTENCE_COOKIE_MAP):
|
lb_const.SESSION_PERSISTENCE_COOKIE_MAP):
|
||||||
persistence.update({
|
persistence.update({
|
||||||
'cookieName': getattr(listener.pool.sessionpersistence,
|
'cookieName': getattr(
|
||||||
'cookie_name',
|
listener.default_pool.sessionpersistence,
|
||||||
'default_cookie_name'),
|
'cookie_name',
|
||||||
'cookieMode': lb_const.SESSION_PERSISTENCE_COOKIE_MAP[
|
'default_cookie_name'),
|
||||||
listener.pool.sessionpersistence.type]})
|
'cookieMode': lb_const.SESSION_PERSISTENCE_COOKIE_MAP[
|
||||||
|
listener.default_pool.sessionpersistence.type]})
|
||||||
|
|
||||||
edge_app_profile['persistence'] = persistence
|
edge_app_profile['persistence'] = persistence
|
||||||
|
|
||||||
return edge_app_profile
|
return edge_app_profile
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ class EdgeListenerManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
|
|
||||||
if listener.default_pool and listener.default_pool.id:
|
if listener.default_pool and listener.default_pool.id:
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, listener.id, listener.default_pool.id)
|
context.session, lb_id, listener.default_pool.id)
|
||||||
if pool_binding:
|
if pool_binding:
|
||||||
default_pool = pool_binding['edge_pool_id']
|
default_pool = pool_binding['edge_pool_id']
|
||||||
|
|
||||||
@ -183,9 +183,13 @@ class EdgeListenerManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
default_pool = None
|
default_pool = None
|
||||||
if new_listener.default_pool and new_listener.default_pool.id:
|
if new_listener.default_pool and new_listener.default_pool.id:
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, new_listener.default_pool.id, None, None)
|
context.session, new_listener.loadbalancer_id,
|
||||||
|
new_listener.default_pool.id)
|
||||||
if pool_binding:
|
if pool_binding:
|
||||||
default_pool = pool_binding['edge_pool_id']
|
default_pool = pool_binding['edge_pool_id']
|
||||||
|
else:
|
||||||
|
LOG.error(_LE("Couldn't find pool binding for pool %s"),
|
||||||
|
new_listener.default_pool.id)
|
||||||
|
|
||||||
lb_id = new_listener.loadbalancer_id
|
lb_id = new_listener.loadbalancer_id
|
||||||
listener_binding = nsxv_db.get_nsxv_lbaas_listener_binding(
|
listener_binding = nsxv_db.get_nsxv_lbaas_listener_binding(
|
||||||
|
@ -53,7 +53,7 @@ class EdgeMemberManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, listener.id, member.pool_id)
|
context.session, lb_id, member.pool_id)
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
edge_pool_id = pool_binding['edge_pool_id']
|
edge_pool_id = pool_binding['edge_pool_id']
|
||||||
@ -98,7 +98,7 @@ class EdgeMemberManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(context.session,
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(context.session,
|
||||||
lb_id, listener.id,
|
lb_id,
|
||||||
new_member.pool_id)
|
new_member.pool_id)
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
@ -147,7 +147,7 @@ class EdgeMemberManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, listener.id, member.pool_id)
|
context.session, lb_id, member.pool_id)
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
edge_pool_id = pool_binding['edge_pool_id']
|
edge_pool_id = pool_binding['edge_pool_id']
|
||||||
|
@ -45,12 +45,9 @@ class EdgePoolManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
'transparent': False
|
'transparent': False
|
||||||
}
|
}
|
||||||
|
|
||||||
listener = pool.listener
|
lb_id = pool.loadbalancer_id
|
||||||
lb_id = listener.loadbalancer_id
|
|
||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
listener_binding = nsxv_db.get_nsxv_lbaas_listener_binding(
|
|
||||||
context.session, lb_id, listener.id)
|
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
|
|
||||||
@ -59,18 +56,21 @@ class EdgePoolManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
h = self.vcns.create_pool(edge_id, edge_pool)[0]
|
h = self.vcns.create_pool(edge_id, edge_pool)[0]
|
||||||
edge_pool_id = lb_common.extract_resource_id(h['location'])
|
edge_pool_id = lb_common.extract_resource_id(h['location'])
|
||||||
nsxv_db.add_nsxv_lbaas_pool_binding(context.session, lb_id,
|
nsxv_db.add_nsxv_lbaas_pool_binding(context.session, lb_id,
|
||||||
listener.id,
|
|
||||||
pool.id,
|
pool.id,
|
||||||
edge_pool_id)
|
edge_pool_id)
|
||||||
|
|
||||||
# Associate listener with pool
|
if pool.listener:
|
||||||
vse = listener_mgr.listener_to_edge_vse(
|
listener_binding = nsxv_db.get_nsxv_lbaas_listener_binding(
|
||||||
listener,
|
context.session, lb_id, pool.listener.id)
|
||||||
lb_binding['vip_address'],
|
# Associate listener with pool
|
||||||
edge_pool_id,
|
vse = listener_mgr.listener_to_edge_vse(
|
||||||
listener_binding['app_profile_id'])
|
pool.listener,
|
||||||
with locking.LockManager.get_lock(edge_id):
|
lb_binding['vip_address'],
|
||||||
self.vcns.update_vip(edge_id, listener_binding['vse_id'], vse)
|
edge_pool_id,
|
||||||
|
listener_binding['app_profile_id'])
|
||||||
|
with locking.LockManager.get_lock(edge_id):
|
||||||
|
self.vcns.update_vip(edge_id, listener_binding['vse_id'],
|
||||||
|
vse)
|
||||||
|
|
||||||
self.lbv2_driver.pool.successful_completion(context, pool)
|
self.lbv2_driver.pool.successful_completion(context, pool)
|
||||||
|
|
||||||
@ -90,12 +90,16 @@ class EdgePoolManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
'transparent': False
|
'transparent': False
|
||||||
}
|
}
|
||||||
|
|
||||||
listener = new_pool.listener
|
if new_pool.listener:
|
||||||
lb_id = listener.loadbalancer_id
|
listener = new_pool.listener
|
||||||
|
lb_id = listener.loadbalancer_id
|
||||||
|
else:
|
||||||
|
lb_id = new_pool.loadbalancer_id
|
||||||
|
|
||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, listener.id, new_pool.id)
|
context.session, lb_id, new_pool.id)
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
edge_pool_id = pool_binding['edge_pool_id']
|
edge_pool_id = pool_binding['edge_pool_id']
|
||||||
@ -113,31 +117,34 @@ class EdgePoolManager(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
def delete(self, context, pool):
|
def delete(self, context, pool):
|
||||||
listener = pool.listener
|
lb_id = pool.loadbalancer_id
|
||||||
lb_id = listener.loadbalancer_id
|
|
||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, listener.id, pool.id)
|
context.session, lb_id, pool.id)
|
||||||
listener_binding = nsxv_db.get_nsxv_lbaas_listener_binding(
|
|
||||||
context.session, lb_id, listener.id)
|
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
edge_pool_id = pool_binding['edge_pool_id']
|
edge_pool_id = pool_binding['edge_pool_id']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
vse = listener_mgr.listener_to_edge_vse(
|
if pool.listeners:
|
||||||
listener,
|
for listener in pool.listeners:
|
||||||
lb_binding['vip_address'],
|
listener_binding = nsxv_db.get_nsxv_lbaas_listener_binding(
|
||||||
None,
|
context.session, lb_id, listener.id)
|
||||||
listener_binding['app_profile_id'])
|
vse = listener_mgr.listener_to_edge_vse(
|
||||||
with locking.LockManager.get_lock(edge_id):
|
listener,
|
||||||
self.vcns.update_vip(edge_id, listener_binding['vse_id'], vse)
|
lb_binding['vip_address'],
|
||||||
self.vcns.delete_pool(edge_id, edge_pool_id)
|
None,
|
||||||
|
listener_binding['app_profile_id'])
|
||||||
|
with locking.LockManager.get_lock(edge_id):
|
||||||
|
self.vcns.update_vip(
|
||||||
|
edge_id, listener_binding['vse_id'], vse)
|
||||||
|
self.vcns.delete_pool(edge_id, edge_pool_id)
|
||||||
self.lbv2_driver.pool.successful_completion(
|
self.lbv2_driver.pool.successful_completion(
|
||||||
context, pool, delete=True)
|
context, pool, delete=True)
|
||||||
nsxv_db.del_nsxv_lbaas_pool_binding(
|
nsxv_db.del_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, listener.id, pool.id)
|
context.session, lb_id, pool.id)
|
||||||
except nsxv_exc.VcnsApiException:
|
except nsxv_exc.VcnsApiException:
|
||||||
self.lbv2_driver.pool.failed_completion(context, pool)
|
self.lbv2_driver.pool.failed_completion(context, pool)
|
||||||
LOG.error(_LE('Failed to delete pool %s'), pool['id'])
|
LOG.error(_LE('Failed to delete pool %s'), pool['id'])
|
||||||
|
@ -195,7 +195,6 @@ def _create_v2_nsx_mappings(v1_pool_id, v1_hm_id, v2_pool_id, v2_lb_id,
|
|||||||
nsxv_db.add_nsxv_lbaas_monitor_binding(
|
nsxv_db.add_nsxv_lbaas_monitor_binding(
|
||||||
neutron_db.context.session,
|
neutron_db.context.session,
|
||||||
v2_lb_id,
|
v2_lb_id,
|
||||||
v2_listener_id,
|
|
||||||
v2_pool_id,
|
v2_pool_id,
|
||||||
v2_hm_id,
|
v2_hm_id,
|
||||||
v1_hm_map['edge_id'],
|
v1_hm_map['edge_id'],
|
||||||
@ -209,7 +208,6 @@ def _create_v2_nsx_mappings(v1_pool_id, v1_hm_id, v2_pool_id, v2_lb_id,
|
|||||||
nsxv_db.add_nsxv_lbaas_pool_binding(
|
nsxv_db.add_nsxv_lbaas_pool_binding(
|
||||||
neutron_db.context.session,
|
neutron_db.context.session,
|
||||||
v2_lb_id,
|
v2_lb_id,
|
||||||
v2_listener_id,
|
|
||||||
v2_pool_id,
|
v2_pool_id,
|
||||||
v1_pool_map['edge_pool_id'])
|
v1_pool_map['edge_pool_id'])
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ EDGE_POOL_ID = 'pool-xx'
|
|||||||
EDGE_POOL_DEF = {'transparent': False, 'name': 'pool_' + POOL_ID,
|
EDGE_POOL_DEF = {'transparent': False, 'name': 'pool_' + POOL_ID,
|
||||||
'algorithm': 'round-robin', 'description': ''}
|
'algorithm': 'round-robin', 'description': ''}
|
||||||
POOL_BINDING = {'loadbalancer_id': LB_ID,
|
POOL_BINDING = {'loadbalancer_id': LB_ID,
|
||||||
'listener_id': LISTENER_ID,
|
|
||||||
'pool_id': POOL_ID,
|
'pool_id': POOL_ID,
|
||||||
'edge_pool_id': EDGE_POOL_ID}
|
'edge_pool_id': EDGE_POOL_ID}
|
||||||
MEMBER_ID = 'mmm-mmm'
|
MEMBER_ID = 'mmm-mmm'
|
||||||
@ -68,7 +67,6 @@ EDGE_HM_DEF = {'maxRetries': 1, 'interval': 3, 'type': 'icmp', 'name': HM_ID,
|
|||||||
'timeout': 3}
|
'timeout': 3}
|
||||||
|
|
||||||
HM_BINDING = {'loadbalancer_id': LB_ID,
|
HM_BINDING = {'loadbalancer_id': LB_ID,
|
||||||
'listener_id': LISTENER_ID,
|
|
||||||
'pool_id': POOL_ID,
|
'pool_id': POOL_ID,
|
||||||
'hm_id': HM_ID,
|
'hm_id': HM_ID,
|
||||||
'edge_id': LB_EDGE_ID,
|
'edge_id': LB_EDGE_ID,
|
||||||
@ -101,7 +99,9 @@ class BaseTestEdgeLbaasV2(base.BaseTestCase):
|
|||||||
loadbalancer=self.lb)
|
loadbalancer=self.lb)
|
||||||
self.pool = lb_models.Pool(POOL_ID, LB_TENANT_ID, 'pool-name', '',
|
self.pool = lb_models.Pool(POOL_ID, LB_TENANT_ID, 'pool-name', '',
|
||||||
None, 'HTTP', 'ROUND_ROBIN',
|
None, 'HTTP', 'ROUND_ROBIN',
|
||||||
listener=self.listener)
|
loadbalancer_id=LB_ID,
|
||||||
|
listener=self.listener,
|
||||||
|
listeners=[self.listener])
|
||||||
self.member = lb_models.Member(MEMBER_ID, LB_TENANT_ID, POOL_ID,
|
self.member = lb_models.Member(MEMBER_ID, LB_TENANT_ID, POOL_ID,
|
||||||
MEMBER_ADDRESS, 80, 1, pool=self.pool)
|
MEMBER_ADDRESS, 80, 1, pool=self.pool)
|
||||||
self.hm = lb_models.HealthMonitor(HM_ID, LB_TENANT_ID, 'PING', 3, 3,
|
self.hm = lb_models.HealthMonitor(HM_ID, LB_TENANT_ID, 'PING', 3, 3,
|
||||||
@ -340,8 +340,7 @@ class TestEdgeLbaasV2Pool(BaseTestEdgeLbaasV2):
|
|||||||
mock_create_pool.assert_called_with(LB_EDGE_ID,
|
mock_create_pool.assert_called_with(LB_EDGE_ID,
|
||||||
EDGE_POOL_DEF.copy())
|
EDGE_POOL_DEF.copy())
|
||||||
mock_add_binding.assert_called_with(self.context.session,
|
mock_add_binding.assert_called_with(self.context.session,
|
||||||
LB_ID, LISTENER_ID, POOL_ID,
|
LB_ID, POOL_ID, EDGE_POOL_ID)
|
||||||
EDGE_POOL_ID)
|
|
||||||
edge_vip_def = EDGE_VIP_DEF.copy()
|
edge_vip_def = EDGE_VIP_DEF.copy()
|
||||||
edge_vip_def['defaultPoolId'] = EDGE_POOL_ID
|
edge_vip_def['defaultPoolId'] = EDGE_POOL_ID
|
||||||
mock_upd_vip.assert_called_with(LB_EDGE_ID, EDGE_VIP_ID,
|
mock_upd_vip.assert_called_with(LB_EDGE_ID, EDGE_VIP_ID,
|
||||||
@ -398,7 +397,7 @@ class TestEdgeLbaasV2Pool(BaseTestEdgeLbaasV2):
|
|||||||
EDGE_VIP_DEF)
|
EDGE_VIP_DEF)
|
||||||
mock_del_pool.assert_called_with(LB_EDGE_ID, EDGE_POOL_ID)
|
mock_del_pool.assert_called_with(LB_EDGE_ID, EDGE_POOL_ID)
|
||||||
mock_del_binding.assert_called_with(
|
mock_del_binding.assert_called_with(
|
||||||
self.context.session, LB_ID, LISTENER_ID, POOL_ID)
|
self.context.session, LB_ID, POOL_ID)
|
||||||
mock_successful_completion = (
|
mock_successful_completion = (
|
||||||
self.lbv2_driver.pool.successful_completion)
|
self.lbv2_driver.pool.successful_completion)
|
||||||
mock_successful_completion.assert_called_with(self.context,
|
mock_successful_completion.assert_called_with(self.context,
|
||||||
@ -541,8 +540,8 @@ class TestEdgeLbaasV2HealthMonitor(BaseTestEdgeLbaasV2):
|
|||||||
|
|
||||||
mock_create_hm.assert_called_with(LB_EDGE_ID, EDGE_HM_DEF)
|
mock_create_hm.assert_called_with(LB_EDGE_ID, EDGE_HM_DEF)
|
||||||
mock_add_hm_binding.assert_called_with(
|
mock_add_hm_binding.assert_called_with(
|
||||||
self.context.session, LB_ID, LISTENER_ID, POOL_ID, HM_ID,
|
self.context.session, LB_ID, POOL_ID, HM_ID, LB_EDGE_ID,
|
||||||
LB_EDGE_ID, EDGE_HM_ID)
|
EDGE_HM_ID)
|
||||||
edge_pool_def = EDGE_POOL_DEF.copy()
|
edge_pool_def = EDGE_POOL_DEF.copy()
|
||||||
edge_pool_def['monitorId'] = [EDGE_HM_ID]
|
edge_pool_def['monitorId'] = [EDGE_HM_ID]
|
||||||
mock_update_pool.assert_called_with(
|
mock_update_pool.assert_called_with(
|
||||||
@ -610,8 +609,7 @@ class TestEdgeLbaasV2HealthMonitor(BaseTestEdgeLbaasV2):
|
|||||||
mock_update_pool.assert_called_with(
|
mock_update_pool.assert_called_with(
|
||||||
LB_EDGE_ID, EDGE_POOL_ID, edge_pool_def)
|
LB_EDGE_ID, EDGE_POOL_ID, edge_pool_def)
|
||||||
mock_del_binding.assert_called_with(self.context.session, LB_ID,
|
mock_del_binding.assert_called_with(self.context.session, LB_ID,
|
||||||
LISTENER_ID, POOL_ID, HM_ID,
|
POOL_ID, HM_ID, LB_EDGE_ID)
|
||||||
LB_EDGE_ID)
|
|
||||||
mock_successful_completion = (
|
mock_successful_completion = (
|
||||||
self.lbv2_driver.health_monitor.successful_completion)
|
self.lbv2_driver.health_monitor.successful_completion)
|
||||||
mock_successful_completion.assert_called_with(self.context,
|
mock_successful_completion.assert_called_with(self.context,
|
||||||
|
Loading…
Reference in New Issue
Block a user