Fix routes disappeared by shared routers with different tenants

When we try to update routes on shared edge with non-admin tenant,
routes belong to other tenants would be disappeared on the edge. The
patch fixed the problem by getting all relative objects with admin
privilege.

Change-Id: I6be20edb11f7d973b9f870aa1e9d2cb0e42ff5a2
This commit is contained in:
linb 2015-06-24 13:32:54 +08:00 committed by Kobi Samoray
parent 2fb6611380
commit 0d8d92d9d5
2 changed files with 5 additions and 3 deletions

View File

@ -1316,10 +1316,12 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
for route in routes:
for port in ports:
for ip in port['fixed_ips']:
subnet = self.get_subnet(context, ip['subnet_id'])
subnet = self.get_subnet(context.elevated(),
ip['subnet_id'])
if netaddr.all_matching_cidrs(
route['nexthop'], [subnet['cidr']]):
net = self.get_network(context, subnet['network_id'])
net = self.get_network(context.elevated(),
subnet['network_id'])
route['network_id'] = net['id']
if net.get(ext_net_extn.EXTERNAL):
route['external'] = True

View File

@ -83,7 +83,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
routes = self.plugin._get_extra_routes_by_router_id(
context, router_id)
filters = {'device_id': [router_id]}
ports = self.plugin.get_ports(context, filters)
ports = self.plugin.get_ports(context.elevated(), filters)
self.plugin._add_network_info_for_routes(context, routes, ports)
all_routes.extend(routes)
if not nexthop: