blob: 925ea9943677cc2dc0a7372d6b4d00ac444c9607 [file] [log] [blame]
xixuanbea010f2017-03-27 10:10:19 -07001# Copyright 2017 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
xixuanbea010f2017-03-27 10:10:19 -07004"""Module for fetching files used by suite scheduler."""
5
Brigit Rossbach50d086f2020-09-17 13:29:49 -06006import logging
xixuanbea010f2017-03-27 10:10:19 -07007import os
Dhanya Ganesh2b29ad12020-09-22 22:18:58 +00008import subprocess
xixuanbea010f2017-03-27 10:10:19 -07009
xixuanbea010f2017-03-27 10:10:19 -070010# The path to save credentials.
11CREDENTIALS_PATH = os.path.join(os.path.dirname(__file__), 'credentials')
12
xixuanbea010f2017-03-27 10:10:19 -070013# The path to save configs.
14CONFIG_PATH = os.path.join(os.path.dirname(__file__), 'configs')
15
16# Suite scheduler event config file
Prathmesh Prabhu8dff3e22020-06-23 13:49:45 -070017SUITE_SCHEDULER_CONFIG_FILE = os.path.join(CONFIG_PATH, 'suite_scheduler.ini')
Xixuan Wu26d06e02017-09-20 14:50:28 -070018
19# The suite scheduler config file for testing.
Brigit Rossbach50d086f2020-09-17 13:29:49 -060020TEST_SUITE_SCHEDULER_CONFIG_FILE = os.path.join(CONFIG_PATH,
21 'fake_suite_scheduler.ini')
xixuanbea010f2017-03-27 10:10:19 -070022
23# Lab config file
24LAB_CONFIG_FILE = os.path.join(CONFIG_PATH, 'lab_config.ini')
25
Brigit Rossbach50d086f2020-09-17 13:29:49 -060026# Test lab config file
27TEST_LAB_CONFIG_FILE = os.path.join(CONFIG_PATH, 'fake_lab_config.ini')
28
29# Suite scheduler config repo
30NEW_SUITE_SCHEDULER_CONFIG_FILE = None
31NEW_LAB_CONFIG_FILE = None
32
33
34def clone_config():
35 """Function to clone the config for suite scheduler from the config-internal repo."""
Brigit Rossbachf951d8d2020-09-22 11:22:01 -060036 global NEW_SUITE_SCHEDULER_CONFIG_FILE
37 global NEW_LAB_CONFIG_FILE
Brigit Rossbach9d124442020-09-23 09:31:36 -060038 temp_dir = '/tmp/config-internal'
Brigit Rossbach50d086f2020-09-17 13:29:49 -060039 cmd = 'git clone --depth 1 https://chrome-internal.googlesource.com/chromeos/config-internal {}'.format(
40 temp_dir)
41 logging.info('Cloning internal config repo.')
42 if (NEW_SUITE_SCHEDULER_CONFIG_FILE is None or NEW_LAB_CONFIG_FILE is None):
43 try:
Dhanya Ganesh2b29ad12020-09-22 22:18:58 +000044 stdout = subprocess.check_output([cmd], shell=True)
45 logging.info(stdout)
Brigit Rossbach50d086f2020-09-17 13:29:49 -060046 suite_scheduler_path = os.path.join(temp_dir, 'test', 'suite_scheduler',
47 'generated')
48 NEW_SUITE_SCHEDULER_CONFIG_FILE = os.path.join(suite_scheduler_path,
49 'suite_scheduler.ini')
50 NEW_LAB_CONFIG_FILE = os.path.join(suite_scheduler_path,
51 'lab_config.ini')
Dhanya Ganesh98e66032020-09-22 21:19:12 +000052 if not os.path.exists(NEW_SUITE_SCHEDULER_CONFIG_FILE):
Dhanya Ganeshe57ac452020-09-22 20:58:04 +000053 logging.error('suite_scheduler.ini does not exist.')
Dhanya Ganesh98e66032020-09-22 21:19:12 +000054 if not os.path.exists(NEW_LAB_CONFIG_FILE):
Dhanya Ganeshe57ac452020-09-22 20:58:04 +000055 logging.error('lab_config.ini does not exist.')
Brigit Rossbach50d086f2020-09-17 13:29:49 -060056 except Exception as e:
57 logging.error(str(e))
58
Xixuan Wu26d06e02017-09-20 14:50:28 -070059# Service account secret json file used for staging project.
60STAGING_CLIENT_SECRETS_FILE = os.path.join(
Xixuan Wu865fa282017-09-05 15:23:19 -070061 CREDENTIALS_PATH,
62 'suite-scheduler-staging_client_secret_service_account.json')
Xixuan Wu26d06e02017-09-20 14:50:28 -070063
64# Service account secret json file used for prod project.
65PROD_CLIENT_SECRETS_FILE = os.path.join(
Prathmesh Prabhu8dff3e22020-06-23 13:49:45 -070066 CREDENTIALS_PATH, 'suite-scheduler_client_secret_service_account.json')