From 37939d8c3e8d7d0488ce0c6486d42b4df74b8f60 Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Sun, 14 Feb 2016 17:31:22 +0200 Subject: [PATCH] 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 --- vmware_nsx/services/lbaas/nsx_v/lbaas_common.py | 5 +++-- .../services/lbaas/nsx_v/v1/edge_loadbalancer_driver.py | 3 ++- vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/services/lbaas/nsx_v/lbaas_common.py b/vmware_nsx/services/lbaas/nsx_v/lbaas_common.py index 13a30368e7..0437087bd7 100644 --- a/vmware_nsx/services/lbaas/nsx_v/lbaas_common.py +++ b/vmware_nsx/services/lbaas/nsx_v/lbaas_common.py @@ -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']) diff --git a/vmware_nsx/services/lbaas/nsx_v/v1/edge_loadbalancer_driver.py b/vmware_nsx/services/lbaas/nsx_v/v1/edge_loadbalancer_driver.py index b2a85a0c70..271cfd30c5 100644 --- a/vmware_nsx/services/lbaas/nsx_v/v1/edge_loadbalancer_driver.py +++ b/vmware_nsx/services/lbaas/nsx_v/v1/edge_loadbalancer_driver.py @@ -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) diff --git a/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py b/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py index b9bd39c2d0..360f0be0c2 100644 --- a/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py @@ -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):