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_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" 35 36# Special value of local image parameters 37FIND_IN_BUILD_ENV = "" 38 39# AVD types 40TYPE_CHEEPS = "cheeps" 41TYPE_CF = "cuttlefish" 42TYPE_GCE = "gce" 43TYPE_GF = "goldfish" 44TYPE_FVP = "fvp" 45 46# Image types 47IMAGE_SRC_REMOTE = "remote_image" 48IMAGE_SRC_LOCAL = "local_image" 49 50# AVD types in build target 51AVD_TYPES_MAPPING = { 52 TYPE_GCE: "gce", 53 TYPE_CF: "cf", 54 TYPE_GF: "sdk", 55 # Cheeps uses the cheets target. 56 TYPE_CHEEPS: "cheets", 57} 58 59# Instance types 60INSTANCE_TYPE_REMOTE = "remote" 61INSTANCE_TYPE_LOCAL = "local" 62INSTANCE_TYPE_HOST = "host" 63 64# CF_AVD_BUILD_TARGET_MAPPING 65CF_X86_PATTERN = "cf_x86" 66CF_ARM_PATTERN = "cf_arm" 67CF_AVD_BUILD_TARGET_PATTERN_MAPPING = { 68 INSTANCE_TYPE_REMOTE: CF_X86_PATTERN, 69 INSTANCE_TYPE_LOCAL: CF_X86_PATTERN, 70 INSTANCE_TYPE_HOST: CF_ARM_PATTERN, 71} 72 73# Flavor types 74FLAVOR_PHONE = "phone" 75FLAVOR_AUTO = "auto" 76FLAVOR_WEAR = "wear" 77FLAVOR_TV = "tv" 78FLAVOR_IOT = "iot" 79FLAVOR_TABLET = "tablet" 80FLAVOR_TABLET_3G = "tablet_3g" 81FLAVOR_FOLDABLE = "foldable" 82ALL_FLAVORS = [ 83 FLAVOR_PHONE, FLAVOR_AUTO, FLAVOR_WEAR, FLAVOR_TV, FLAVOR_IOT, 84 FLAVOR_TABLET, FLAVOR_TABLET_3G, FLAVOR_FOLDABLE 85] 86 87# HW Property 88HW_ALIAS_CPUS = "cpu" 89HW_ALIAS_RESOLUTION = "resolution" 90HW_ALIAS_DPI = "dpi" 91HW_ALIAS_MEMORY = "memory" 92HW_ALIAS_DISK = "disk" 93HW_PROPERTIES_CMD_EXAMPLE = ( 94 " %s:2,%s:1280x700,%s:160,%s:2g,%s:2g" % 95 (HW_ALIAS_CPUS, 96 HW_ALIAS_RESOLUTION, 97 HW_ALIAS_DPI, 98 HW_ALIAS_MEMORY, 99 HW_ALIAS_DISK) 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"] 110 111IP = "ip" 112INSTANCE_NAME = "instance_name" 113GCE_USER = "vsoc-01" 114VNC_PORT = "vnc_port" 115ADB_PORT = "adb_port" 116WEBRTC_PORT = "webrtc_port" 117DEVICE_SERIAL = "device_serial" 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_LAUNCH_CVD = "launch_cvd" 137CMD_PGREP = "pgrep" 138CMD_STOP_CVD = "stop_cvd" 139CMD_RUN_CVD = "run_cvd" 140ENV_ANDROID_BUILD_TOP = "ANDROID_BUILD_TOP" 141ENV_ANDROID_EMULATOR_PREBUILTS = "ANDROID_EMULATOR_PREBUILTS" 142# TODO(b/172535794): Remove the deprecated "ANDROID_HOST_OUT" by 2021Q4. 143ENV_ANDROID_HOST_OUT = "ANDROID_HOST_OUT" 144ENV_ANDROID_PRODUCT_OUT = "ANDROID_PRODUCT_OUT" 145ENV_ANDROID_SOONG_HOST_OUT = "ANDROID_SOONG_HOST_OUT" 146ENV_ANDROID_TMP = "ANDROID_TMP" 147ENV_BUILD_TARGET = "TARGET_PRODUCT" 148 149LOCALHOST = "0.0.0.0" 150LOCALHOST_ADB_SERIAL = LOCALHOST + ":%d" 151REMOTE_INSTANCE_ADB_SERIAL = "127.0.0.1:%s" 152 153SSH_BIN = "ssh" 154SCP_BIN = "scp" 155ADB_BIN = "adb" 156# Default timeout, the unit is seconds. 157DEFAULT_SSH_TIMEOUT = 300 158DEFAULT_CF_BOOT_TIMEOUT = 450 159 160LABEL_CREATE_BY = "created_by" 161 162# for list and delete cmd 163INS_KEY_NAME = "name" 164INS_KEY_FULLNAME = "full_name" 165INS_KEY_STATUS = "status" 166INS_KEY_DISPLAY = "display" 167INS_KEY_IP = "ip" 168INS_KEY_ADB = "adb" 169INS_KEY_VNC = "vnc" 170INS_KEY_WEBRTC = "webrtc" 171INS_KEY_CREATETIME = "creationTimestamp" 172INS_KEY_AVD_TYPE = "avd_type" 173INS_KEY_AVD_FLAVOR = "flavor" 174INS_KEY_IS_LOCAL = "remote" 175INS_KEY_ZONE = "zone" 176INS_STATUS_RUNNING = "RUNNING" 177ENV_CUTTLEFISH_CONFIG_FILE = "CUTTLEFISH_CONFIG_FILE" 178ENV_CUTTLEFISH_INSTANCE = "CUTTLEFISH_INSTANCE" 179ENV_CVD_HOME = "HOME" 180CUTTLEFISH_CONFIG_FILE = "cuttlefish_config.json" 181 182TEMP_ARTIFACTS_FOLDER = "acloud_image_artifacts" 183CVD_HOST_PACKAGE = "cvd-host_package.tar.gz" 184# cvd tools symbolic link name of local instance. 185CVD_TOOLS_LINK_NAME = "host_bins" 186TOOL_NAME = "acloud" 187# Exit code in metrics 188EXIT_SUCCESS = 0 189EXIT_BY_USER = 1 190EXIT_BY_WRONG_CMD = 2 191EXIT_BY_FAIL_REPORT = 3 192EXIT_BY_ERROR = -99 193 194# For reuse gce instance 195SELECT_ONE_GCE_INSTANCE = "select_one_gce_instance" 196 197# Webrtc 198WEBRTC_LOCAL_PORT = 8443 199WEBRTC_LOCAL_HOST = "localhost" 200 201# Remote Log 202REMOTE_LOG_FOLDER = "/home/%s/cuttlefish_runtime" % GCE_USER 203 204# Cheeps specific stuff. 205CHEEPS_BETTY_IMAGE = "betty_image" 206 207# Key name in report 208ERROR_LOG_FOLDER = "error_log_folder" 209 210# Stages for create progress 211STAGE_INIT = 0 212STAGE_GCE = 1 213STAGE_SSH_CONNECT = 2 214STAGE_ARTIFACT = 3 215STAGE_BOOT_UP = 4 216 217# The name of download image tool. 218FETCH_CVD = "fetch_cvd" 219