Autotest: Make autotest call the new devserver API list_suite_controls

Related to CL:338931, this CL is to change the code in autotest to call
the API: list_suite_controls, to get the control contents of all control
files in one call to devserver.

BUG=chromium:602562
TEST=Ran dev_server_unittest, control_file_getter_unittest,
suite_unittest.py, site_rpc_interface_unittest for
ENABLE_CONTROLS_IN_BATCH=False/True;
Ran test_suite:dummy in local autotest instance using local devserver
for ENABLE_CONTROLS_IN_BATCH=False/True.

Change-Id: I075fad07b79827a5d78b7de371bba845fcdf09b1
Reviewed-on: https://chromium-review.googlesource.com/339480
Commit-Ready: Dan Shi <dshi@google.com>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index 7947b9e..77d4204 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -36,6 +36,7 @@
 from autotest_lib.server.cros.dynamic_suite import constants
 from autotest_lib.server.cros.dynamic_suite import control_file_getter
 from autotest_lib.server.cros.dynamic_suite import tools
+from autotest_lib.server.cros.dynamic_suite import suite as SuiteBase
 from autotest_lib.server.cros.dynamic_suite.suite import Suite
 from autotest_lib.server.hosts import moblab_host
 from autotest_lib.site_utils import host_history
@@ -59,8 +60,6 @@
 _GS_SECRETE_ACCESS_KEY = 'gs_secret_access_key'
 _IMAGE_STORAGE_SERVER = 'image_storage_server'
 _RESULT_STORAGE_SERVER = 'results_storage_server'
-
-
 # Relevant CrosDynamicSuiteExceptions are defined in client/common_lib/error.py.
 
 
@@ -1004,14 +1003,21 @@
 
     # Collect the control files specified in this build
     cfile_getter = control_file_getter.DevServerGetter.create(build, ds)
-    control_file_list = cfile_getter.get_control_file_list()
+    if SuiteBase.ENABLE_CONTROLS_IN_BATCH:
+        control_file_info_list = cfile_getter.get_suite_info()
+        control_file_list = control_file_info_list.keys()
+    else:
+        control_file_list = cfile_getter.get_control_file_list()
 
     test_objects = []
     _id = 0
     for control_file_path in control_file_list:
         # Read and parse the control file
-        control_file = cfile_getter.get_control_file_contents(
-                control_file_path)
+        if SuiteBase.ENABLE_CONTROLS_IN_BATCH:
+            control_file = control_file_info_list[control_file_path]
+        else:
+            control_file = cfile_getter.get_control_file_contents(
+                    control_file_path)
         try:
             control_obj = control_data.parse_control_string(control_file)
         except: