blob: 421a47ce985e5ebc21f27168301becae2c437a55 [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
Brigit Rossbach50d086f2020-09-17 13:29:49 -06008import tempfile
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 Rossbach50d086f2020-09-17 13:29:49 -060038 temp_dir = tempfile.mkdtemp()
39 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:
44 os.system(cmd)
45 suite_scheduler_path = os.path.join(temp_dir, 'test', 'suite_scheduler',
46 'generated')
47 NEW_SUITE_SCHEDULER_CONFIG_FILE = os.path.join(suite_scheduler_path,
48 'suite_scheduler.ini')
49 NEW_LAB_CONFIG_FILE = os.path.join(suite_scheduler_path,
50 'lab_config.ini')
51 except Exception as e:
52 logging.error(str(e))
53
Xixuan Wu26d06e02017-09-20 14:50:28 -070054# Service account secret json file used for staging project.
55STAGING_CLIENT_SECRETS_FILE = os.path.join(
Xixuan Wu865fa282017-09-05 15:23:19 -070056 CREDENTIALS_PATH,
57 'suite-scheduler-staging_client_secret_service_account.json')
Xixuan Wu26d06e02017-09-20 14:50:28 -070058
59# Service account secret json file used for prod project.
60PROD_CLIENT_SECRETS_FILE = os.path.join(
Prathmesh Prabhu8dff3e22020-06-23 13:49:45 -070061 CREDENTIALS_PATH, 'suite-scheduler_client_secret_service_account.json')