blob: 6328811c860982f5f8ec91445a134b9b81628fec [file] [log] [blame]
Mike Frysingerd03e6b52019-08-03 12:49:01 -04001#!/usr/bin/python2
Xixuan Wu94388e52019-04-10 14:38:58 -07002
3"""
4Fetch credentials used by lab tools from Google storage.
5
6Usage? Just run it.
7 utils/download_creds.py
8"""
9
10import os
11import sys
12
13import common
14from chromite.lib import gs
15from chromite.lib import osutils
16
17from autotest_lib.utils import external_packages
18
19
20CRED_DIR = 'creds'
21RUN_SUITE_SERVICE_ACCOUNT = (
22 'gs://chromeos-proxy.appspot.com/skylab-trampoline.json')
23
24def _fetch_run_suite_creds(ctx, creds_dir):
25 """Download creds for labtools run_suites.
26
27 Args:
28 ctx: A gs.GSContext object.
29 creds_dir: A string path.
30 """
31 cred_file = os.path.join(creds_dir,
32 'skylab_trampoline_service_account.json')
33 ctx.Copy(RUN_SUITE_SERVICE_ACCOUNT, cred_file)
34
35
36def main():
37 """Download credentials."""
38 autotest_dir = external_packages.find_top_of_autotest_tree()
39 creds_dir = os.path.join(autotest_dir, CRED_DIR)
40 osutils.SafeMakedirs(creds_dir)
41 ctx = gs.GSContext()
42 _fetch_run_suite_creds(ctx, creds_dir)
43
44
45if __name__ == '__main__':
46 sys.exit(main())