• 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"
118# For cuttlefish remote instances
119CF_ADB_PORT = 6520
120CF_VNC_PORT = 6444
121# For cheeps remote instances
122CHEEPS_ADB_PORT = 9222
123CHEEPS_VNC_PORT = 5900
124# For gce_x86_phones remote instances
125GCE_ADB_PORT = 5555
126GCE_VNC_PORT = 6444
127# For goldfish remote instances
128GF_ADB_PORT = 5555
129GF_VNC_PORT = 6444
130# For FVP remote instances (no VNC support)
131FVP_ADB_PORT = 5555
132# Maximum port number
133MAX_PORT = 65535
134
135COMMAND_PS = ["ps", "aux"]
136CMD_CVD = "cvd"
137CMD_LAUNCH_CVD = "launch_cvd"
138CMD_PGREP = "pgrep"
139CMD_STOP_CVD = "stop_cvd"
140CMD_RUN_CVD = "run_cvd"
141ENV_ANDROID_BUILD_TOP = "ANDROID_BUILD_TOP"
142ENV_ANDROID_EMULATOR_PREBUILTS = "ANDROID_EMULATOR_PREBUILTS"
143# TODO(b/172535794): Remove the deprecated "ANDROID_HOST_OUT" by 2021Q4.
144ENV_ANDROID_HOST_OUT = "ANDROID_HOST_OUT"
145ENV_ANDROID_PRODUCT_OUT = "ANDROID_PRODUCT_OUT"
146ENV_ANDROID_SOONG_HOST_OUT = "ANDROID_SOONG_HOST_OUT"
147ENV_ANDROID_TMP = "ANDROID_TMP"
148ENV_BUILD_TARGET = "TARGET_PRODUCT"
149
150LOCALHOST = "0.0.0.0"
151LOCALHOST_ADB_SERIAL = LOCALHOST + ":%d"
152REMOTE_INSTANCE_ADB_SERIAL = "127.0.0.1:%s"
153
154SSH_BIN = "ssh"
155SCP_BIN = "scp"
156ADB_BIN = "adb"
157# Default timeout, the unit is seconds.
158DEFAULT_SSH_TIMEOUT = 300
159DEFAULT_CF_BOOT_TIMEOUT = 450
160
161LABEL_CREATE_BY = "created_by"
162
163# for list and delete cmd
164INS_KEY_NAME = "name"
165INS_KEY_FULLNAME = "full_name"
166INS_KEY_STATUS = "status"
167INS_KEY_DISPLAY = "display"
168INS_KEY_IP = "ip"
169INS_KEY_ADB = "adb"
170INS_KEY_VNC = "vnc"
171INS_KEY_WEBRTC = "webrtc"
172INS_KEY_WEBRTC_PORT = "webrtc_port"
173INS_KEY_CREATETIME = "creationTimestamp"
174INS_KEY_AVD_TYPE = "avd_type"
175INS_KEY_AVD_FLAVOR = "flavor"
176INS_KEY_IS_LOCAL = "remote"
177INS_KEY_ZONE = "zone"
178INS_STATUS_RUNNING = "RUNNING"
179ENV_CUTTLEFISH_CONFIG_FILE = "CUTTLEFISH_CONFIG_FILE"
180ENV_CUTTLEFISH_INSTANCE = "CUTTLEFISH_INSTANCE"
181ENV_CVD_HOME = "HOME"
182ANDROID_INFO_FILE = "android-info.txt"
183CUTTLEFISH_CONFIG_FILE = "cuttlefish_config.json"
184
185TEMP_ARTIFACTS_FOLDER = "acloud_image_artifacts"
186CVD_HOST_PACKAGE = "cvd-host_package.tar.gz"
187# cvd tools symbolic link name of local instance.
188CVD_TOOLS_LINK_NAME = "host_bins"
189TOOL_NAME = "acloud"
190# Exit code in metrics
191EXIT_SUCCESS = 0
192EXIT_BY_USER = 1
193EXIT_BY_WRONG_CMD = 2
194EXIT_BY_FAIL_REPORT = 3
195EXIT_BY_ERROR = -99
196
197# For reuse gce instance
198SELECT_ONE_GCE_INSTANCE = "select_one_gce_instance"
199
200# Webrtc
201WEBRTC_LOCAL_PORT = 8443
202WEBRTC_LOCAL_HOST = "localhost"
203WEBRTC_CERTS_PATH = "usr/share/webrtc/certs"
204WEBRTC_CERTS_FILES = ["server.crt", "server.key"]
205SSL_DIR = ".config/acloud/mkcert"
206SSL_CA_NAME = "ACloud-webRTC-CA"
207SSL_TRUST_CA_DIR = "/usr/local/share/ca-certificates"
208
209# Remote Log
210REMOTE_LOG_FOLDER = "cuttlefish_runtime"
211
212# Key name in report
213ERROR_LOG_FOLDER = "error_log_folder"
214
215# Type of "logs" entries in report.
216# The values must be consistent with LogDataType in TradeFed.
217LOG_TYPE_DIR = "DIR"
218LOG_TYPE_KERNEL_LOG = "KERNEL_LOG"
219LOG_TYPE_LOGCAT = "LOGCAT"
220LOG_TYPE_TEXT = "TEXT"
221
222# Stages for create progress
223STAGE_INIT = 0
224STAGE_GCE = 1
225STAGE_SSH_CONNECT = 2
226STAGE_ARTIFACT = 3
227STAGE_BOOT_UP = 4
228
229# Acloud error types
230# Also update InfraErrorIdentifier.java in TradeFed for the errors to be
231# properly reported.
232ACLOUD_CONFIG_ERROR = "ACLOUD_CONFIG_ERROR"
233ACLOUD_UNKNOWN_ARGS_ERROR = "ACLOUD_UNKNOWN_ARGS_ERROR"
234ACLOUD_BOOT_UP_ERROR = "ACLOUD_BOOT_UP_ERROR"
235ACLOUD_CREATE_GCE_ERROR = "ACLOUD_CREATE_GCE_ERROR"
236ACLOUD_DOWNLOAD_ARTIFACT_ERROR = "ACLOUD_DOWNLOAD_ARTIFACT_ERROR"
237ACLOUD_INIT_ERROR = "ACLOUD_INIT_ERROR"
238ACLOUD_UNKNOWN_ERROR = "ACLOUD_UNKNOWN_ERROR"
239ACLOUD_SSH_CONNECT_ERROR = "ACLOUD_SSH_CONNECT_ERROR"
240GCE_QUOTA_ERROR = "GCE_QUOTA_ERROR"
241ACLOUD_OXYGEN_LEASE_ERROR = "ACLOUD_OXYGEN_LEASE_ERROR"
242ACLOUD_OXYGEN_RELEASE_ERROR = "ACLOUD_OXYGEN_RELEASE_ERROR"
243
244# Key words of error messages.
245ERROR_MSG_VNC_NOT_SUPPORT = "unknown command line flag 'start_vnc_server'"
246ERROR_MSG_WEBRTC_NOT_SUPPORT = "unknown command line flag 'start_webrtc'"
247
248# The name of download image tool.
249FETCH_CVD = "fetch_cvd"
250
251# For setup and cleanup
252# Packages "devscripts" and "equivs" are required for "mk-build-deps".
253# Packages from: https://android.googlesource.com/device/google/cuttlefish/
254AVD_REQUIRED_PKGS = [
255    "devscripts", "equivs", "libvirt-clients", "libvirt-daemon-system",
256    "config-package-dev", "golang"]
257BASE_REQUIRED_PKGS = ["ssvnc", "lzop", "python3-tk"]
258CUTTLEFISH_COMMOM_PKG = "cuttlefish-common"
259