John A Meinel has proposed merging lp:~jameinel/maas/stripped-nodes into
lp:maas.
Commit message:
Improve the performance of nodegroups/$UUID/?op=list-nodes
Tell Django that we only care about the system_id column (which is true). This
cuts out a full second of clock time from the api. Best guess is that it is
because we are avoiding reading the hardware_details content. It doesn't hurt
to filter out the other stuff as well, though.
Also, change the APIs to be accessible to admins (superusers). We allow that
for other apis, and it makes it much easier to test their performance, because
you can poke at it from maascli instead of having to trigger a worker request.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jameinel/maas/stripped-nodes/+merge/128916
--
https://code.launchpad.net/~jameinel/maas/stripped-nodes/+merge/128916
Your team Launchpad code reviewers is requested to review the proposed merge of
lp:~jameinel/maas/stripped-nodes into lp:maas.
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py 2012-10-10 08:30:51 +0000
+++ src/maasserver/api.py 2012-10-10 11:56:00 +0000
@@ -1178,9 +1178,10 @@
def list_nodes(self, request, uuid):
"""Get the list of node ids that are part of this group."""
nodegroup = get_object_or_404(NodeGroup, uuid=uuid)
- check_nodegroup_access(request, nodegroup)
- return [node.system_id
- for node in Node.objects.filter(nodegroup=nodegroup)]
+ if not request.user.is_superuser:
+ check_nodegroup_access(request, nodegroup)
+ nodes = Node.objects.filter(nodegroup=nodegroup).only('system_id')
+ return [node.system_id for node in nodes]
# node_hardware_details is actually idempotent, however:
# a) We expect to get a list of system_ids which is quite long (~100 ids,
@@ -1206,7 +1207,8 @@
system_ids = get_list_from_dict_or_multidict(
request.data, 'system_ids', [])
nodegroup = get_object_or_404(NodeGroup, uuid=uuid)
- check_nodegroup_access(request, nodegroup)
+ if not request.user.is_superuser:
+ check_nodegroup_access(request, nodegroup)
nodes = Node.objects.filter(
system_id__in=system_ids, nodegroup=nodegroup)
details = [(node.system_id, node.hardware_details) for node in nodes]
_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help : https://help.launchpad.net/ListHelp