Prevent creating jobs via the frontend directly on hosts in an atomic group
if the atomic group was not requested for that job.
Signed-off-by: Gregory Smith <gps@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3017 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index 9842c94..8d25a20 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -422,6 +422,17 @@
{'hosts':
'only %d hosts provided for job with synch_count = %d' %
(len(all_host_objects), synch_count)})
+ atomic_hosts = models.Host.objects.filter(
+ id__in=[host.id for host in host_objects],
+ labels__atomic_group=True)
+ unusable_host_names = [host.hostname for host in atomic_hosts]
+ if unusable_host_names:
+ raise model_logic.ValidationError(
+ {'hosts':
+ 'Host(s) "%s" are atomic group hosts but no '
+ 'atomic group was specified for this job.' %
+ (', '.join(unusable_host_names),)})
+
rpc_utils.check_job_dependencies(host_objects, dependencies)
dependency_labels = [labels_by_name[label_name]