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