Commit 7332ebb7 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Prefetch metadata when listing servers

parent 5881ee1d
......@@ -341,7 +341,7 @@ def list_servers(request, detail=False):
log.debug('list_servers detail=%s', detail)
user_vms = VirtualMachine.objects.filter(userid=request.user_uniq)
if detail:
user_vms = user_vms.prefetch_related("nics__ips")
user_vms = user_vms.prefetch_related("nics__ips", "metadata")
user_vms = utils.filter_modified_since(request, objects=user_vms)
......@@ -426,7 +426,7 @@ def get_server_details(request, server_id):
log.debug('get_server_details %s', server_id)
vm = util.get_vm(server_id, request.user_uniq,
prefetch_related=["nics__ips", "metadata"])
server = vm_to_dict(vm, detail=True)
return render_server(request, server)
......@@ -138,7 +138,10 @@ def get_vm(server_id, user_id, for_update=False, non_deleted=False,
if for_update:
servers = servers.select_for_update()
if prefetch_related is not None:
servers = servers.prefetch_related(prefetch_related)
if isinstance(prefetch_related, list):
servers = servers.prefetch_related(*prefetch_related)
servers = servers.prefetch_related(prefetch_related)
vm = servers.get(id=server_id, userid=user_id)
if non_deleted and vm.deleted:
raise faults.BadRequest("Server has been deleted.")
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