Adds UI to upload all Moblab credentials files.
BUG=chromium:658462
TEST=manual.
Change-Id: I53fff080f524c8cb793911227d18125e45da00fd
Reviewed-on: https://chromium-review.googlesource.com/401282
Reviewed-by: Keith Haddow <[email protected]>
Reviewed-by: Michael Tang <[email protected]>
Commit-Queue: Michael Tang <[email protected]>
Tested-by: Michael Tang <[email protected]>
Trybot-Ready: Michael Tang <[email protected]>
diff --git a/frontend/afe/moblab_rpc_interface.py b/frontend/afe/moblab_rpc_interface.py
index f0ec8e3..9aabcb6 100644
--- a/frontend/afe/moblab_rpc_interface.py
+++ b/frontend/afe/moblab_rpc_interface.py
@@ -26,7 +26,7 @@
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib import global_config
-from autotest_lib.frontend.afe import models, model_logic, model_attributes
+from autotest_lib.frontend.afe import models
from autotest_lib.frontend.afe import rpc_utils
from autotest_lib.server.hosts import moblab_host
@@ -194,6 +194,22 @@
@rpc_utils.moblab_only
+def set_service_account_credential(service_account_filename):
+ """Update the service account credential file.
+
+ @param service_account_filename: Name of uploaded file through
+ handle_file_upload.
+ """
+ if not os.path.exists(service_account_filename):
+ raise error.RPCException(
+ 'Service account file: %s does not exist!' %
+ service_account_filename)
+ shutil.copyfile(
+ service_account_filename,
+ moblab_host.MOBLAB_SERVICE_ACCOUNT_LOCATION)
+
+
+@rpc_utils.moblab_only
def set_launch_control_key(launch_control_key):
"""Update the launch_control_key file.
@@ -520,6 +536,8 @@
def add_moblab_dut(ipaddress):
""" RPC handler to add a connected DUT to autotest.
+ @param ipaddress: IP address of the DUT.
+
@return: A string giving information about the status.
"""
cmd = '/usr/local/autotest/cli/atest host create %s &' % ipaddress
@@ -531,6 +549,8 @@
def remove_moblab_dut(ipaddress):
""" RPC handler to remove DUT entry from autotest.
+ @param ipaddress: IP address of the DUT.
+
@return: True if the command succeeds without an exception
"""
models.Host.smart_get(ipaddress).delete()
@@ -541,6 +561,9 @@
def add_moblab_label(ipaddress, label_name):
""" RPC handler to add a label in autotest to a DUT entry.
+ @param ipaddress: IP address of the DUT.
+ @param label_name: The label name.
+
@return: A string giving information about the status.
"""
# Try to create the label in case it does not already exist.
@@ -560,6 +583,9 @@
def remove_moblab_label(ipaddress, label_name):
""" RPC handler to remove a label in autotest from a DUT entry.
+ @param ipaddress: IP address of the DUT.
+ @param label_name: The label name.
+
@return: A string giving information about the status.
"""
host_obj = models.Host.smart_get(ipaddress)