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# AVD types
37TYPE_CHEEPS = "cheeps"
38TYPE_CF = "cuttlefish"
39TYPE_GCE = "gce"
40TYPE_GF = "goldfish"
41TYPE_FVP = "fvp"
42
43# Image types
44IMAGE_SRC_REMOTE = "remote_image"
45IMAGE_SRC_LOCAL = "local_image"
46
47# AVD types in build target
48AVD_TYPES_MAPPING = {
49    TYPE_GCE: "gce",
50    TYPE_CF: "cf",
51    TYPE_GF: "sdk",
52    # Cheeps uses the cheets target.
53    TYPE_CHEEPS: "cheets",
54}
55
56# Instance types
57INSTANCE_TYPE_REMOTE = "remote"
58INSTANCE_TYPE_LOCAL = "local"
59INSTANCE_TYPE_HOST = "host"
60
61# CF_AVD_BUILD_TARGET_MAPPING
62CF_X86_PATTERN = "cf_x86"
63CF_ARM_PATTERN = "cf_arm"
64CF_AVD_BUILD_TARGET_PATTERN_MAPPING = {
65    INSTANCE_TYPE_REMOTE: CF_X86_PATTERN,
66    INSTANCE_TYPE_LOCAL: CF_X86_PATTERN,
67    INSTANCE_TYPE_HOST: CF_ARM_PATTERN,
68}
69
70# Flavor types
71FLAVOR_PHONE = "phone"
72FLAVOR_AUTO = "auto"
73FLAVOR_WEAR = "wear"
74FLAVOR_TV = "tv"
75FLAVOR_IOT = "iot"
76FLAVOR_TABLET = "tablet"
77FLAVOR_TABLET_3G = "tablet_3g"
78ALL_FLAVORS = [
79    FLAVOR_PHONE, FLAVOR_AUTO, FLAVOR_WEAR, FLAVOR_TV, FLAVOR_IOT,
80    FLAVOR_TABLET, FLAVOR_TABLET_3G
81]
82
83# HW Property
84HW_ALIAS_CPUS = "cpu"
85HW_ALIAS_RESOLUTION = "resolution"
86HW_ALIAS_DPI = "dpi"
87HW_ALIAS_MEMORY = "memory"
88HW_ALIAS_DISK = "disk"
89HW_PROPERTIES_CMD_EXAMPLE = (
90    " %s:2,%s:1280x700,%s:160,%s:2g,%s:2g" %
91    (HW_ALIAS_CPUS,
92     HW_ALIAS_RESOLUTION,
93     HW_ALIAS_DPI,
94     HW_ALIAS_MEMORY,
95     HW_ALIAS_DISK)
96)
97HW_PROPERTIES = [HW_ALIAS_CPUS, HW_ALIAS_RESOLUTION, HW_ALIAS_DPI,
98                 HW_ALIAS_MEMORY, HW_ALIAS_DISK]
99HW_X_RES = "x_res"
100HW_Y_RES = "y_res"
101
102USER_ANSWER_YES = {"y", "yes", "Y"}
103
104# Cuttlefish groups
105LIST_CF_USER_GROUPS = ["kvm", "cvdnetwork"]
106
107IP = "ip"
108INSTANCE_NAME = "instance_name"
109GCE_USER = "vsoc-01"
110VNC_PORT = "vnc_port"
111ADB_PORT = "adb_port"
112# For cuttlefish remote instances
113CF_ADB_PORT = 6520
114CF_VNC_PORT = 6444
115# For cheeps remote instances
116CHEEPS_ADB_PORT = 9222
117CHEEPS_VNC_PORT = 5900
118# For gce_x86_phones remote instances
119GCE_ADB_PORT = 5555
120GCE_VNC_PORT = 6444
121# For goldfish remote instances
122GF_ADB_PORT = 5555
123GF_VNC_PORT = 6444
124# For FVP remote instances (no VNC support)
125FVP_ADB_PORT = 5555
126
127COMMAND_PS = ["ps", "aux"]
128CMD_LAUNCH_CVD = "launch_cvd"
129CMD_PGREP = "pgrep"
130CMD_STOP_CVD = "stop_cvd"
131CMD_RUN_CVD = "run_cvd"
132ENV_ANDROID_BUILD_TOP = "ANDROID_BUILD_TOP"
133ENV_ANDROID_EMULATOR_PREBUILTS = "ANDROID_EMULATOR_PREBUILTS"
134ENV_ANDROID_HOST_OUT = "ANDROID_HOST_OUT"
135ENV_ANDROID_PRODUCT_OUT = "ANDROID_PRODUCT_OUT"
136ENV_ANDROID_TMP = "ANDROID_TMP"
137ENV_BUILD_TARGET = "TARGET_PRODUCT"
138
139LOCALHOST = "127.0.0.1"
140LOCALHOST_ADB_SERIAL = LOCALHOST + ":%d"
141
142SSH_BIN = "ssh"
143SCP_BIN = "scp"
144ADB_BIN = "adb"
145# Default timeout, the unit is seconds.
146DEFAULT_SSH_TIMEOUT = 300
147DEFAULT_CF_BOOT_TIMEOUT = 450
148
149LABEL_CREATE_BY = "created_by"
150
151# for list and delete cmd
152INS_KEY_NAME = "name"
153INS_KEY_FULLNAME = "full_name"
154INS_KEY_STATUS = "status"
155INS_KEY_DISPLAY = "display"
156INS_KEY_IP = "ip"
157INS_KEY_ADB = "adb"
158INS_KEY_VNC = "vnc"
159INS_KEY_WEBRTC = "webrtc"
160INS_KEY_CREATETIME = "creationTimestamp"
161INS_KEY_AVD_TYPE = "avd_type"
162INS_KEY_AVD_FLAVOR = "flavor"
163INS_KEY_IS_LOCAL = "remote"
164INS_KEY_ZONE = "zone"
165INS_STATUS_RUNNING = "RUNNING"
166LOCAL_INS_NAME = "local-instance"
167ENV_CUTTLEFISH_CONFIG_FILE = "CUTTLEFISH_CONFIG_FILE"
168ENV_CUTTLEFISH_INSTANCE = "CUTTLEFISH_INSTANCE"
169ENV_CVD_HOME = "HOME"
170CUTTLEFISH_CONFIG_FILE = "cuttlefish_config.json"
171
172TEMP_ARTIFACTS_FOLDER = "acloud_image_artifacts"
173CVD_HOST_PACKAGE = "cvd-host_package.tar.gz"
174TOOL_NAME = "acloud"
175# Exit code in metrics
176EXIT_SUCCESS = 0
177EXIT_BY_USER = 1
178EXIT_BY_WRONG_CMD = 2
179EXIT_BY_FAIL_REPORT = 3
180EXIT_BY_ERROR = -99
181
182# For reuse gce instance
183SELECT_ONE_GCE_INSTANCE = "select_one_gce_instance"
184
185# Webrtc
186WEBRTC_LOCAL_PORT = 8443
187WEBRTC_LOCAL_HOST = "localhost"
188
189# Remote Log
190REMOTE_LOG_FOLDER = "/home/%s/cuttlefish_runtime" % GCE_USER
191
192# Cheeps specific stuff.
193CHEEPS_BETTY_IMAGE = "betty_image"
194
195# Key name in report
196ERROR_LOG_FOLDER = "error_log_folder"
197