[autotest] Support uploading a service key file to moblab
Add RPC to accept an uploaded key file and save it to
/home/moblab/.launch_control_key
Add a new tab in moblab setup page to allow user to upload a service key file.
BUG=chromium:570705
TEST=verify with a local moblab build
Change-Id: Ib54a6b707cb93bb5220e29ed6feeb854f5f4abe8
Reviewed-on: https://chromium-review.googlesource.com/321140
Commit-Ready: Dan Shi <dshi@google.com>
Tested-by: Dan Shi <dshi@google.com>
Reviewed-by: Simran Basi <sbasi@chromium.org>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index a7cb19a..e0a7e0a 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -325,6 +325,22 @@
shutil.copyfile(boto_key, moblab_host.MOBLAB_BOTO_LOCATION)
+@moblab_only
+def set_launch_control_key(launch_control_key):
+ """Update the launch_control_key file.
+
+ @param launch_control_key: File name of launch_control_key uploaded through
+ handle_file_upload.
+ """
+ if not os.path.exists(launch_control_key):
+ raise error.RPCException('Launch Control key: %s does not exist!' %
+ launch_control_key)
+ shutil.copyfile(launch_control_key,
+ moblab_host.MOBLAB_LAUNCH_CONTROL_KEY_LOCATION)
+ # Restart the devserver service.
+ os.system('sudo restart moblab-devserver-init')
+
+
def get_job_history(**filter_data):
"""Get history of the job, including the special tasks executed for the job