NSXv: Place LB only on tenant's router

When LBaaS selects an Edge appliance to host a load balancer, it should
lookup only ports which belong to the specifig tenant who creates the
load balancer.

Change-Id: I3d489f88b9506abe1c6604c5704e8e718c93c582
This commit is contained in:
Kobi Samoray 2016-02-14 17:31:22 +02:00
parent 8d4385173e
commit 37939d8c3e
3 changed files with 6 additions and 4 deletions

View File

@ -31,14 +31,15 @@ def get_member_id(member_id):
return MEMBER_ID_PFX + member_id
def get_lbaas_edge_id_for_subnet(context, plugin, subnet_id):
def get_lbaas_edge_id_for_subnet(context, plugin, subnet_id, tenant_id):
"""
Grab the id of an Edge appliance that is connected to subnet_id.
"""
subnet = plugin.get_subnet(context, subnet_id)
net_id = subnet.get('network_id')
filters = {'network_id': [net_id],
'device_owner': ['network:router_interface']}
'device_owner': ['network:router_interface'],
'tenant_id': [tenant_id]}
attached_routers = plugin.get_ports(context.elevated(),
filters=filters,
fields=['device_id'])

View File

@ -180,7 +180,8 @@ class EdgeLbDriver(object):
def create_pool(self, context, pool):
LOG.debug('Creating pool %s', pool)
edge_id = lb_common.get_lbaas_edge_id_for_subnet(
context, self.callbacks.plugin, pool['subnet_id'])
context, self.callbacks.plugin, pool['subnet_id'],
pool['tenant_id'])
if edge_id is None:
self.lbv1_driver.pool_failed(context, pool)

View File

@ -35,7 +35,7 @@ class EdgeLoadBalancerManager(base_mgr.EdgeLoadbalancerBaseManager):
def create(self, context, lb):
try:
edge_id = lb_common.get_lbaas_edge_id_for_subnet(
context, self.core_plugin, lb.vip_subnet_id)
context, self.core_plugin, lb.vip_subnet_id, lb.tenant_id)
if not nsxv_db.get_nsxv_lbaas_loadbalancer_binding_by_edge(
context.session, edge_id):