Allow the RPC interface to create jobs in an atomic group without
requiring any meta_hosts or hosts to be specified.

Signed-off-by: Gregory Smith <gps@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@2985 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index f08eb99..f520f38 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -269,12 +269,17 @@
         hosts_in_label = (h.hostname for h in label.host_set.all())
         possible_hosts.intersection_update(hosts_in_label)
 
-    host_set = set(host.hostname for host in host_objects)
-    unusable_host_set = host_set.difference(possible_hosts)
-    if unusable_host_set:
-        raise model_logic.ValidationError(
-            {'hosts': 'Hosts "%s" are not in Atomic Group "%s"' %
-             (', '.join(sorted(unusable_host_set)), atomic_group.name)})
+    if not host_objects and not metahost_objects:
+        # No hosts or metahosts are required to queue an atomic group Job.
+        # However, if they are given, we respect them below.
+        host_set = possible_hosts
+    else:
+        host_set = set(host.hostname for host in host_objects)
+        unusable_host_set = host_set.difference(possible_hosts)
+        if unusable_host_set:
+            raise model_logic.ValidationError(
+                {'hosts': 'Hosts "%s" are not in Atomic Group "%s"' %
+                 (', '.join(sorted(unusable_host_set)), atomic_group.name)})
 
     # Lookup hosts provided by each meta host and merge them into the
     # host_set for final counting.