• 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"
114WEBRTC_PORT = "webrtc_port"
115DEVICE_SERIAL = "device_serial"
116LOGS = "logs"
117BASE_INSTANCE_NUM = "base_instance_num"
118LAUNCH_CVD_COMMAND = "launch_cvd_command"
119# For cuttlefish remote instances
120CF_ADB_PORT = 6520
121CF_VNC_PORT = 6444
122# For cheeps remote instances
123CHEEPS_ADB_PORT = 9222
124CHEEPS_VNC_PORT = 5900
125# For gce_x86_phones remote instances
126GCE_ADB_PORT = 5555
127GCE_VNC_PORT = 6444
128# For ssh connect with GCE hostname
129GCE_HOSTNAME = "gce_hostname"
130# For goldfish remote instances
131GF_ADB_PORT = 5555
132GF_VNC_PORT = 6444
133# For FVP remote instances (no VNC support)
134FVP_ADB_PORT = 5555
135# Maximum port number
136MAX_PORT = 65535
137# Time info to write in report.
138TIME_ARTIFACT = "fetch_artifact_time"
139TIME_GCE = "gce_create_time"
140TIME_LAUNCH = "launch_cvd_time"
141
142COMMAND_PS = ["ps", "aux"]
143CMD_CVD = "cvd"
144CMD_LAUNCH_CVD = "launch_cvd"
145CMD_PGREP = "pgrep"
146CMD_STOP_CVD = "stop_cvd"
147CMD_RUN_CVD = "run_cvd"
148ENV_ANDROID_BUILD_TOP = "ANDROID_BUILD_TOP"
149ENV_ANDROID_EMULATOR_PREBUILTS = "ANDROID_EMULATOR_PREBUILTS"
150ENV_ANDROID_HOST_OUT = "ANDROID_HOST_OUT"
151ENV_ANDROID_PRODUCT_OUT = "ANDROID_PRODUCT_OUT"
152ENV_ANDROID_SOONG_HOST_OUT = "ANDROID_SOONG_HOST_OUT"
153ENV_ANDROID_TMP = "ANDROID_TMP"
154ENV_BUILD_TARGET = "TARGET_PRODUCT"
155# For cvd to run in compatible mode.
156ENV_CVD_ACQUIRE_FILE_LOCK = "CVD_ACQUIRE_FILE_LOCK"
157ENV_LAUNCHED_BY_ACLOUD = "LAUNCHED_BY_ACLOUD"
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_VNC = "vnc"
180INS_KEY_WEBRTC = "webrtc"
181INS_KEY_WEBRTC_PORT = "webrtc_port"
182INS_KEY_WEBRTC_DEVICE_ID = "webrtc_device_id"
183INS_KEY_CREATETIME = "creationTimestamp"
184INS_KEY_AVD_TYPE = "avd_type"
185INS_KEY_AVD_FLAVOR = "flavor"
186INS_KEY_IS_LOCAL = "remote"
187INS_KEY_ZONE = "zone"
188INS_STATUS_RUNNING = "RUNNING"
189ENV_CUTTLEFISH_CONFIG_FILE = "CUTTLEFISH_CONFIG_FILE"
190ENV_CUTTLEFISH_INSTANCE = "CUTTLEFISH_INSTANCE"
191ENV_CVD_HOME = "HOME"
192ANDROID_INFO_FILE = "android-info.txt"
193CUTTLEFISH_CONFIG_FILE = "cuttlefish_config.json"
194
195TEMP_ARTIFACTS_FOLDER = "acloud_image_artifacts"
196CVD_HOST_PACKAGE = "cvd-host_package"
197CVD_HOST_TARBALL = "cvd-host_package.tar.gz"
198# cvd tools symbolic link name of local instance.
199CVD_TOOLS_LINK_NAME = "host_bins"
200TOOL_NAME = "acloud"
201# Exit code in metrics
202EXIT_SUCCESS = 0
203EXIT_BY_USER = 1
204EXIT_BY_WRONG_CMD = 2
205EXIT_BY_FAIL_REPORT = 3
206EXIT_BY_ERROR = -99
207
208# For reuse gce instance
209SELECT_ONE_GCE_INSTANCE = "select_one_gce_instance"
210
211# Webrtc
212WEBRTC_LOCAL_PORT = 8443
213WEBRTC_LOCAL_HOST = "localhost"
214WEBRTC_CERTS_PATH = "usr/share/webrtc/certs"
215WEBRTC_CERTS_FILES = ["server.crt", "server.key"]
216SSL_DIR = ".config/acloud/mkcert"
217SSL_CA_NAME = "ACloud-webRTC-CA"
218SSL_TRUST_CA_DIR = "/usr/local/share/ca-certificates"
219
220# Remote Log
221REMOTE_LOG_FOLDER = "cuttlefish_runtime"
222
223# Key name in report
224ERROR_LOG_FOLDER = "error_log_folder"
225
226# Type of "logs" entries in report.
227# The values must be consistent with LogDataType in TradeFed.
228LOG_TYPE_DIR = "DIR"
229LOG_TYPE_KERNEL_LOG = "KERNEL_LOG"
230LOG_TYPE_LOGCAT = "LOGCAT"
231LOG_TYPE_TEXT = "TEXT"
232LOG_TYPE_CUTTLEFISH_LOG = "CUTTLEFISH_LOG"
233
234# Stages for create progress
235STAGE_INIT = 0
236STAGE_GCE = 1
237STAGE_SSH_CONNECT = 2
238STAGE_ARTIFACT = 3
239STAGE_BOOT_UP = 4
240
241# Acloud error types
242# Also update InfraErrorIdentifier.java in TradeFed for the errors to be
243# properly reported.
244ACLOUD_CONFIG_ERROR = "ACLOUD_CONFIG_ERROR"
245ACLOUD_UNKNOWN_ARGS_ERROR = "ACLOUD_UNKNOWN_ARGS_ERROR"
246ACLOUD_BOOT_UP_ERROR = "ACLOUD_BOOT_UP_ERROR"
247ACLOUD_CREATE_GCE_ERROR = "ACLOUD_CREATE_GCE_ERROR"
248ACLOUD_DOWNLOAD_ARTIFACT_ERROR = "ACLOUD_DOWNLOAD_ARTIFACT_ERROR"
249ACLOUD_INIT_ERROR = "ACLOUD_INIT_ERROR"
250ACLOUD_UNKNOWN_ERROR = "ACLOUD_UNKNOWN_ERROR"
251ACLOUD_SSH_CONNECT_ERROR = "ACLOUD_SSH_CONNECT_ERROR"
252GCE_QUOTA_ERROR = "GCE_QUOTA_ERROR"
253ACLOUD_OXYGEN_LEASE_ERROR = "ACLOUD_OXYGEN_LEASE_ERROR"
254ACLOUD_OXYGEN_RELEASE_ERROR = "ACLOUD_OXYGEN_RELEASE_ERROR"
255
256# Key words of error messages.
257ERROR_MSG_VNC_NOT_SUPPORT = "unknown command line flag 'start_vnc_server'"
258ERROR_MSG_WEBRTC_NOT_SUPPORT = "unknown command line flag 'start_webrtc'"
259ERROR_MSG_SSO_INVALID = "stuck at SSO"
260
261# The name of download image tool.
262FETCH_CVD = "fetch_cvd"
263FETCH_CVD_ARGS_FILE = "fetch-cvd-args.txt"
264# The version is used when downloading LKGB fetch_cvd failed.
265FETCH_CVD_SECOND_VERSION = "10176216"
266# Last known good build
267LKGB = "LKGB"
268
269# The name of credential source key json file, a copy of
270# cfg.service_account_json_private_key_path for remote host case.
271FETCH_CVD_CREDENTIAL_SOURCE = "credential_key.json"
272
273# For setup and cleanup
274# Packages "devscripts" and "equivs" are required for "mk-build-deps".
275# Packages from: https://android.googlesource.com/device/google/cuttlefish/
276AVD_REQUIRED_PKGS = [
277    "devscripts", "equivs", "libvirt-clients", "libvirt-daemon-system",
278    "config-package-dev", "golang"]
279BASE_REQUIRED_PKGS = ["ssvnc", "lzop", "python3-tk"]
280CUTTLEFISH_COMMOM_PKG = "cuttlefish-common"
281