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-trunk_staging-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" 46TYPE_TRUSTY = "trusty" 47 48# Image types 49IMAGE_SRC_REMOTE = "remote_image" 50IMAGE_SRC_LOCAL = "local_image" 51 52# AVD types in build target 53AVD_TYPES_MAPPING = { 54 TYPE_GCE: "gce", 55 TYPE_CF: "cf", 56 TYPE_GF: "sdk", 57 # Cheeps uses the cheets target. 58 TYPE_CHEEPS: "cheets", 59 TYPE_TRUSTY: "trusty", 60} 61 62# Instance types 63INSTANCE_TYPE_REMOTE = "remote" 64INSTANCE_TYPE_LOCAL = "local" 65INSTANCE_TYPE_HOST = "host" 66 67# CF_AVD_BUILD_TARGET_MAPPING 68CF_X86_PATTERN = "cf_x86" 69CF_ARM_PATTERN = "cf_arm" 70CF_AVD_BUILD_TARGET_PATTERN_MAPPING = { 71 INSTANCE_TYPE_REMOTE: CF_X86_PATTERN, 72 INSTANCE_TYPE_LOCAL: CF_X86_PATTERN, 73 INSTANCE_TYPE_HOST: CF_ARM_PATTERN, 74} 75 76# Flavor types 77FLAVOR_PHONE = "phone" 78FLAVOR_AUTO = "auto" 79FLAVOR_WEAR = "wear" 80FLAVOR_TV = "tv" 81FLAVOR_IOT = "iot" 82FLAVOR_TABLET = "tablet" 83FLAVOR_TABLET_3G = "tablet_3g" 84FLAVOR_FOLDABLE = "foldable" 85FLAVOR_DESKTOP = "desktop" 86ALL_FLAVORS = [ 87 FLAVOR_PHONE, FLAVOR_AUTO, FLAVOR_WEAR, FLAVOR_TV, FLAVOR_IOT, 88 FLAVOR_TABLET, FLAVOR_TABLET_3G, FLAVOR_FOLDABLE, FLAVOR_DESKTOP 89] 90 91# HW Property 92HW_ALIAS_CPUS = "cpu" 93HW_ALIAS_RESOLUTION = "resolution" 94HW_ALIAS_DPI = "dpi" 95HW_ALIAS_MEMORY = "memory" 96HW_ALIAS_DISK = "disk" 97HW_PROPERTIES_CMD_EXAMPLE = ( 98 f" {HW_ALIAS_CPUS}:2,{HW_ALIAS_RESOLUTION}:1280x700,{HW_ALIAS_DPI}:160," 99 f"{HW_ALIAS_MEMORY}:2g,{HW_ALIAS_DISK}:2g" 100) 101HW_PROPERTIES = [HW_ALIAS_CPUS, HW_ALIAS_RESOLUTION, HW_ALIAS_DPI, 102 HW_ALIAS_MEMORY, HW_ALIAS_DISK] 103HW_X_RES = "x_res" 104HW_Y_RES = "y_res" 105 106USER_ANSWER_YES = {"y", "yes", "Y"} 107 108# Cuttlefish groups 109LIST_CF_USER_GROUPS = ["kvm", "cvdnetwork", "render"] 110 111# Report keys 112IP = "ip" 113INSTANCE_NAME = "instance_name" 114GCE_USER = "vsoc-01" 115VNC_PORT = "vnc_port" 116ADB_PORT = "adb_port" 117WEBRTC_PORT = "webrtc_port" 118DEVICE_SERIAL = "device_serial" 119LOGS = "logs" 120BASE_INSTANCE_NUM = "base_instance_num" 121LAUNCH_CVD_COMMAND = "launch_cvd_command" 122# For cuttlefish remote instances 123CF_ADB_PORT = 6520 124CF_VNC_PORT = 6444 125# For cheeps remote instances 126CHEEPS_ADB_PORT = 9222 127CHEEPS_VNC_PORT = 5900 128# For gce_x86_phones remote instances 129GCE_ADB_PORT = 5555 130GCE_VNC_PORT = 6444 131# For ssh connect with GCE hostname 132GCE_HOSTNAME = "gce_hostname" 133# For goldfish remote instances 134GF_ADB_PORT = 5555 135GF_VNC_PORT = 6444 136# For FVP remote instances (no VNC support) 137FVP_ADB_PORT = 5555 138# For Trusty remote instances (no VNC support) 139TRUSTY_ADB_PORT = 5555 140# Maximum port number 141MAX_PORT = 65535 142# Time info to write in report. 143TIME_ARTIFACT = "fetch_artifact_time" 144TIME_GCE = "gce_create_time" 145TIME_LAUNCH = "launch_cvd_time" 146 147COMMAND_PS = ["ps", "aux"] 148CMD_CVD = "cvd" 149# the newer download tool 150CMD_CVD_FETCH = ["cvd", "fetch"] 151CMD_LAUNCH_CVD = "launch_cvd" 152CMD_PGREP = "pgrep" 153CMD_STOP_CVD = "stop_cvd" 154CMD_RUN_CVD = "run_cvd" 155ENV_ANDROID_BUILD_TOP = "ANDROID_BUILD_TOP" 156ENV_ANDROID_EMULATOR_PREBUILTS = "ANDROID_EMULATOR_PREBUILTS" 157ENV_ANDROID_HOST_OUT = "ANDROID_HOST_OUT" 158ENV_ANDROID_PRODUCT_OUT = "ANDROID_PRODUCT_OUT" 159ENV_ANDROID_SOONG_HOST_OUT = "ANDROID_SOONG_HOST_OUT" 160ENV_ANDROID_TMP = "ANDROID_TMP" 161ENV_BUILD_TARGET = "TARGET_PRODUCT" 162# For cvd to run in compatible mode. 163ENV_CVD_ACQUIRE_FILE_LOCK = "CVD_ACQUIRE_FILE_LOCK" 164ENV_LAUNCHED_BY_ACLOUD = "LAUNCHED_BY_ACLOUD" 165 166LOCALHOST = "0.0.0.0" 167LOCALHOST_ADB_SERIAL = LOCALHOST + ":%d" 168REMOTE_INSTANCE_ADB_SERIAL = "127.0.0.1:%s" 169 170SSH_BIN = "ssh" 171SCP_BIN = "scp" 172ADB_BIN = "adb" 173# Default timeout, the unit is seconds. 174DEFAULT_SSH_TIMEOUT = 300 175DEFAULT_CF_BOOT_TIMEOUT = 450 176 177LABEL_CREATE_BY = "created_by" 178 179# for list and delete cmd 180INS_KEY_NAME = "name" 181INS_KEY_FULLNAME = "full_name" 182INS_KEY_STATUS = "status" 183INS_KEY_DISPLAY = "display" 184INS_KEY_IP = "ip" 185INS_KEY_ADB = "adb" 186INS_KEY_VNC = "vnc" 187INS_KEY_WEBRTC = "webrtc" 188INS_KEY_WEBRTC_PORT = "webrtc_port" 189INS_KEY_WEBRTC_DEVICE_ID = "webrtc_device_id" 190INS_KEY_CREATETIME = "creationTimestamp" 191INS_KEY_AVD_TYPE = "avd_type" 192INS_KEY_AVD_FLAVOR = "flavor" 193INS_KEY_IS_LOCAL = "remote" 194INS_KEY_ZONE = "zone" 195INS_STATUS_RUNNING = "RUNNING" 196ENV_CUTTLEFISH_CONFIG_FILE = "CUTTLEFISH_CONFIG_FILE" 197ENV_CUTTLEFISH_INSTANCE = "CUTTLEFISH_INSTANCE" 198ENV_CVD_HOME = "HOME" 199ANDROID_INFO_FILE = "android-info.txt" 200CUTTLEFISH_CONFIG_FILE = "cuttlefish_config.json" 201 202TEMP_ARTIFACTS_FOLDER = "acloud_image_artifacts" 203CVD_HOST_PACKAGE = "cvd-host_package" 204CVD_HOST_TARBALL = "cvd-host_package.tar.gz" 205# cvd tools symbolic link name of local instance. 206CVD_TOOLS_LINK_NAME = "host_bins" 207TOOL_NAME = "acloud" 208# Exit code in metrics 209EXIT_SUCCESS = 0 210EXIT_BY_USER = 1 211EXIT_BY_WRONG_CMD = 2 212EXIT_BY_FAIL_REPORT = 3 213EXIT_BY_ERROR = -99 214 215# For reuse gce instance 216SELECT_ONE_GCE_INSTANCE = "select_one_gce_instance" 217 218# Webrtc 219WEBRTC_LOCAL_PORT = 8443 220WEBRTC_LOCAL_HOST = "localhost" 221WEBRTC_CERTS_PATH = "usr/share/webrtc/certs" 222WEBRTC_CERTS_FILES = ["server.crt", "server.key"] 223SSL_DIR = ".config/acloud/mkcert" 224SSL_CA_NAME = "ACloud-webRTC-CA" 225SSL_TRUST_CA_DIR = "/usr/local/share/ca-certificates" 226 227# Remote Log 228REMOTE_LOG_FOLDER = "cuttlefish_runtime" 229 230# Key name in report 231ERROR_LOG_FOLDER = "error_log_folder" 232 233# Type of "logs" entries in report. 234# The values must be consistent with LogDataType in TradeFed. 235LOG_TYPE_DIR = "DIR" 236LOG_TYPE_KERNEL_LOG = "KERNEL_LOG" 237LOG_TYPE_LOGCAT = "LOGCAT" 238LOG_TYPE_TEXT = "TEXT" 239LOG_TYPE_CUTTLEFISH_LOG = "CUTTLEFISH_LOG" 240 241# Stages for create progress 242STAGE_INIT = 0 243STAGE_GCE = 1 244STAGE_SSH_CONNECT = 2 245STAGE_ARTIFACT = 3 246STAGE_BOOT_UP = 4 247 248# Acloud error types 249# Also update InfraErrorIdentifier.java in TradeFed for the errors to be 250# properly reported. 251ACLOUD_CONFIG_ERROR = "ACLOUD_CONFIG_ERROR" 252ACLOUD_UNKNOWN_ARGS_ERROR = "ACLOUD_UNKNOWN_ARGS_ERROR" 253ACLOUD_BOOT_UP_ERROR = "ACLOUD_BOOT_UP_ERROR" 254ACLOUD_CREATE_GCE_ERROR = "ACLOUD_CREATE_GCE_ERROR" 255ACLOUD_DOWNLOAD_ARTIFACT_ERROR = "ACLOUD_DOWNLOAD_ARTIFACT_ERROR" 256ACLOUD_INIT_ERROR = "ACLOUD_INIT_ERROR" 257ACLOUD_UNKNOWN_ERROR = "ACLOUD_UNKNOWN_ERROR" 258ACLOUD_SSH_CONNECT_ERROR = "ACLOUD_SSH_CONNECT_ERROR" 259GCE_QUOTA_ERROR = "GCE_QUOTA_ERROR" 260ACLOUD_OXYGEN_LEASE_ERROR = "ACLOUD_OXYGEN_LEASE_ERROR" 261ACLOUD_OXYGEN_RELEASE_ERROR = "ACLOUD_OXYGEN_RELEASE_ERROR" 262 263# Key words of error messages. 264ERROR_MSG_VNC_NOT_SUPPORT = "unknown command line flag 'start_vnc_server'" 265ERROR_MSG_WEBRTC_NOT_SUPPORT = "unknown command line flag 'start_webrtc'" 266ERROR_MSG_SSO_INVALID = "stuck at SSO" 267 268# The name of download image tool. 269FETCH_CVD = "fetch_cvd" 270FETCH_CVD_ARGS_FILE = "fetch-cvd-args.txt" 271# The version is used when downloading LKGB fetch_cvd failed. 272FETCH_CVD_SECOND_VERSION = "10176216" 273# Last known good build 274LKGB = "LKGB" 275 276# The name of credential source key json file, a copy of 277# cfg.service_account_json_private_key_path for remote host case. 278FETCH_CVD_CREDENTIAL_SOURCE = "credential_key.json" 279 280# For setup and cleanup 281# Packages "devscripts" and "equivs" are required for "mk-build-deps". 282# Packages from: https://android.googlesource.com/device/google/cuttlefish/ 283AVD_REQUIRED_PKGS = [ 284 "devscripts", "equivs", "libvirt-clients", "libvirt-daemon-system", 285 "config-package-dev", "golang"] 286BASE_REQUIRED_PKGS = ["ssvnc", "lzop", "python3-tk"] 287CUTTLEFISH_COMMOM_PKG = "cuttlefish-common" 288