Commit 5470313f authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Do not prefetch related in get()

parent 1ad655cd
......@@ -164,7 +164,7 @@ def create_subnet(request):
def get_subnet(request, sub_id):
"""Show info of a specific subnet"""
user_id = request.user_uniq
subnet = subnets.get_subnet(sub_id, prefetch_related=True)
subnet = subnets.get_subnet(sub_id)
if ( != user_id) and ( is False):
raise api.faults.Unauthorized("You're not allowed to view this subnet")
......@@ -222,7 +222,7 @@ def get_network(network_id, user_id, for_update=False, non_deleted=False):
network_id = int(network_id)
objects = Network.objects.prefetch_related("subnets")
objects = Network.objects
if for_update:
objects = objects.select_for_update()
network = objects.get(Q(userid=user_id) | Q(public=True),
......@@ -148,14 +148,11 @@ def _create_subnet(network_id, user_id, cidr, name, ipversion=4, gateway=None,
return sub
def get_subnet(sub_id, prefetch_related=False):
def get_subnet(sub_id):
"""Show info of a specific subnet"""
log.debug('get_subnet %s', sub_id)
subnets = Subnet.objects
if prefetch_related:
subnets = subnets.select_related("network")
subnets = subnets.prefetch_related("ip_pools")
return subnets.get(id=sub_id)
except Subnet.DoesNotExist:
raise api.faults.ItemNotFound("Subnet not found")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment