-support filtering on multiple labels
-fix problem mostly related to history handling that was causing unnecessary RPCs to be executed
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1414 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index 8c3366d..0764272 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -53,6 +53,20 @@
return {'where': where}
+def extra_host_filters(multiple_labels=[]):
+ """\
+ Generate SQL WHERE clauses for matching hosts in an intersection of
+ labels.
+ """
+ extra_args = {}
+ where_str = ('hosts.id in (select host_id from hosts_labels '
+ 'where label_id=%s)')
+ extra_args['where'] = [where_str] * len(multiple_labels)
+ extra_args['params'] = [models.Label.smart_get(label).id
+ for label in multiple_labels]
+ return extra_args
+
+
local_vars = threading.local()
def set_user(user):
@@ -121,3 +135,9 @@
id_set.add(obj['id'])
result.append(obj)
return result
+
+
+def sorted(in_list):
+ new_list = list(in_list)
+ new_list.sort()
+ return new_list