[autotest] Add more build option in autotest create_job tab for FAFT

Add an Advanced Build Options panel for user to specify:
firmware build (RW), firmware RO build, and test source build.

Then create a suite job from AFE to update both CrOS and firmware.

BUG=chromium:493429
TEST=local test
http://dshi.mtv/afe/#tab_id=create_job
1. check AFE shows the Advanced Build Options panel
2. Confirm the builds specified in the options are used in the sutie job run.
3. Confirm non-suite job can't be created with firmware image specified.
sample cros build: veyron_jerry-release/R45-7201.0.0
sample firmware build: veyron_jerry-firmware/R41-6588.106.0
DEPLOY=afe,apache

Change-Id: I81e1f5f81aaa9dfb5fe7b9f2f3677b8fb437130c
Reviewed-on: https://chromium-review.googlesource.com/281021
Trybot-Ready: Dan Shi <dshi@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index 64e8ca7..1a19802 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -45,6 +45,7 @@
 from autotest_lib.frontend.tko import rpc_interface as tko_rpc_interface
 from autotest_lib.server import frontend
 from autotest_lib.server import utils
+from autotest_lib.server.cros import provision
 from autotest_lib.server.cros.dynamic_suite import tools
 from autotest_lib.site_utils import status_history
 
@@ -779,7 +780,9 @@
 
 
 def create_job_page_handler(name, priority, control_file, control_type,
-                            image=None, hostless=False, **kwargs):
+                            image=None, hostless=False, firmware_rw_build=None,
+                            firmware_ro_build=None, test_source_build=None,
+                            **kwargs):
     """\
     Create and enqueue a job.
 
@@ -787,6 +790,13 @@
     @param priority Integer priority of this job.  Higher is more important.
     @param control_file String contents of the control file.
     @param control_type Type of control file, Client or Server.
+    @param image: ChromeOS build to be installed in the dut. Default to None.
+    @param firmware_rw_build: Firmware build to update RW firmware. Default to
+                              None, i.e., RW firmware will not be updated.
+    @param firmware_ro_build: Firmware build to update RO firmware. Default to
+                              None, i.e., RO firmware will not be updated.
+    @param test_source_build: Build to be used to retrieve test code. Default
+                              to None.
     @param kwargs extra args that will be required by create_suite_job or
                   create_job.
 
@@ -798,9 +808,15 @@
                 'control_file' : "Control file cannot be empty"})
 
     if image and hostless:
+        builds = {}
+        builds[provision.CROS_VERSION_PREFIX] = image
+        if firmware_rw_build:
+            builds[provision.FW_VERSION_PREFIX] = firmware_rw_build
+        if firmware_ro_build:
+            builds[provision.FW_RO_VERSION_PREFIX] = firmware_ro_build
         return site_rpc_interface.create_suite_job(
                 name=name, control_file=control_file, priority=priority,
-                build=image, **kwargs)
+                builds=builds, test_source_build=test_source_build, **kwargs)
     return create_job(name, priority, control_file, control_type, image=image,
                       hostless=hostless, **kwargs)
 
@@ -886,6 +902,8 @@
             test_parameter=image_parameter, parameter_value=image,
             parameter_type='string')
 
+    # TODO(crbug.com/502638): save firmware build etc to parameterized_job.
+
     # By passing a parameterized_job to create_job_common the job entry in
     # the afe_jobs table will have the field parameterized_job_id set.
     # The scheduler uses this id in the afe_parameterized_jobs table to