• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#
3# Copyright 2016 - The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16"""This module holds constants used by the driver."""
17BRANCH_PREFIX = "git_"
18BUILD_TARGET_MAPPING = {
19    # TODO: Add aosp goldfish targets and internal cf targets to vendor code
20    # base.
21    "aosp_phone": "aosp_cf_x86_64_phone-userdebug",
22    "aosp_tablet": "aosp_cf_x86_tablet-userdebug",
23}
24SPEC_NAMES = {
25    "nexus5", "nexus6", "nexus7_2012", "nexus7_2013", "nexus9", "nexus10"
26}
27
28DEFAULT_SERIAL_PORT = 1
29LOGCAT_SERIAL_PORT = 2
30
31# Remote image parameters
32BUILD_TARGET = "build_target"
33BUILD_BRANCH = "branch"
34BUILD_ID = "build_id"
35BUILD_ARTIFACT = "artifact"
36
37# Special value of local image parameters
38FIND_IN_BUILD_ENV = ""
39
40# AVD types
41TYPE_CHEEPS = "cheeps"
42TYPE_CF = "cuttlefish"
43TYPE_GCE = "gce"
44TYPE_GF = "goldfish"
45TYPE_FVP = "fvp"
46
47# Image types
48IMAGE_SRC_REMOTE = "remote_image"
49IMAGE_SRC_LOCAL = "local_image"
50
51# AVD types in build target
52AVD_TYPES_MAPPING = {
53    TYPE_GCE: "gce",
54    TYPE_CF: "cf",
55    TYPE_GF: "sdk",
56    # Cheeps uses the cheets target.
57    TYPE_CHEEPS: "cheets",
58}
59
60# Instance types
61INSTANCE_TYPE_REMOTE = "remote"
62INSTANCE_TYPE_LOCAL = "local"
63INSTANCE_TYPE_HOST = "host"
64
65# CF_AVD_BUILD_TARGET_MAPPING
66CF_X86_PATTERN = "cf_x86"
67CF_ARM_PATTERN = "cf_arm"
68CF_AVD_BUILD_TARGET_PATTERN_MAPPING = {
69    INSTANCE_TYPE_REMOTE: CF_X86_PATTERN,
70    INSTANCE_TYPE_LOCAL: CF_X86_PATTERN,
71    INSTANCE_TYPE_HOST: CF_ARM_PATTERN,
72}
73
74# Flavor types
75FLAVOR_PHONE = "phone"
76FLAVOR_AUTO = "auto"
77FLAVOR_WEAR = "wear"
78FLAVOR_TV = "tv"
79FLAVOR_IOT = "iot"
80FLAVOR_TABLET = "tablet"
81FLAVOR_TABLET_3G = "tablet_3g"
82FLAVOR_FOLDABLE = "foldable"
83ALL_FLAVORS = [
84    FLAVOR_PHONE, FLAVOR_AUTO, FLAVOR_WEAR, FLAVOR_TV, FLAVOR_IOT,
85    FLAVOR_TABLET, FLAVOR_TABLET_3G, FLAVOR_FOLDABLE
86]
87
88# HW Property
89HW_ALIAS_CPUS = "cpu"
90HW_ALIAS_RESOLUTION = "resolution"
91HW_ALIAS_DPI = "dpi"
92HW_ALIAS_MEMORY = "memory"
93HW_ALIAS_DISK = "disk"
94HW_PROPERTIES_CMD_EXAMPLE = (
95    f" {HW_ALIAS_CPUS}:2,{HW_ALIAS_RESOLUTION}:1280x700,{HW_ALIAS_DPI}:160,"
96    f"{HW_ALIAS_MEMORY}:2g,{HW_ALIAS_DISK}:2g"
97)
98HW_PROPERTIES = [HW_ALIAS_CPUS, HW_ALIAS_RESOLUTION, HW_ALIAS_DPI,
99                 HW_ALIAS_MEMORY, HW_ALIAS_DISK]
100HW_X_RES = "x_res"
101HW_Y_RES = "y_res"
102
103USER_ANSWER_YES = {"y", "yes", "Y"}
104
105# Cuttlefish groups
106LIST_CF_USER_GROUPS = ["kvm", "cvdnetwork", "render"]
107
108# Report keys
109IP = "ip"
110INSTANCE_NAME = "instance_name"
111GCE_USER = "vsoc-01"
112VNC_PORT = "vnc_port"
113ADB_PORT = "adb_port"
114FASTBOOT_PORT = "fastboot_port"
115WEBRTC_PORT = "webrtc_port"
116DEVICE_SERIAL = "device_serial"
117LOGS = "logs"
118BASE_INSTANCE_NUM = "base_instance_num"
119# For cuttlefish remote instances
120CF_ADB_PORT = 6520
121CF_FASTBOOT_PORT = 7520
122CF_VNC_PORT = 6444
123# For cheeps remote instances
124CHEEPS_ADB_PORT = 9222
125CHEEPS_VNC_PORT = 5900
126# For gce_x86_phones remote instances
127GCE_ADB_PORT = 5555
128GCE_VNC_PORT = 6444
129# For ssh connect with GCE hostname
130GCE_HOSTNAME = "gce_hostname"
131# For goldfish remote instances
132GF_ADB_PORT = 5555
133GF_VNC_PORT = 6444
134# For FVP remote instances (no VNC support)
135FVP_ADB_PORT = 5555
136# Maximum port number
137MAX_PORT = 65535
138# Time info to write in report.
139TIME_ARTIFACT = "fetch_artifact_time"
140TIME_GCE = "gce_create_time"
141TIME_LAUNCH = "launch_cvd_time"
142
143COMMAND_PS = ["ps", "aux"]
144CMD_CVD = "cvd"
145CMD_LAUNCH_CVD = "launch_cvd"
146CMD_PGREP = "pgrep"
147CMD_STOP_CVD = "stop_cvd"
148CMD_RUN_CVD = "run_cvd"
149ENV_ANDROID_BUILD_TOP = "ANDROID_BUILD_TOP"
150ENV_ANDROID_EMULATOR_PREBUILTS = "ANDROID_EMULATOR_PREBUILTS"
151# TODO(b/172535794): Remove the deprecated "ANDROID_HOST_OUT" by 2021Q4.
152ENV_ANDROID_HOST_OUT = "ANDROID_HOST_OUT"
153ENV_ANDROID_PRODUCT_OUT = "ANDROID_PRODUCT_OUT"
154ENV_ANDROID_SOONG_HOST_OUT = "ANDROID_SOONG_HOST_OUT"
155ENV_ANDROID_TMP = "ANDROID_TMP"
156ENV_BUILD_TARGET = "TARGET_PRODUCT"
157ENV_CVD_ACQUIRE_FILE_LOCK = "CVD_ACQUIRE_FILE_LOCK"
158
159LOCALHOST = "0.0.0.0"
160LOCALHOST_ADB_SERIAL = LOCALHOST + ":%d"
161REMOTE_INSTANCE_ADB_SERIAL = "127.0.0.1:%s"
162
163SSH_BIN = "ssh"
164SCP_BIN = "scp"
165ADB_BIN = "adb"
166# Default timeout, the unit is seconds.
167DEFAULT_SSH_TIMEOUT = 300
168DEFAULT_CF_BOOT_TIMEOUT = 450
169
170LABEL_CREATE_BY = "created_by"
171
172# for list and delete cmd
173INS_KEY_NAME = "name"
174INS_KEY_FULLNAME = "full_name"
175INS_KEY_STATUS = "status"
176INS_KEY_DISPLAY = "display"
177INS_KEY_IP = "ip"
178INS_KEY_ADB = "adb"
179INS_KEY_FASTBOOT = "fastboot"
180INS_KEY_VNC = "vnc"
181INS_KEY_WEBRTC = "webrtc"
182INS_KEY_WEBRTC_PORT = "webrtc_port"
183INS_KEY_WEBRTC_DEVICE_ID = "webrtc_device_id"
184INS_KEY_CREATETIME = "creationTimestamp"
185INS_KEY_AVD_TYPE = "avd_type"
186INS_KEY_AVD_FLAVOR = "flavor"
187INS_KEY_IS_LOCAL = "remote"
188INS_KEY_ZONE = "zone"
189INS_STATUS_RUNNING = "RUNNING"
190ENV_CUTTLEFISH_CONFIG_FILE = "CUTTLEFISH_CONFIG_FILE"
191ENV_CUTTLEFISH_INSTANCE = "CUTTLEFISH_INSTANCE"
192ENV_CVD_HOME = "HOME"
193ANDROID_INFO_FILE = "android-info.txt"
194CUTTLEFISH_CONFIG_FILE = "cuttlefish_config.json"
195
196TEMP_ARTIFACTS_FOLDER = "acloud_image_artifacts"
197CVD_HOST_PACKAGE = "cvd-host_package"
198CVD_HOST_TARBALL = "cvd-host_package.tar.gz"
199# cvd tools symbolic link name of local instance.
200CVD_TOOLS_LINK_NAME = "host_bins"
201TOOL_NAME = "acloud"
202# Exit code in metrics
203EXIT_SUCCESS = 0
204EXIT_BY_USER = 1
205EXIT_BY_WRONG_CMD = 2
206EXIT_BY_FAIL_REPORT = 3
207EXIT_BY_ERROR = -99
208
209# For reuse gce instance
210SELECT_ONE_GCE_INSTANCE = "select_one_gce_instance"
211
212# Webrtc
213WEBRTC_LOCAL_PORT = 8443
214WEBRTC_LOCAL_HOST = "localhost"
215WEBRTC_CERTS_PATH = "usr/share/webrtc/certs"
216WEBRTC_CERTS_FILES = ["server.crt", "server.key"]
217SSL_DIR = ".config/acloud/mkcert"
218SSL_CA_NAME = "ACloud-webRTC-CA"
219SSL_TRUST_CA_DIR = "/usr/local/share/ca-certificates"
220
221# Remote Log
222REMOTE_LOG_FOLDER = "cuttlefish_runtime"
223
224# Key name in report
225ERROR_LOG_FOLDER = "error_log_folder"
226
227# Type of "logs" entries in report.
228# The values must be consistent with LogDataType in TradeFed.
229LOG_TYPE_DIR = "DIR"
230LOG_TYPE_KERNEL_LOG = "KERNEL_LOG"
231LOG_TYPE_LOGCAT = "LOGCAT"
232LOG_TYPE_TEXT = "TEXT"
233LOG_TYPE_CUTTLEFISH_LOG = "CUTTLEFISH_LOG"
234
235# Stages for create progress
236STAGE_INIT = 0
237STAGE_GCE = 1
238STAGE_SSH_CONNECT = 2
239STAGE_ARTIFACT = 3
240STAGE_BOOT_UP = 4
241
242# Acloud error types
243# Also update InfraErrorIdentifier.java in TradeFed for the errors to be
244# properly reported.
245ACLOUD_CONFIG_ERROR = "ACLOUD_CONFIG_ERROR"
246ACLOUD_UNKNOWN_ARGS_ERROR = "ACLOUD_UNKNOWN_ARGS_ERROR"
247ACLOUD_BOOT_UP_ERROR = "ACLOUD_BOOT_UP_ERROR"
248ACLOUD_CREATE_GCE_ERROR = "ACLOUD_CREATE_GCE_ERROR"
249ACLOUD_DOWNLOAD_ARTIFACT_ERROR = "ACLOUD_DOWNLOAD_ARTIFACT_ERROR"
250ACLOUD_INIT_ERROR = "ACLOUD_INIT_ERROR"
251ACLOUD_UNKNOWN_ERROR = "ACLOUD_UNKNOWN_ERROR"
252ACLOUD_SSH_CONNECT_ERROR = "ACLOUD_SSH_CONNECT_ERROR"
253GCE_QUOTA_ERROR = "GCE_QUOTA_ERROR"
254ACLOUD_OXYGEN_LEASE_ERROR = "ACLOUD_OXYGEN_LEASE_ERROR"
255ACLOUD_OXYGEN_RELEASE_ERROR = "ACLOUD_OXYGEN_RELEASE_ERROR"
256
257# Key words of error messages.
258ERROR_MSG_VNC_NOT_SUPPORT = "unknown command line flag 'start_vnc_server'"
259ERROR_MSG_WEBRTC_NOT_SUPPORT = "unknown command line flag 'start_webrtc'"
260ERROR_MSG_SSO_INVALID = "stuck at SSO"
261
262# The name of download image tool.
263FETCH_CVD = "fetch_cvd"
264FETCH_CVD_ARGS_FILE = "fetch-cvd-args.txt"
265# Last known good build
266LKGB = "LKGB"
267
268# The name of credential source key json file, a copy of
269# cfg.service_account_json_private_key_path for remote host case.
270FETCH_CVD_CREDENTIAL_SOURCE = "credential_key.json"
271
272# For setup and cleanup
273# Packages "devscripts" and "equivs" are required for "mk-build-deps".
274# Packages from: https://android.googlesource.com/device/google/cuttlefish/
275AVD_REQUIRED_PKGS = [
276    "devscripts", "equivs", "libvirt-clients", "libvirt-daemon-system",
277    "config-package-dev", "golang"]
278BASE_REQUIRED_PKGS = ["ssvnc", "lzop", "python3-tk"]
279CUTTLEFISH_COMMOM_PKG = "cuttlefish-common"
280