xref: /aosp_15_r20/tools/acloud/create/create_args.py (revision 800a58d989c669b8eb8a71d8df53b1ba3d411444)
1*800a58d9SAndroid Build Coastguard Worker# Copyright 2018 - The Android Open Source Project
2*800a58d9SAndroid Build Coastguard Worker#
3*800a58d9SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*800a58d9SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*800a58d9SAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*800a58d9SAndroid Build Coastguard Worker#
7*800a58d9SAndroid Build Coastguard Worker#     http://www.apache.org/licenses/LICENSE-2.0
8*800a58d9SAndroid Build Coastguard Worker#
9*800a58d9SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*800a58d9SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*800a58d9SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*800a58d9SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*800a58d9SAndroid Build Coastguard Worker# limitations under the License.
14*800a58d9SAndroid Build Coastguard Workerr"""Create args.
15*800a58d9SAndroid Build Coastguard Worker
16*800a58d9SAndroid Build Coastguard WorkerDefines the create arg parser that holds create specific args.
17*800a58d9SAndroid Build Coastguard Worker"""
18*800a58d9SAndroid Build Coastguard Worker
19*800a58d9SAndroid Build Coastguard Workerimport argparse
20*800a58d9SAndroid Build Coastguard Workerimport logging
21*800a58d9SAndroid Build Coastguard Workerimport os
22*800a58d9SAndroid Build Coastguard Workerimport posixpath as remote_path
23*800a58d9SAndroid Build Coastguard Worker
24*800a58d9SAndroid Build Coastguard Workerfrom acloud import errors
25*800a58d9SAndroid Build Coastguard Workerfrom acloud.create import create_common
26*800a58d9SAndroid Build Coastguard Workerfrom acloud.internal import constants
27*800a58d9SAndroid Build Coastguard Workerfrom acloud.internal.lib import utils
28*800a58d9SAndroid Build Coastguard Worker
29*800a58d9SAndroid Build Coastguard Workerlogger = logging.getLogger(__name__)
30*800a58d9SAndroid Build Coastguard Worker_DEFAULT_GPU = "default"
31*800a58d9SAndroid Build Coastguard WorkerCMD_CREATE = "create"
32*800a58d9SAndroid Build Coastguard Worker
33*800a58d9SAndroid Build Coastguard Worker
34*800a58d9SAndroid Build Coastguard Worker# TODO: Add this into main create args once create_cf/gf is deprecated.
35*800a58d9SAndroid Build Coastguard Worker# pylint: disable=too-many-statements
36*800a58d9SAndroid Build Coastguard Workerdef AddCommonCreateArgs(parser):
37*800a58d9SAndroid Build Coastguard Worker    """Adds arguments common to create parsers.
38*800a58d9SAndroid Build Coastguard Worker
39*800a58d9SAndroid Build Coastguard Worker    Args:
40*800a58d9SAndroid Build Coastguard Worker        parser: ArgumentParser object, used to parse flags.
41*800a58d9SAndroid Build Coastguard Worker    """
42*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
43*800a58d9SAndroid Build Coastguard Worker        "--num",
44*800a58d9SAndroid Build Coastguard Worker        type=int,
45*800a58d9SAndroid Build Coastguard Worker        dest="num",
46*800a58d9SAndroid Build Coastguard Worker        required=False,
47*800a58d9SAndroid Build Coastguard Worker        default=1,
48*800a58d9SAndroid Build Coastguard Worker        help="Number of instances to create.")
49*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
50*800a58d9SAndroid Build Coastguard Worker        "--serial-log-file",
51*800a58d9SAndroid Build Coastguard Worker        type=str,
52*800a58d9SAndroid Build Coastguard Worker        dest="serial_log_file",
53*800a58d9SAndroid Build Coastguard Worker        required=False,
54*800a58d9SAndroid Build Coastguard Worker        help="Path to a *tar.gz file where serial logs will be saved "
55*800a58d9SAndroid Build Coastguard Worker             "when a device fails on boot.")
56*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
57*800a58d9SAndroid Build Coastguard Worker        "--autoconnect",
58*800a58d9SAndroid Build Coastguard Worker        type=str,
59*800a58d9SAndroid Build Coastguard Worker        nargs="?",
60*800a58d9SAndroid Build Coastguard Worker        const=constants.INS_KEY_WEBRTC,
61*800a58d9SAndroid Build Coastguard Worker        dest="autoconnect",
62*800a58d9SAndroid Build Coastguard Worker        required=False,
63*800a58d9SAndroid Build Coastguard Worker        choices=[constants.INS_KEY_VNC, constants.INS_KEY_ADB,
64*800a58d9SAndroid Build Coastguard Worker                 constants.INS_KEY_WEBRTC],
65*800a58d9SAndroid Build Coastguard Worker        help="Determines to establish a tunnel forwarding adb/vnc and "
66*800a58d9SAndroid Build Coastguard Worker             "launch VNC/webrtc. Establish a tunnel forwarding adb and vnc "
67*800a58d9SAndroid Build Coastguard Worker             "then launch vnc if --autoconnect vnc is provided. Establish a "
68*800a58d9SAndroid Build Coastguard Worker             "tunnel forwarding adb if --autoconnect adb is provided. "
69*800a58d9SAndroid Build Coastguard Worker             "Establish a tunnel forwarding adb and auto-launch on the browser "
70*800a58d9SAndroid Build Coastguard Worker             "if --autoconnect webrtc is provided. For local goldfish "
71*800a58d9SAndroid Build Coastguard Worker             "instance, create a window.")
72*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
73*800a58d9SAndroid Build Coastguard Worker        "--no-autoconnect",
74*800a58d9SAndroid Build Coastguard Worker        action="store_false",
75*800a58d9SAndroid Build Coastguard Worker        dest="autoconnect",
76*800a58d9SAndroid Build Coastguard Worker        required=False,
77*800a58d9SAndroid Build Coastguard Worker        help="Will not automatically create ssh tunnels forwarding adb & vnc "
78*800a58d9SAndroid Build Coastguard Worker             "when instance created.")
79*800a58d9SAndroid Build Coastguard Worker    parser.set_defaults(autoconnect=constants.INS_KEY_WEBRTC)
80*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
81*800a58d9SAndroid Build Coastguard Worker        "--unlock",
82*800a58d9SAndroid Build Coastguard Worker        action="store_true",
83*800a58d9SAndroid Build Coastguard Worker        dest="unlock_screen",
84*800a58d9SAndroid Build Coastguard Worker        required=False,
85*800a58d9SAndroid Build Coastguard Worker        default=False,
86*800a58d9SAndroid Build Coastguard Worker        help="This can unlock screen after invoke vnc client.")
87*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
88*800a58d9SAndroid Build Coastguard Worker        "--report-internal-ip",
89*800a58d9SAndroid Build Coastguard Worker        action="store_true",
90*800a58d9SAndroid Build Coastguard Worker        dest="report_internal_ip",
91*800a58d9SAndroid Build Coastguard Worker        required=False,
92*800a58d9SAndroid Build Coastguard Worker        help="Report internal ip of the created instance instead of external "
93*800a58d9SAndroid Build Coastguard Worker             "ip. Using the internal ip is used when connecting from another "
94*800a58d9SAndroid Build Coastguard Worker             "GCE instance.")
95*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
96*800a58d9SAndroid Build Coastguard Worker        "--disable-external-ip",
97*800a58d9SAndroid Build Coastguard Worker        action="store_true",
98*800a58d9SAndroid Build Coastguard Worker        dest="disable_external_ip",
99*800a58d9SAndroid Build Coastguard Worker        required=False,
100*800a58d9SAndroid Build Coastguard Worker        help="Disable the external ip of the created instance.")
101*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
102*800a58d9SAndroid Build Coastguard Worker        "--extra-files",
103*800a58d9SAndroid Build Coastguard Worker        nargs='+',
104*800a58d9SAndroid Build Coastguard Worker        type=str,
105*800a58d9SAndroid Build Coastguard Worker        dest="extra_files",
106*800a58d9SAndroid Build Coastguard Worker        required=False,
107*800a58d9SAndroid Build Coastguard Worker        help="Upload the extra files into GCE instance. e.g. "
108*800a58d9SAndroid Build Coastguard Worker             "/path/to/file_in_local,/path/to/file_in_gce")
109*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
110*800a58d9SAndroid Build Coastguard Worker        "--network",
111*800a58d9SAndroid Build Coastguard Worker        type=str,
112*800a58d9SAndroid Build Coastguard Worker        dest="network",
113*800a58d9SAndroid Build Coastguard Worker        required=False,
114*800a58d9SAndroid Build Coastguard Worker        help="Set the network the GCE instance will utilize.")
115*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
116*800a58d9SAndroid Build Coastguard Worker        "--skip-pre-run-check",
117*800a58d9SAndroid Build Coastguard Worker        action="store_true",
118*800a58d9SAndroid Build Coastguard Worker        dest="skip_pre_run_check",
119*800a58d9SAndroid Build Coastguard Worker        required=False,
120*800a58d9SAndroid Build Coastguard Worker        help="Skip the pre-run check.")
121*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
122*800a58d9SAndroid Build Coastguard Worker        "--force-sync",
123*800a58d9SAndroid Build Coastguard Worker        action="store_true",
124*800a58d9SAndroid Build Coastguard Worker        dest="force_sync",
125*800a58d9SAndroid Build Coastguard Worker        required=False,
126*800a58d9SAndroid Build Coastguard Worker        help="Force to sync image files from Android Build servers even if "
127*800a58d9SAndroid Build Coastguard Worker             "they are already existed for local instance mode.")
128*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
129*800a58d9SAndroid Build Coastguard Worker        "--boot-timeout",
130*800a58d9SAndroid Build Coastguard Worker        dest="boot_timeout_secs",
131*800a58d9SAndroid Build Coastguard Worker        type=int,
132*800a58d9SAndroid Build Coastguard Worker        required=False,
133*800a58d9SAndroid Build Coastguard Worker        help="The maximum time in seconds used to wait for the AVD to download "
134*800a58d9SAndroid Build Coastguard Worker             "artifacts and boot.")
135*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
136*800a58d9SAndroid Build Coastguard Worker        "--wait-for-ins-stable",
137*800a58d9SAndroid Build Coastguard Worker        dest="ins_timeout_secs",
138*800a58d9SAndroid Build Coastguard Worker        type=int,
139*800a58d9SAndroid Build Coastguard Worker        required=False,
140*800a58d9SAndroid Build Coastguard Worker        help="The maximum time in seconds used to wait for the instance boot "
141*800a58d9SAndroid Build Coastguard Worker             "up. The default value to wait for instance up time is 300 secs.")
142*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
143*800a58d9SAndroid Build Coastguard Worker        "--build-target",
144*800a58d9SAndroid Build Coastguard Worker        type=str,
145*800a58d9SAndroid Build Coastguard Worker        dest="build_target",
146*800a58d9SAndroid Build Coastguard Worker        help="Android build target, e.g. aosp_cf_x86_64_phone-userdebug, "
147*800a58d9SAndroid Build Coastguard Worker             "or short names: phone, tablet, or tablet_mobile.")
148*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
149*800a58d9SAndroid Build Coastguard Worker        "--branch",
150*800a58d9SAndroid Build Coastguard Worker        type=str,
151*800a58d9SAndroid Build Coastguard Worker        dest="branch",
152*800a58d9SAndroid Build Coastguard Worker        help="Android branch, e.g. mnc-dev or git_mnc-dev")
153*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
154*800a58d9SAndroid Build Coastguard Worker        "--build-id",
155*800a58d9SAndroid Build Coastguard Worker        type=str,
156*800a58d9SAndroid Build Coastguard Worker        dest="build_id",
157*800a58d9SAndroid Build Coastguard Worker        help="Android build id, e.g. 2145099, P2804227")
158*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
159*800a58d9SAndroid Build Coastguard Worker        "--bootloader-branch",
160*800a58d9SAndroid Build Coastguard Worker        type=str,
161*800a58d9SAndroid Build Coastguard Worker        dest="bootloader_branch",
162*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Branch to consume the bootloader from.",
163*800a58d9SAndroid Build Coastguard Worker        required=False)
164*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
165*800a58d9SAndroid Build Coastguard Worker        "--bootloader-build-id",
166*800a58d9SAndroid Build Coastguard Worker        type=str,
167*800a58d9SAndroid Build Coastguard Worker        dest="bootloader_build_id",
168*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Bootloader build id, e.g. P2804227",
169*800a58d9SAndroid Build Coastguard Worker        required=False)
170*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
171*800a58d9SAndroid Build Coastguard Worker        "--bootloader-build-target",
172*800a58d9SAndroid Build Coastguard Worker        type=str,
173*800a58d9SAndroid Build Coastguard Worker        dest="bootloader_build_target",
174*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Bootloader build target.",
175*800a58d9SAndroid Build Coastguard Worker        required=False)
176*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
177*800a58d9SAndroid Build Coastguard Worker        "--android-efi-loader-build-id",
178*800a58d9SAndroid Build Coastguard Worker        type=str,
179*800a58d9SAndroid Build Coastguard Worker        dest="android_efi_loader_build_id",
180*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Android EFI loader build id, e.g. P2804227",
181*800a58d9SAndroid Build Coastguard Worker        required=False)
182*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
183*800a58d9SAndroid Build Coastguard Worker        "--android-efi-loader-artifact",
184*800a58d9SAndroid Build Coastguard Worker        type=str,
185*800a58d9SAndroid Build Coastguard Worker        dest="android_efi_loader_artifact",
186*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Android EFI loader artifact name, e.g. gbl_aarch64.efi",
187*800a58d9SAndroid Build Coastguard Worker        required=False)
188*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
189*800a58d9SAndroid Build Coastguard Worker        "--kernel-build-id",
190*800a58d9SAndroid Build Coastguard Worker        type=str,
191*800a58d9SAndroid Build Coastguard Worker        dest="kernel_build_id",
192*800a58d9SAndroid Build Coastguard Worker        required=False,
193*800a58d9SAndroid Build Coastguard Worker        help="Android kernel build id, e.g. 4586590. This is to test a new"
194*800a58d9SAndroid Build Coastguard Worker        " kernel build with a particular Android build (--build-id). If neither"
195*800a58d9SAndroid Build Coastguard Worker        " kernel-branch nor kernel-build-id are specified, the kernel that's"
196*800a58d9SAndroid Build Coastguard Worker        " bundled with the Android build would be used.")
197*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
198*800a58d9SAndroid Build Coastguard Worker        "--kernel-branch",
199*800a58d9SAndroid Build Coastguard Worker        type=str,
200*800a58d9SAndroid Build Coastguard Worker        dest="kernel_branch",
201*800a58d9SAndroid Build Coastguard Worker        required=False,
202*800a58d9SAndroid Build Coastguard Worker        help="Android kernel build branch name, e.g."
203*800a58d9SAndroid Build Coastguard Worker        " kernel-common-android-4.14. This is to test a new kernel build with a"
204*800a58d9SAndroid Build Coastguard Worker        " particular Android build (--build-id). If specified without"
205*800a58d9SAndroid Build Coastguard Worker        " specifying kernel-build-id, the last green build in the branch will"
206*800a58d9SAndroid Build Coastguard Worker        " be used. If neither kernel-branch nor kernel-build-id are specified,"
207*800a58d9SAndroid Build Coastguard Worker        " the kernel that's bundled with the Android build would be used.")
208*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
209*800a58d9SAndroid Build Coastguard Worker        "--kernel-build-target",
210*800a58d9SAndroid Build Coastguard Worker        type=str,
211*800a58d9SAndroid Build Coastguard Worker        dest="kernel_build_target",
212*800a58d9SAndroid Build Coastguard Worker        default="kernel",
213*800a58d9SAndroid Build Coastguard Worker        help="Kernel build target, specify if different from 'kernel'")
214*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
215*800a58d9SAndroid Build Coastguard Worker        "--boot-build-id",
216*800a58d9SAndroid Build Coastguard Worker        type=str,
217*800a58d9SAndroid Build Coastguard Worker        dest="boot_build_id",
218*800a58d9SAndroid Build Coastguard Worker        required=False,
219*800a58d9SAndroid Build Coastguard Worker        help="Boot image build ID, e.g., 8747889, 8748012.")
220*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
221*800a58d9SAndroid Build Coastguard Worker        "--boot-branch",
222*800a58d9SAndroid Build Coastguard Worker        type=str,
223*800a58d9SAndroid Build Coastguard Worker        dest="boot_branch",
224*800a58d9SAndroid Build Coastguard Worker        required=False,
225*800a58d9SAndroid Build Coastguard Worker        help="Boot image branch, e.g., aosp-gki13-boot-release, aosp-master.")
226*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
227*800a58d9SAndroid Build Coastguard Worker        "--boot-build-target",
228*800a58d9SAndroid Build Coastguard Worker        type=str,
229*800a58d9SAndroid Build Coastguard Worker        dest="boot_build_target",
230*800a58d9SAndroid Build Coastguard Worker        required=False,
231*800a58d9SAndroid Build Coastguard Worker        help="Boot image build target, "
232*800a58d9SAndroid Build Coastguard Worker        "e.g., gki_x86_64-userdebug, aosp_cf_x86_64_phone-userdebug.")
233*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
234*800a58d9SAndroid Build Coastguard Worker        "--boot-artifact",
235*800a58d9SAndroid Build Coastguard Worker        type=str,
236*800a58d9SAndroid Build Coastguard Worker        dest="boot_artifact",
237*800a58d9SAndroid Build Coastguard Worker        required=False,
238*800a58d9SAndroid Build Coastguard Worker        help="The name of the boot image to be retrieved from Android build, "
239*800a58d9SAndroid Build Coastguard Worker        "e.g., boot-5.10.img, boot.img.")
240*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
241*800a58d9SAndroid Build Coastguard Worker        "--ota-branch",
242*800a58d9SAndroid Build Coastguard Worker        type=str,
243*800a58d9SAndroid Build Coastguard Worker        dest="ota_branch",
244*800a58d9SAndroid Build Coastguard Worker        required=False,
245*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' OTA tools branch name. e.g. aosp-master")
246*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
247*800a58d9SAndroid Build Coastguard Worker        "--ota-build-id",
248*800a58d9SAndroid Build Coastguard Worker        type=str,
249*800a58d9SAndroid Build Coastguard Worker        dest="ota_build_id",
250*800a58d9SAndroid Build Coastguard Worker        required=False,
251*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' OTA tools build id, e.g. 2145099, P2804227")
252*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
253*800a58d9SAndroid Build Coastguard Worker        "--ota-build-target",
254*800a58d9SAndroid Build Coastguard Worker        type=str,
255*800a58d9SAndroid Build Coastguard Worker        dest="ota_build_target",
256*800a58d9SAndroid Build Coastguard Worker        required=False,
257*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' OTA tools build target, e.g. "
258*800a58d9SAndroid Build Coastguard Worker        "cf_x86_64_phone-userdebug.")
259*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
260*800a58d9SAndroid Build Coastguard Worker        "--host-package-branch", "--host_package_branch",
261*800a58d9SAndroid Build Coastguard Worker        type=str,
262*800a58d9SAndroid Build Coastguard Worker        dest="host_package_branch",
263*800a58d9SAndroid Build Coastguard Worker        required=False,
264*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish and trusty only' Host package branch name. e.g. "
265*800a58d9SAndroid Build Coastguard Worker        "aosp-main")
266*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
267*800a58d9SAndroid Build Coastguard Worker        "--host-package-build-id", "--host_package_build_id",
268*800a58d9SAndroid Build Coastguard Worker        type=str,
269*800a58d9SAndroid Build Coastguard Worker        dest="host_package_build_id",
270*800a58d9SAndroid Build Coastguard Worker        required=False,
271*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish and trusty only' Host package build id, e.g. "
272*800a58d9SAndroid Build Coastguard Worker        "2145099, P2804227")
273*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
274*800a58d9SAndroid Build Coastguard Worker        "--host-package-build-target", "--host_package_build_target",
275*800a58d9SAndroid Build Coastguard Worker        type=str,
276*800a58d9SAndroid Build Coastguard Worker        dest="host_package_build_target",
277*800a58d9SAndroid Build Coastguard Worker        required=False,
278*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish and trusty only' Host package build target, e.g. "
279*800a58d9SAndroid Build Coastguard Worker        "cf_x86_64_phone-userdebug.")
280*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
281*800a58d9SAndroid Build Coastguard Worker        "--system-branch",
282*800a58d9SAndroid Build Coastguard Worker        type=str,
283*800a58d9SAndroid Build Coastguard Worker        dest="system_branch",
284*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Branch to consume the system image (system.img) "
285*800a58d9SAndroid Build Coastguard Worker        "from, will default to what is defined by --branch. "
286*800a58d9SAndroid Build Coastguard Worker        "That feature allows to (automatically) test various combinations "
287*800a58d9SAndroid Build Coastguard Worker        "of vendor.img (CF, e.g.) and system images (GSI, e.g.). ",
288*800a58d9SAndroid Build Coastguard Worker        required=False)
289*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
290*800a58d9SAndroid Build Coastguard Worker        "--system-build-id",
291*800a58d9SAndroid Build Coastguard Worker        type=str,
292*800a58d9SAndroid Build Coastguard Worker        dest="system_build_id",
293*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' System image build id, e.g. 2145099, P2804227",
294*800a58d9SAndroid Build Coastguard Worker        required=False)
295*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
296*800a58d9SAndroid Build Coastguard Worker        "--system-build-target",
297*800a58d9SAndroid Build Coastguard Worker        type=str,
298*800a58d9SAndroid Build Coastguard Worker        dest="system_build_target",
299*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' System image build target, specify if different "
300*800a58d9SAndroid Build Coastguard Worker        "from --build-target",
301*800a58d9SAndroid Build Coastguard Worker        required=False)
302*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
303*800a58d9SAndroid Build Coastguard Worker        "--launch-args",
304*800a58d9SAndroid Build Coastguard Worker        type=str,
305*800a58d9SAndroid Build Coastguard Worker        dest="launch_args",
306*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Add extra args to launch_cvd command.",
307*800a58d9SAndroid Build Coastguard Worker        required=False)
308*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
309*800a58d9SAndroid Build Coastguard Worker        "--pet-name",
310*800a58d9SAndroid Build Coastguard Worker        "--webrtc_device_id",
311*800a58d9SAndroid Build Coastguard Worker        type=str,
312*800a58d9SAndroid Build Coastguard Worker        dest="webrtc_device_id",
313*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Give the pet name of the instance.",
314*800a58d9SAndroid Build Coastguard Worker        required=False)
315*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
316*800a58d9SAndroid Build Coastguard Worker        "--gce-metadata",
317*800a58d9SAndroid Build Coastguard Worker        type=str,
318*800a58d9SAndroid Build Coastguard Worker        dest="gce_metadata",
319*800a58d9SAndroid Build Coastguard Worker        default=None,
320*800a58d9SAndroid Build Coastguard Worker        help="'GCE instance only' Record data into GCE instance metadata with "
321*800a58d9SAndroid Build Coastguard Worker        "key-value pair format. e.g. id:12,name:unknown.")
322*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
323*800a58d9SAndroid Build Coastguard Worker        "--fetch_cvd-build-id",
324*800a58d9SAndroid Build Coastguard Worker        type=str,
325*800a58d9SAndroid Build Coastguard Worker        dest="fetch_cvd_build_id",
326*800a58d9SAndroid Build Coastguard Worker        required=False,
327*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Build id of fetch_cvd, e.g. 2145099, P2804227")
328*800a58d9SAndroid Build Coastguard Worker    # TODO(146314062): Remove --multi-stage-launch after infra don't use this
329*800a58d9SAndroid Build Coastguard Worker    # args.
330*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
331*800a58d9SAndroid Build Coastguard Worker        "--multi-stage-launch",
332*800a58d9SAndroid Build Coastguard Worker        dest="multi_stage_launch",
333*800a58d9SAndroid Build Coastguard Worker        action="store_true",
334*800a58d9SAndroid Build Coastguard Worker        required=False,
335*800a58d9SAndroid Build Coastguard Worker        default=True,
336*800a58d9SAndroid Build Coastguard Worker        help="Enable the multi-stage cuttlefish launch.")
337*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
338*800a58d9SAndroid Build Coastguard Worker        "--no-multi-stage-launch",
339*800a58d9SAndroid Build Coastguard Worker        dest="multi_stage_launch",
340*800a58d9SAndroid Build Coastguard Worker        action="store_false",
341*800a58d9SAndroid Build Coastguard Worker        required=False,
342*800a58d9SAndroid Build Coastguard Worker        default=None,
343*800a58d9SAndroid Build Coastguard Worker        help="Disable the multi-stage cuttlefish launch.")
344*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
345*800a58d9SAndroid Build Coastguard Worker        "--no-pull-log",
346*800a58d9SAndroid Build Coastguard Worker        dest="no_pull_log",
347*800a58d9SAndroid Build Coastguard Worker        action="store_true",
348*800a58d9SAndroid Build Coastguard Worker        required=False,
349*800a58d9SAndroid Build Coastguard Worker        default=None,
350*800a58d9SAndroid Build Coastguard Worker        help="Disable auto download logs when AVD booting up failed.")
351*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
352*800a58d9SAndroid Build Coastguard Worker        "--no-mkcert",
353*800a58d9SAndroid Build Coastguard Worker        dest="mkcert",
354*800a58d9SAndroid Build Coastguard Worker        action="store_false",
355*800a58d9SAndroid Build Coastguard Worker        required=False,
356*800a58d9SAndroid Build Coastguard Worker        default=True,
357*800a58d9SAndroid Build Coastguard Worker        help="Disable mkcert setup process on the host.")
358*800a58d9SAndroid Build Coastguard Worker    # TODO(147335651): Add gpu in user config.
359*800a58d9SAndroid Build Coastguard Worker    # TODO(147335651): Support "--gpu" without giving any value.
360*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
361*800a58d9SAndroid Build Coastguard Worker        "--gpu",
362*800a58d9SAndroid Build Coastguard Worker        type=str,
363*800a58d9SAndroid Build Coastguard Worker        const=_DEFAULT_GPU,
364*800a58d9SAndroid Build Coastguard Worker        nargs="?",
365*800a58d9SAndroid Build Coastguard Worker        dest="gpu",
366*800a58d9SAndroid Build Coastguard Worker        required=False,
367*800a58d9SAndroid Build Coastguard Worker        default=None,
368*800a58d9SAndroid Build Coastguard Worker        help="GPU accelerator to use if any. e.g. nvidia-tesla-k80. For local "
369*800a58d9SAndroid Build Coastguard Worker             "instances, this arg without assigning any value is to enable "
370*800a58d9SAndroid Build Coastguard Worker             "local gpu support.")
371*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
372*800a58d9SAndroid Build Coastguard Worker        "--num-avds-per-instance",
373*800a58d9SAndroid Build Coastguard Worker        "--num-instances",
374*800a58d9SAndroid Build Coastguard Worker        "--num_instances",
375*800a58d9SAndroid Build Coastguard Worker        type=int,
376*800a58d9SAndroid Build Coastguard Worker        dest="num_avds_per_instance",
377*800a58d9SAndroid Build Coastguard Worker        required=False,
378*800a58d9SAndroid Build Coastguard Worker        default=1,
379*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Create multiple cuttlefish AVDs in one local "
380*800a58d9SAndroid Build Coastguard Worker             "instance.")
381*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
382*800a58d9SAndroid Build Coastguard Worker        "--connect-hostname",
383*800a58d9SAndroid Build Coastguard Worker        action="store_true",
384*800a58d9SAndroid Build Coastguard Worker        dest="connect_hostname",
385*800a58d9SAndroid Build Coastguard Worker        required=False,
386*800a58d9SAndroid Build Coastguard Worker        default=False,
387*800a58d9SAndroid Build Coastguard Worker        help="Ssh connects to the GCE instance with hostname.")
388*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
389*800a58d9SAndroid Build Coastguard Worker        "--gce-only",
390*800a58d9SAndroid Build Coastguard Worker        action="store_true",
391*800a58d9SAndroid Build Coastguard Worker        dest="gce_only",
392*800a58d9SAndroid Build Coastguard Worker        required=False,
393*800a58d9SAndroid Build Coastguard Worker        default=False,
394*800a58d9SAndroid Build Coastguard Worker        help="Only create the GCE instance. It won't create virtual devices.")
395*800a58d9SAndroid Build Coastguard Worker    # Hide following args for users, it is only used in infra.
396*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
397*800a58d9SAndroid Build Coastguard Worker        "--local-instance-dir",
398*800a58d9SAndroid Build Coastguard Worker        dest="local_instance_dir",
399*800a58d9SAndroid Build Coastguard Worker        required=False,
400*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
401*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
402*800a58d9SAndroid Build Coastguard Worker        "--remote-image-dir",
403*800a58d9SAndroid Build Coastguard Worker        dest="remote_image_dir",
404*800a58d9SAndroid Build Coastguard Worker        required=False,
405*800a58d9SAndroid Build Coastguard Worker        # 'cuttlefish remote host only' Upload images and cvd host package to
406*800a58d9SAndroid Build Coastguard Worker        # the remote directory instead of the instance's own directory. If the
407*800a58d9SAndroid Build Coastguard Worker        # directory has been initialized, acloud ignores the image arguments
408*800a58d9SAndroid Build Coastguard Worker        # given by command line and reuses the images in the directory.
409*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
410*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
411*800a58d9SAndroid Build Coastguard Worker        "--oxygen",
412*800a58d9SAndroid Build Coastguard Worker        action="store_true",
413*800a58d9SAndroid Build Coastguard Worker        dest="oxygen",
414*800a58d9SAndroid Build Coastguard Worker        required=False,
415*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
416*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
417*800a58d9SAndroid Build Coastguard Worker        "--zone",
418*800a58d9SAndroid Build Coastguard Worker        type=str,
419*800a58d9SAndroid Build Coastguard Worker        dest="zone",
420*800a58d9SAndroid Build Coastguard Worker        required=False,
421*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
422*800a58d9SAndroid Build Coastguard Worker
423*800a58d9SAndroid Build Coastguard Worker    # TODO(b/118439885): Old arg formats to support transition, delete when
424*800a58d9SAndroid Build Coastguard Worker    # transistion is done.
425*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
426*800a58d9SAndroid Build Coastguard Worker        "--serial_log_file",
427*800a58d9SAndroid Build Coastguard Worker        type=str,
428*800a58d9SAndroid Build Coastguard Worker        dest="serial_log_file",
429*800a58d9SAndroid Build Coastguard Worker        required=False,
430*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
431*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
432*800a58d9SAndroid Build Coastguard Worker        "--build_id",
433*800a58d9SAndroid Build Coastguard Worker        type=str,
434*800a58d9SAndroid Build Coastguard Worker        dest="build_id",
435*800a58d9SAndroid Build Coastguard Worker        required=False,
436*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
437*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
438*800a58d9SAndroid Build Coastguard Worker        "--build_target",
439*800a58d9SAndroid Build Coastguard Worker        type=str,
440*800a58d9SAndroid Build Coastguard Worker        dest="build_target",
441*800a58d9SAndroid Build Coastguard Worker        required=False,
442*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
443*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
444*800a58d9SAndroid Build Coastguard Worker        "--system_branch",
445*800a58d9SAndroid Build Coastguard Worker        type=str,
446*800a58d9SAndroid Build Coastguard Worker        dest="system_branch",
447*800a58d9SAndroid Build Coastguard Worker        required=False,
448*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
449*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
450*800a58d9SAndroid Build Coastguard Worker        "--system_build_id",
451*800a58d9SAndroid Build Coastguard Worker        type=str,
452*800a58d9SAndroid Build Coastguard Worker        dest="system_build_id",
453*800a58d9SAndroid Build Coastguard Worker        required=False,
454*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
455*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
456*800a58d9SAndroid Build Coastguard Worker        "--system_build_target",
457*800a58d9SAndroid Build Coastguard Worker        type=str,
458*800a58d9SAndroid Build Coastguard Worker        dest="system_build_target",
459*800a58d9SAndroid Build Coastguard Worker        required=False,
460*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
461*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
462*800a58d9SAndroid Build Coastguard Worker        "--kernel_build_id",
463*800a58d9SAndroid Build Coastguard Worker        type=str,
464*800a58d9SAndroid Build Coastguard Worker        dest="kernel_build_id",
465*800a58d9SAndroid Build Coastguard Worker        required=False,
466*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
467*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
468*800a58d9SAndroid Build Coastguard Worker        "--kernel_branch",
469*800a58d9SAndroid Build Coastguard Worker        type=str,
470*800a58d9SAndroid Build Coastguard Worker        dest="kernel_branch",
471*800a58d9SAndroid Build Coastguard Worker        required=False,
472*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
473*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
474*800a58d9SAndroid Build Coastguard Worker        "--kernel_build_target",
475*800a58d9SAndroid Build Coastguard Worker        type=str,
476*800a58d9SAndroid Build Coastguard Worker        dest="kernel_build_target",
477*800a58d9SAndroid Build Coastguard Worker        default="kernel",
478*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
479*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
480*800a58d9SAndroid Build Coastguard Worker        "--bootloader_branch",
481*800a58d9SAndroid Build Coastguard Worker        type=str,
482*800a58d9SAndroid Build Coastguard Worker        dest="bootloader_branch",
483*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS,
484*800a58d9SAndroid Build Coastguard Worker        required=False)
485*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
486*800a58d9SAndroid Build Coastguard Worker        "--bootloader_build_id",
487*800a58d9SAndroid Build Coastguard Worker        type=str,
488*800a58d9SAndroid Build Coastguard Worker        dest="bootloader_build_id",
489*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS,
490*800a58d9SAndroid Build Coastguard Worker        required=False)
491*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
492*800a58d9SAndroid Build Coastguard Worker        "--bootloader_build_target",
493*800a58d9SAndroid Build Coastguard Worker        type=str,
494*800a58d9SAndroid Build Coastguard Worker        dest="bootloader_build_target",
495*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS,
496*800a58d9SAndroid Build Coastguard Worker        required=False)
497*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
498*800a58d9SAndroid Build Coastguard Worker        "--fetch_cvd_build_id",
499*800a58d9SAndroid Build Coastguard Worker        type=str,
500*800a58d9SAndroid Build Coastguard Worker        dest="fetch_cvd_build_id",
501*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS,
502*800a58d9SAndroid Build Coastguard Worker        required=False)
503*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
504*800a58d9SAndroid Build Coastguard Worker        "--remote-fetch",
505*800a58d9SAndroid Build Coastguard Worker        action="store_true",
506*800a58d9SAndroid Build Coastguard Worker        dest="remote_fetch",
507*800a58d9SAndroid Build Coastguard Worker        required=False,
508*800a58d9SAndroid Build Coastguard Worker        default=None,
509*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Fetch artifacts in remote host.")
510*800a58d9SAndroid Build Coastguard Worker    parser.add_argument(
511*800a58d9SAndroid Build Coastguard Worker        "--fetch-cvd-wrapper",
512*800a58d9SAndroid Build Coastguard Worker        dest="fetch_cvd_wrapper",
513*800a58d9SAndroid Build Coastguard Worker        type=str,
514*800a58d9SAndroid Build Coastguard Worker        required=False,
515*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Fetch artifacts in remote host by a"
516*800a58d9SAndroid Build Coastguard Worker        " provided static executable fetch cvd wrapper file. "
517*800a58d9SAndroid Build Coastguard Worker        " (Still in experiment, this flag only works on lab hosts"
518*800a58d9SAndroid Build Coastguard Worker        " with special setup.)")
519*800a58d9SAndroid Build Coastguard Worker
520*800a58d9SAndroid Build Coastguard Worker
521*800a58d9SAndroid Build Coastguard Workerdef GetCreateArgParser(subparser):
522*800a58d9SAndroid Build Coastguard Worker    """Return the create arg parser.
523*800a58d9SAndroid Build Coastguard Worker
524*800a58d9SAndroid Build Coastguard Worker    Args:
525*800a58d9SAndroid Build Coastguard Worker       subparser: argparse.ArgumentParser that is attached to main acloud cmd.
526*800a58d9SAndroid Build Coastguard Worker
527*800a58d9SAndroid Build Coastguard Worker    Returns:
528*800a58d9SAndroid Build Coastguard Worker        argparse.ArgumentParser with create options defined.
529*800a58d9SAndroid Build Coastguard Worker    """
530*800a58d9SAndroid Build Coastguard Worker    create_parser = subparser.add_parser(CMD_CREATE)
531*800a58d9SAndroid Build Coastguard Worker    create_parser.required = False
532*800a58d9SAndroid Build Coastguard Worker    create_parser.set_defaults(which=CMD_CREATE)
533*800a58d9SAndroid Build Coastguard Worker    # Use default=None to distinguish remote instance or local. The instance
534*800a58d9SAndroid Build Coastguard Worker    # type will be remote if the arg is not provided.
535*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
536*800a58d9SAndroid Build Coastguard Worker        "--local-instance",
537*800a58d9SAndroid Build Coastguard Worker        type=_PositiveInteger,
538*800a58d9SAndroid Build Coastguard Worker        const=0,
539*800a58d9SAndroid Build Coastguard Worker        metavar="ID",
540*800a58d9SAndroid Build Coastguard Worker        nargs="?",
541*800a58d9SAndroid Build Coastguard Worker        dest="local_instance",
542*800a58d9SAndroid Build Coastguard Worker        required=False,
543*800a58d9SAndroid Build Coastguard Worker        help="Create a local AVD instance using the resources associated with "
544*800a58d9SAndroid Build Coastguard Worker             "the ID. Choose an unused ID automatically if the value is "
545*800a58d9SAndroid Build Coastguard Worker             "not specified (primarily for infra usage).")
546*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
547*800a58d9SAndroid Build Coastguard Worker        "--adb-port", "-p",
548*800a58d9SAndroid Build Coastguard Worker        type=int,
549*800a58d9SAndroid Build Coastguard Worker        default=None,
550*800a58d9SAndroid Build Coastguard Worker        dest="adb_port",
551*800a58d9SAndroid Build Coastguard Worker        required=False,
552*800a58d9SAndroid Build Coastguard Worker        help="Specify port for adb forwarding.")
553*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
554*800a58d9SAndroid Build Coastguard Worker        "--base-instance-num",
555*800a58d9SAndroid Build Coastguard Worker        type=int,
556*800a58d9SAndroid Build Coastguard Worker        default=None,
557*800a58d9SAndroid Build Coastguard Worker        dest="base_instance_num",
558*800a58d9SAndroid Build Coastguard Worker        required=False,
559*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' The instance number of the created device.")
560*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
561*800a58d9SAndroid Build Coastguard Worker        "--avd-type",
562*800a58d9SAndroid Build Coastguard Worker        type=str,
563*800a58d9SAndroid Build Coastguard Worker        dest="avd_type",
564*800a58d9SAndroid Build Coastguard Worker        default=constants.TYPE_CF,
565*800a58d9SAndroid Build Coastguard Worker        choices=[constants.TYPE_GCE, constants.TYPE_CF, constants.TYPE_GF, constants.TYPE_CHEEPS,
566*800a58d9SAndroid Build Coastguard Worker                 constants.TYPE_FVP, constants.TYPE_TRUSTY],
567*800a58d9SAndroid Build Coastguard Worker        help="Android Virtual Device type (default %s)." % constants.TYPE_CF)
568*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
569*800a58d9SAndroid Build Coastguard Worker        "--config", "--flavor",
570*800a58d9SAndroid Build Coastguard Worker        type=str,
571*800a58d9SAndroid Build Coastguard Worker        dest="flavor",
572*800a58d9SAndroid Build Coastguard Worker        help="The device flavor of the AVD (default %s). e.g. phone, tv, foldable."
573*800a58d9SAndroid Build Coastguard Worker        % constants.FLAVOR_PHONE)
574*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
575*800a58d9SAndroid Build Coastguard Worker        "--local-image",
576*800a58d9SAndroid Build Coastguard Worker        const=constants.FIND_IN_BUILD_ENV,
577*800a58d9SAndroid Build Coastguard Worker        type=str,
578*800a58d9SAndroid Build Coastguard Worker        dest="local_image",
579*800a58d9SAndroid Build Coastguard Worker        nargs="?",
580*800a58d9SAndroid Build Coastguard Worker        required=False,
581*800a58d9SAndroid Build Coastguard Worker        help="Use the locally built image for the AVD. Look for the image "
582*800a58d9SAndroid Build Coastguard Worker        "artifact in $ANDROID_PRODUCT_OUT if no args value is provided."
583*800a58d9SAndroid Build Coastguard Worker        "e.g --local-image or --local-image /path/to/dir or --local-image "
584*800a58d9SAndroid Build Coastguard Worker        "/path/to/file")
585*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
586*800a58d9SAndroid Build Coastguard Worker        "--local-kernel-image", "--local-boot-image",
587*800a58d9SAndroid Build Coastguard Worker        const=constants.FIND_IN_BUILD_ENV,
588*800a58d9SAndroid Build Coastguard Worker        type=str,
589*800a58d9SAndroid Build Coastguard Worker        dest="local_kernel_image",
590*800a58d9SAndroid Build Coastguard Worker        nargs="?",
591*800a58d9SAndroid Build Coastguard Worker        required=False,
592*800a58d9SAndroid Build Coastguard Worker        help="Use the locally built kernel and ramdisk for the AVD. Look "
593*800a58d9SAndroid Build Coastguard Worker        "for boot.img, vendor_boot.img, kernel, initramfs.img, etc. if the "
594*800a58d9SAndroid Build Coastguard Worker        "argument is a directory. Look for the images in $ANDROID_PRODUCT_OUT "
595*800a58d9SAndroid Build Coastguard Worker        "if no argument is provided. e.g., --local-kernel-image, "
596*800a58d9SAndroid Build Coastguard Worker        "--local-kernel-image /path/to/dir, or --local-kernel-image "
597*800a58d9SAndroid Build Coastguard Worker        "/path/to/boot.img")
598*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
599*800a58d9SAndroid Build Coastguard Worker        "--local-system-image",
600*800a58d9SAndroid Build Coastguard Worker        const=constants.FIND_IN_BUILD_ENV,
601*800a58d9SAndroid Build Coastguard Worker        type=str,
602*800a58d9SAndroid Build Coastguard Worker        dest="local_system_image",
603*800a58d9SAndroid Build Coastguard Worker        nargs="?",
604*800a58d9SAndroid Build Coastguard Worker        required=False,
605*800a58d9SAndroid Build Coastguard Worker        help="Use the locally built system images for the AVD. Look for the "
606*800a58d9SAndroid Build Coastguard Worker        "images in $ANDROID_PRODUCT_OUT if no args value is provided. "
607*800a58d9SAndroid Build Coastguard Worker        "e.g., --local-system-image, --local-system-image /path/to/dir, or "
608*800a58d9SAndroid Build Coastguard Worker        "--local-system-image /path/to/img")
609*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
610*800a58d9SAndroid Build Coastguard Worker        "--local-system_dlkm-image",
611*800a58d9SAndroid Build Coastguard Worker        const=constants.FIND_IN_BUILD_ENV,
612*800a58d9SAndroid Build Coastguard Worker        type=str,
613*800a58d9SAndroid Build Coastguard Worker        dest="local_system_dlkm_image",
614*800a58d9SAndroid Build Coastguard Worker        nargs="?",
615*800a58d9SAndroid Build Coastguard Worker        required=False,
616*800a58d9SAndroid Build Coastguard Worker        help="`remote host only` Use the locally built system_dlkm image for "
617*800a58d9SAndroid Build Coastguard Worker        "the AVD. Look for the image in $ANDROID_PRODUCT_OUT if no args value "
618*800a58d9SAndroid Build Coastguard Worker        "is provided.")
619*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
620*800a58d9SAndroid Build Coastguard Worker        "--local-vendor-image",
621*800a58d9SAndroid Build Coastguard Worker        const=constants.FIND_IN_BUILD_ENV,
622*800a58d9SAndroid Build Coastguard Worker        type=str,
623*800a58d9SAndroid Build Coastguard Worker        dest="local_vendor_image",
624*800a58d9SAndroid Build Coastguard Worker        nargs="?",
625*800a58d9SAndroid Build Coastguard Worker        required=False,
626*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Use the locally built vendor images for the "
627*800a58d9SAndroid Build Coastguard Worker        "AVD. Look for vendor.img, vendor_dlkm.img, odm.img, and odm_dlkm.img "
628*800a58d9SAndroid Build Coastguard Worker        "if the argument is a directory. Look for the images in "
629*800a58d9SAndroid Build Coastguard Worker        "$ANDROID_PRODUCT_OUT if no argument is provided. e.g., "
630*800a58d9SAndroid Build Coastguard Worker        "--local-vendor-image, or --local-vendor-image /path/to/dir")
631*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
632*800a58d9SAndroid Build Coastguard Worker        "--local-vendor_boot-image", "--local-vendor-boot-image",
633*800a58d9SAndroid Build Coastguard Worker        const=constants.FIND_IN_BUILD_ENV,
634*800a58d9SAndroid Build Coastguard Worker        type=str,
635*800a58d9SAndroid Build Coastguard Worker        dest="local_vendor_boot_image",
636*800a58d9SAndroid Build Coastguard Worker        nargs="?",
637*800a58d9SAndroid Build Coastguard Worker        required=False,
638*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Use the locally built vendor boot image for "
639*800a58d9SAndroid Build Coastguard Worker        "the AVD. Look for the vendor_boot.img in $ANDROID_PRODUCT_OUT "
640*800a58d9SAndroid Build Coastguard Worker        "if no argument is provided. e.g., --local-vendor-boot-image, or "
641*800a58d9SAndroid Build Coastguard Worker        "--local-vendor-boot-image /path/to/dir, or "
642*800a58d9SAndroid Build Coastguard Worker        "--local-vendor-boot-image /path/to/img")
643*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
644*800a58d9SAndroid Build Coastguard Worker        "--local-tool",
645*800a58d9SAndroid Build Coastguard Worker        type=str,
646*800a58d9SAndroid Build Coastguard Worker        dest="local_tool",
647*800a58d9SAndroid Build Coastguard Worker        action="append",
648*800a58d9SAndroid Build Coastguard Worker        default=[],
649*800a58d9SAndroid Build Coastguard Worker        required=False,
650*800a58d9SAndroid Build Coastguard Worker        help="Use the tools in the specified directory to create local "
651*800a58d9SAndroid Build Coastguard Worker        "instances. The directory structure follows $ANDROID_SOONG_HOST_OUT "
652*800a58d9SAndroid Build Coastguard Worker        "or $ANDROID_EMULATOR_PREBUILTS.")
653*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
654*800a58d9SAndroid Build Coastguard Worker        "--cvd-host-package",
655*800a58d9SAndroid Build Coastguard Worker        type=str,
656*800a58d9SAndroid Build Coastguard Worker        dest="cvd_host_package",
657*800a58d9SAndroid Build Coastguard Worker        required=False,
658*800a58d9SAndroid Build Coastguard Worker        help="Use the specified path of the cvd host package to create "
659*800a58d9SAndroid Build Coastguard Worker        "instances. e.g. /path/cvd-host_package_v1.tar.gz")
660*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
661*800a58d9SAndroid Build Coastguard Worker        "--image-download-dir",
662*800a58d9SAndroid Build Coastguard Worker        type=str,
663*800a58d9SAndroid Build Coastguard Worker        dest="image_download_dir",
664*800a58d9SAndroid Build Coastguard Worker        required=False,
665*800a58d9SAndroid Build Coastguard Worker        help="Define remote image download directory, e.g. /usr/local/dl.")
666*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
667*800a58d9SAndroid Build Coastguard Worker        "--yes", "-y",
668*800a58d9SAndroid Build Coastguard Worker        action="store_true",
669*800a58d9SAndroid Build Coastguard Worker        dest="no_prompt",
670*800a58d9SAndroid Build Coastguard Worker        required=False,
671*800a58d9SAndroid Build Coastguard Worker        help=("Automatic yes to prompts. Assume 'yes' as answer to all prompts "
672*800a58d9SAndroid Build Coastguard Worker              "and run non-interactively."))
673*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
674*800a58d9SAndroid Build Coastguard Worker        "--reuse-gce",
675*800a58d9SAndroid Build Coastguard Worker        type=str,
676*800a58d9SAndroid Build Coastguard Worker        const=constants.SELECT_ONE_GCE_INSTANCE,
677*800a58d9SAndroid Build Coastguard Worker        nargs="?",
678*800a58d9SAndroid Build Coastguard Worker        dest="reuse_gce",
679*800a58d9SAndroid Build Coastguard Worker        required=False,
680*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' This can help users use their own instance. "
681*800a58d9SAndroid Build Coastguard Worker        "Reusing specific gce instance if --reuse-gce [instance_name] is "
682*800a58d9SAndroid Build Coastguard Worker        "provided. Select one gce instance to reuse if --reuse-gce is "
683*800a58d9SAndroid Build Coastguard Worker        "provided.")
684*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
685*800a58d9SAndroid Build Coastguard Worker        "--openwrt",
686*800a58d9SAndroid Build Coastguard Worker        action="store_true",
687*800a58d9SAndroid Build Coastguard Worker        dest="openwrt",
688*800a58d9SAndroid Build Coastguard Worker        required=False,
689*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Create OpenWrt device when launching cuttlefish "
690*800a58d9SAndroid Build Coastguard Worker        "device.")
691*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
692*800a58d9SAndroid Build Coastguard Worker        "--use-launch_cvd",
693*800a58d9SAndroid Build Coastguard Worker        action="store_true",
694*800a58d9SAndroid Build Coastguard Worker        dest="use_launch_cvd",
695*800a58d9SAndroid Build Coastguard Worker        required=False,
696*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Use launch_cvd to create cuttlefish devices.")
697*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
698*800a58d9SAndroid Build Coastguard Worker        "--host",
699*800a58d9SAndroid Build Coastguard Worker        type=str,
700*800a58d9SAndroid Build Coastguard Worker        dest="remote_host",
701*800a58d9SAndroid Build Coastguard Worker        default=None,
702*800a58d9SAndroid Build Coastguard Worker        help="'cuttlefish only' Provide host name to clean up the remote host. "
703*800a58d9SAndroid Build Coastguard Worker        "For example: '--host 1.1.1.1'")
704*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
705*800a58d9SAndroid Build Coastguard Worker        "--host-user",
706*800a58d9SAndroid Build Coastguard Worker        type=str,
707*800a58d9SAndroid Build Coastguard Worker        dest="host_user",
708*800a58d9SAndroid Build Coastguard Worker        default=constants.GCE_USER,
709*800a58d9SAndroid Build Coastguard Worker        help="'remote host only' Provide host user for logging in to the host. "
710*800a58d9SAndroid Build Coastguard Worker        "The default value is vsoc-01. For example: '--host 1.1.1.1 --host-user "
711*800a58d9SAndroid Build Coastguard Worker        "vsoc-02'")
712*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
713*800a58d9SAndroid Build Coastguard Worker        "--host-ssh-private-key-path",
714*800a58d9SAndroid Build Coastguard Worker        type=str,
715*800a58d9SAndroid Build Coastguard Worker        dest="host_ssh_private_key_path",
716*800a58d9SAndroid Build Coastguard Worker        default=None,
717*800a58d9SAndroid Build Coastguard Worker        help="'remote host only' Provide host key for login on on this host.")
718*800a58d9SAndroid Build Coastguard Worker    # User should not specify --spec and --hw_property at the same time.
719*800a58d9SAndroid Build Coastguard Worker    hw_spec_group = create_parser.add_mutually_exclusive_group()
720*800a58d9SAndroid Build Coastguard Worker    hw_spec_group.add_argument(
721*800a58d9SAndroid Build Coastguard Worker        "--hw-property",
722*800a58d9SAndroid Build Coastguard Worker        type=str,
723*800a58d9SAndroid Build Coastguard Worker        dest="hw_property",
724*800a58d9SAndroid Build Coastguard Worker        required=False,
725*800a58d9SAndroid Build Coastguard Worker        help="Supported HW properties and example values: %s" %
726*800a58d9SAndroid Build Coastguard Worker        constants.HW_PROPERTIES_CMD_EXAMPLE)
727*800a58d9SAndroid Build Coastguard Worker    hw_spec_group.add_argument(
728*800a58d9SAndroid Build Coastguard Worker        "--spec",
729*800a58d9SAndroid Build Coastguard Worker        type=str,
730*800a58d9SAndroid Build Coastguard Worker        dest="spec",
731*800a58d9SAndroid Build Coastguard Worker        required=False,
732*800a58d9SAndroid Build Coastguard Worker        choices=constants.SPEC_NAMES,
733*800a58d9SAndroid Build Coastguard Worker        help="The name of a pre-configured device spec that we are "
734*800a58d9SAndroid Build Coastguard Worker        "going to use.")
735*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
736*800a58d9SAndroid Build Coastguard Worker        "--disk-type",
737*800a58d9SAndroid Build Coastguard Worker        type=str,
738*800a58d9SAndroid Build Coastguard Worker        dest="disk_type",
739*800a58d9SAndroid Build Coastguard Worker        required=False,
740*800a58d9SAndroid Build Coastguard Worker        help="This is used to customize the GCE instance disk type, the "
741*800a58d9SAndroid Build Coastguard Worker        "default disk type is from the stable host image. Use pd-ssd or "
742*800a58d9SAndroid Build Coastguard Worker        "pd-standard to specify instance disk type.")
743*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
744*800a58d9SAndroid Build Coastguard Worker        "--stable-host-image-name",
745*800a58d9SAndroid Build Coastguard Worker        type=str,
746*800a58d9SAndroid Build Coastguard Worker        dest="stable_host_image_name",
747*800a58d9SAndroid Build Coastguard Worker        required=False,
748*800a58d9SAndroid Build Coastguard Worker        default=None,
749*800a58d9SAndroid Build Coastguard Worker        help=("'cuttlefish only' The Cuttlefish host image from which instances "
750*800a58d9SAndroid Build Coastguard Worker              "are launched. If specified here, the value set in Acloud config "
751*800a58d9SAndroid Build Coastguard Worker              "file will be overridden."))
752*800a58d9SAndroid Build Coastguard Worker
753*800a58d9SAndroid Build Coastguard Worker    # Arguments for goldfish type.
754*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
755*800a58d9SAndroid Build Coastguard Worker        "--emulator-build-id",
756*800a58d9SAndroid Build Coastguard Worker        type=str,
757*800a58d9SAndroid Build Coastguard Worker        dest="emulator_build_id",
758*800a58d9SAndroid Build Coastguard Worker        required=False,
759*800a58d9SAndroid Build Coastguard Worker        help="'goldfish only' Emulator build ID used to run the images. "
760*800a58d9SAndroid Build Coastguard Worker        "e.g. 4669466.")
761*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
762*800a58d9SAndroid Build Coastguard Worker        "--emulator-build-target",
763*800a58d9SAndroid Build Coastguard Worker        dest="emulator_build_target",
764*800a58d9SAndroid Build Coastguard Worker        required=False,
765*800a58d9SAndroid Build Coastguard Worker        help="'goldfish remote host only' Emulator build target used to run "
766*800a58d9SAndroid Build Coastguard Worker        "the images. e.g. emulator-linux_x64_nolocationui.")
767*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
768*800a58d9SAndroid Build Coastguard Worker        "--emulator-zip",
769*800a58d9SAndroid Build Coastguard Worker        dest="emulator_zip",
770*800a58d9SAndroid Build Coastguard Worker        required=False,
771*800a58d9SAndroid Build Coastguard Worker        help="'goldfish remote host only' Emulator zip used to run the "
772*800a58d9SAndroid Build Coastguard Worker        "images. e.g., /path/sdk-repo-linux-emulator-1234567.zip.")
773*800a58d9SAndroid Build Coastguard Worker
774*800a58d9SAndroid Build Coastguard Worker    # Arguments for cheeps type.
775*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
776*800a58d9SAndroid Build Coastguard Worker        "--stable-cheeps-host-image-name",
777*800a58d9SAndroid Build Coastguard Worker        type=str,
778*800a58d9SAndroid Build Coastguard Worker        dest="stable_cheeps_host_image_name",
779*800a58d9SAndroid Build Coastguard Worker        required=False,
780*800a58d9SAndroid Build Coastguard Worker        default=None,
781*800a58d9SAndroid Build Coastguard Worker        help=("'cheeps only' The Cheeps host image from which instances are "
782*800a58d9SAndroid Build Coastguard Worker              "launched. If specified here, the value set in Acloud config "
783*800a58d9SAndroid Build Coastguard Worker              "file will be overridden."))
784*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
785*800a58d9SAndroid Build Coastguard Worker        "--stable-cheeps-host-image-project",
786*800a58d9SAndroid Build Coastguard Worker        type=str,
787*800a58d9SAndroid Build Coastguard Worker        dest="stable_cheeps_host_image_project",
788*800a58d9SAndroid Build Coastguard Worker        required=False,
789*800a58d9SAndroid Build Coastguard Worker        default=None,
790*800a58d9SAndroid Build Coastguard Worker        help=("'cheeps only' The project hosting the specified Cheeps host "
791*800a58d9SAndroid Build Coastguard Worker              "image. If specified here, the value set in Acloud config file "
792*800a58d9SAndroid Build Coastguard Worker              "will be overridden."))
793*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
794*800a58d9SAndroid Build Coastguard Worker        "--user",
795*800a58d9SAndroid Build Coastguard Worker        type=str,
796*800a58d9SAndroid Build Coastguard Worker        dest="username",
797*800a58d9SAndroid Build Coastguard Worker        required=False,
798*800a58d9SAndroid Build Coastguard Worker        default=None,
799*800a58d9SAndroid Build Coastguard Worker        help="'cheeps only' username to log in to Chrome OS as.")
800*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
801*800a58d9SAndroid Build Coastguard Worker        "--password",
802*800a58d9SAndroid Build Coastguard Worker        type=str,
803*800a58d9SAndroid Build Coastguard Worker        dest="password",
804*800a58d9SAndroid Build Coastguard Worker        required=False,
805*800a58d9SAndroid Build Coastguard Worker        default=None,
806*800a58d9SAndroid Build Coastguard Worker        help="'cheeps only' password to log in to Chrome OS with.")
807*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
808*800a58d9SAndroid Build Coastguard Worker        "--betty-image",
809*800a58d9SAndroid Build Coastguard Worker        type=str,
810*800a58d9SAndroid Build Coastguard Worker        dest="cheeps_betty_image",
811*800a58d9SAndroid Build Coastguard Worker        required=False,
812*800a58d9SAndroid Build Coastguard Worker        default=None,
813*800a58d9SAndroid Build Coastguard Worker        help=("'cheeps only' The L1 betty version to use. Only makes sense "
814*800a58d9SAndroid Build Coastguard Worker              "when launching a controller image with "
815*800a58d9SAndroid Build Coastguard Worker              "stable-cheeps-host-image"))
816*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
817*800a58d9SAndroid Build Coastguard Worker        "--cheeps-feature",
818*800a58d9SAndroid Build Coastguard Worker        type=str,
819*800a58d9SAndroid Build Coastguard Worker        dest="cheeps_features",
820*800a58d9SAndroid Build Coastguard Worker        required=False,
821*800a58d9SAndroid Build Coastguard Worker        action="append",
822*800a58d9SAndroid Build Coastguard Worker        default=[],
823*800a58d9SAndroid Build Coastguard Worker        help=("'cheeps only' Cheeps feature to enable. Can be repeated."))
824*800a58d9SAndroid Build Coastguard Worker
825*800a58d9SAndroid Build Coastguard Worker    # Arguments for trusty type
826*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
827*800a58d9SAndroid Build Coastguard Worker        "--trusty-host-package",
828*800a58d9SAndroid Build Coastguard Worker        type=str,
829*800a58d9SAndroid Build Coastguard Worker        dest="trusty_host_package",
830*800a58d9SAndroid Build Coastguard Worker        required=False,
831*800a58d9SAndroid Build Coastguard Worker        help="Use the specified path of the trusty host package to create "
832*800a58d9SAndroid Build Coastguard Worker        "instances. e.g. /path/trusty-host_package.tar.gz")
833*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
834*800a58d9SAndroid Build Coastguard Worker        "--local-trusty-image",
835*800a58d9SAndroid Build Coastguard Worker        type=str,
836*800a58d9SAndroid Build Coastguard Worker        dest="local_trusty_image",
837*800a58d9SAndroid Build Coastguard Worker        required=False,
838*800a58d9SAndroid Build Coastguard Worker        help="'trusty only' Use the specified path for the locally built "
839*800a58d9SAndroid Build Coastguard Worker        "trusty emulator images package, built with "
840*800a58d9SAndroid Build Coastguard Worker        "PACKAGE_TRUSTY_IMAGE_TARBALL=true in the Trusty build. E.g., "
841*800a58d9SAndroid Build Coastguard Worker        "/path/trusty_image_package.tar.gz")
842*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
843*800a58d9SAndroid Build Coastguard Worker        "--trusty-build-id",
844*800a58d9SAndroid Build Coastguard Worker        type=str,
845*800a58d9SAndroid Build Coastguard Worker        dest="trusty_build_id",
846*800a58d9SAndroid Build Coastguard Worker        required=False,
847*800a58d9SAndroid Build Coastguard Worker        help="Trusty image package build ID, e.g., 8747889, 8748012.")
848*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
849*800a58d9SAndroid Build Coastguard Worker        "--trusty-branch",
850*800a58d9SAndroid Build Coastguard Worker        type=str,
851*800a58d9SAndroid Build Coastguard Worker        dest="trusty_branch",
852*800a58d9SAndroid Build Coastguard Worker        required=False,
853*800a58d9SAndroid Build Coastguard Worker        help="Trusty image package branch, e.g., aosp-trusty-master.")
854*800a58d9SAndroid Build Coastguard Worker    create_parser.add_argument(
855*800a58d9SAndroid Build Coastguard Worker        "--trusty-build-target",
856*800a58d9SAndroid Build Coastguard Worker        type=str,
857*800a58d9SAndroid Build Coastguard Worker        dest="trusty_build_target",
858*800a58d9SAndroid Build Coastguard Worker        required=False,
859*800a58d9SAndroid Build Coastguard Worker        help="Trusty image package build target, "
860*800a58d9SAndroid Build Coastguard Worker        "e.g., qemu_generic_arm64_test_debug.")
861*800a58d9SAndroid Build Coastguard Worker
862*800a58d9SAndroid Build Coastguard Worker    AddCommonCreateArgs(create_parser)
863*800a58d9SAndroid Build Coastguard Worker    return create_parser
864*800a58d9SAndroid Build Coastguard Worker
865*800a58d9SAndroid Build Coastguard Worker
866*800a58d9SAndroid Build Coastguard Workerdef _PositiveInteger(arg):
867*800a58d9SAndroid Build Coastguard Worker    """Convert an argument from a string to a positive integer."""
868*800a58d9SAndroid Build Coastguard Worker    try:
869*800a58d9SAndroid Build Coastguard Worker        value = int(arg)
870*800a58d9SAndroid Build Coastguard Worker    except ValueError as e:
871*800a58d9SAndroid Build Coastguard Worker        raise argparse.ArgumentTypeError(arg + " is not an integer.") from e
872*800a58d9SAndroid Build Coastguard Worker    if value <= 0:
873*800a58d9SAndroid Build Coastguard Worker        raise argparse.ArgumentTypeError(arg + " is not positive.")
874*800a58d9SAndroid Build Coastguard Worker    return value
875*800a58d9SAndroid Build Coastguard Worker
876*800a58d9SAndroid Build Coastguard Worker
877*800a58d9SAndroid Build Coastguard Workerdef _VerifyLocalArgs(args):
878*800a58d9SAndroid Build Coastguard Worker    """Verify args starting with --local.
879*800a58d9SAndroid Build Coastguard Worker
880*800a58d9SAndroid Build Coastguard Worker    Args:
881*800a58d9SAndroid Build Coastguard Worker        args: Namespace object from argparse.parse_args.
882*800a58d9SAndroid Build Coastguard Worker
883*800a58d9SAndroid Build Coastguard Worker    Raises:
884*800a58d9SAndroid Build Coastguard Worker        errors.CheckPathError: Image path doesn't exist.
885*800a58d9SAndroid Build Coastguard Worker        errors.UnsupportedCreateArgs: The specified avd type does not support
886*800a58d9SAndroid Build Coastguard Worker                                      a provided argument.
887*800a58d9SAndroid Build Coastguard Worker        errors.UnsupportedLocalInstanceId: Local instance ID is invalid.
888*800a58d9SAndroid Build Coastguard Worker    """
889*800a58d9SAndroid Build Coastguard Worker    if args.local_image and not os.path.exists(args.local_image):
890*800a58d9SAndroid Build Coastguard Worker        raise errors.CheckPathError(
891*800a58d9SAndroid Build Coastguard Worker            "Specified path doesn't exist: %s" % args.local_image)
892*800a58d9SAndroid Build Coastguard Worker
893*800a58d9SAndroid Build Coastguard Worker    if args.local_instance_dir and not os.path.exists(args.local_instance_dir):
894*800a58d9SAndroid Build Coastguard Worker        raise errors.CheckPathError(
895*800a58d9SAndroid Build Coastguard Worker            "Specified path doesn't exist: %s" % args.local_instance_dir)
896*800a58d9SAndroid Build Coastguard Worker
897*800a58d9SAndroid Build Coastguard Worker    if not (args.local_system_image is None or
898*800a58d9SAndroid Build Coastguard Worker            args.avd_type in (constants.TYPE_CF, constants.TYPE_GF)):
899*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs("%s instance does not support "
900*800a58d9SAndroid Build Coastguard Worker                                           "--local-system-image" %
901*800a58d9SAndroid Build Coastguard Worker                                           args.avd_type)
902*800a58d9SAndroid Build Coastguard Worker    # TODO(b/179340595): To support local image remote instance with kernel build.
903*800a58d9SAndroid Build Coastguard Worker    if args.local_instance is None and args.local_image is not None and (
904*800a58d9SAndroid Build Coastguard Worker            args.kernel_branch or args.kernel_build_id):
905*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
906*800a58d9SAndroid Build Coastguard Worker            "Acloud didn't support local image with specific kernel. "
907*800a58d9SAndroid Build Coastguard Worker            "Please download the specific kernel and put it into "
908*800a58d9SAndroid Build Coastguard Worker            "your local image folder: '%s'." % (
909*800a58d9SAndroid Build Coastguard Worker            args.local_image if args.local_image else
910*800a58d9SAndroid Build Coastguard Worker            utils.GetBuildEnvironmentVariable(constants.ENV_ANDROID_PRODUCT_OUT)))
911*800a58d9SAndroid Build Coastguard Worker
912*800a58d9SAndroid Build Coastguard Worker    if (args.local_system_image and
913*800a58d9SAndroid Build Coastguard Worker            not os.path.exists(args.local_system_image)):
914*800a58d9SAndroid Build Coastguard Worker        raise errors.CheckPathError(
915*800a58d9SAndroid Build Coastguard Worker            "Specified path doesn't exist: %s" % args.local_system_image)
916*800a58d9SAndroid Build Coastguard Worker
917*800a58d9SAndroid Build Coastguard Worker    for tool_dir in args.local_tool:
918*800a58d9SAndroid Build Coastguard Worker        if not os.path.exists(tool_dir):
919*800a58d9SAndroid Build Coastguard Worker            raise errors.CheckPathError(
920*800a58d9SAndroid Build Coastguard Worker                "Specified path doesn't exist: %s" % tool_dir)
921*800a58d9SAndroid Build Coastguard Worker
922*800a58d9SAndroid Build Coastguard Worker
923*800a58d9SAndroid Build Coastguard Workerdef _VerifyHostArgs(args):
924*800a58d9SAndroid Build Coastguard Worker    """Verify args starting with --host.
925*800a58d9SAndroid Build Coastguard Worker
926*800a58d9SAndroid Build Coastguard Worker    Args:
927*800a58d9SAndroid Build Coastguard Worker        args: Namespace object from argparse.parse_args.
928*800a58d9SAndroid Build Coastguard Worker
929*800a58d9SAndroid Build Coastguard Worker    Raises:
930*800a58d9SAndroid Build Coastguard Worker        errors.UnsupportedCreateArgs: When a create arg is specified but
931*800a58d9SAndroid Build Coastguard Worker                                      unsupported for remote host mode.
932*800a58d9SAndroid Build Coastguard Worker    """
933*800a58d9SAndroid Build Coastguard Worker    if args.remote_host and args.local_instance is not None:
934*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
935*800a58d9SAndroid Build Coastguard Worker            "--host is not supported for local instance.")
936*800a58d9SAndroid Build Coastguard Worker
937*800a58d9SAndroid Build Coastguard Worker    if args.remote_host and args.num > 1:
938*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
939*800a58d9SAndroid Build Coastguard Worker            "--num is not supported for remote host.")
940*800a58d9SAndroid Build Coastguard Worker
941*800a58d9SAndroid Build Coastguard Worker    if args.host_user != constants.GCE_USER and args.remote_host is None:
942*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
943*800a58d9SAndroid Build Coastguard Worker            "--host-user is only supported for remote host.")
944*800a58d9SAndroid Build Coastguard Worker
945*800a58d9SAndroid Build Coastguard Worker    if args.host_ssh_private_key_path and args.remote_host is None:
946*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
947*800a58d9SAndroid Build Coastguard Worker            "--host-ssh-private-key-path is only supported for remote host.")
948*800a58d9SAndroid Build Coastguard Worker
949*800a58d9SAndroid Build Coastguard Worker    if args.remote_image_dir:
950*800a58d9SAndroid Build Coastguard Worker        if args.remote_host is None:
951*800a58d9SAndroid Build Coastguard Worker            raise errors.UnsupportedCreateArgs(
952*800a58d9SAndroid Build Coastguard Worker                "--remote-image-dir is only supported for remote host.")
953*800a58d9SAndroid Build Coastguard Worker        if remote_path.basename(
954*800a58d9SAndroid Build Coastguard Worker                remote_path.normpath(args.remote_image_dir)) in ("..", "."):
955*800a58d9SAndroid Build Coastguard Worker            raise errors.UnsupportedCreateArgs(
956*800a58d9SAndroid Build Coastguard Worker                "--remote-image-dir must not include the working directory.")
957*800a58d9SAndroid Build Coastguard Worker
958*800a58d9SAndroid Build Coastguard Worker
959*800a58d9SAndroid Build Coastguard Workerdef _VerifyGoldfishArgs(args):
960*800a58d9SAndroid Build Coastguard Worker    """Verify goldfish args.
961*800a58d9SAndroid Build Coastguard Worker
962*800a58d9SAndroid Build Coastguard Worker    Args:
963*800a58d9SAndroid Build Coastguard Worker        args: Namespace object from argparse.parse_args.
964*800a58d9SAndroid Build Coastguard Worker
965*800a58d9SAndroid Build Coastguard Worker    Raises:
966*800a58d9SAndroid Build Coastguard Worker        errors.UnsupportedCreateArgs: When a create arg is specified but
967*800a58d9SAndroid Build Coastguard Worker                                      unsupported for goldfish.
968*800a58d9SAndroid Build Coastguard Worker    """
969*800a58d9SAndroid Build Coastguard Worker    goldfish_only_flags = [
970*800a58d9SAndroid Build Coastguard Worker        args.emulator_build_id,
971*800a58d9SAndroid Build Coastguard Worker        args.emulator_build_target,
972*800a58d9SAndroid Build Coastguard Worker        args.emulator_zip
973*800a58d9SAndroid Build Coastguard Worker    ]
974*800a58d9SAndroid Build Coastguard Worker    if args.avd_type != constants.TYPE_GF and any(goldfish_only_flags):
975*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
976*800a58d9SAndroid Build Coastguard Worker            f"--emulator-* is only valid with avd_type == {constants.TYPE_GF}")
977*800a58d9SAndroid Build Coastguard Worker
978*800a58d9SAndroid Build Coastguard Worker    # Exclude kernel_build_target because the default value isn't empty.
979*800a58d9SAndroid Build Coastguard Worker    remote_kernel_flags = [
980*800a58d9SAndroid Build Coastguard Worker        args.kernel_build_id,
981*800a58d9SAndroid Build Coastguard Worker        args.kernel_branch,
982*800a58d9SAndroid Build Coastguard Worker    ]
983*800a58d9SAndroid Build Coastguard Worker    if args.avd_type == constants.TYPE_GF and any(remote_kernel_flags):
984*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
985*800a58d9SAndroid Build Coastguard Worker            "--kernel-* is not supported for goldfish.")
986*800a58d9SAndroid Build Coastguard Worker
987*800a58d9SAndroid Build Coastguard Worker    remote_boot_flags = [
988*800a58d9SAndroid Build Coastguard Worker        args.boot_build_id,
989*800a58d9SAndroid Build Coastguard Worker        args.boot_build_target,
990*800a58d9SAndroid Build Coastguard Worker        args.boot_branch,
991*800a58d9SAndroid Build Coastguard Worker        args.boot_artifact,
992*800a58d9SAndroid Build Coastguard Worker    ]
993*800a58d9SAndroid Build Coastguard Worker    if (args.avd_type == constants.TYPE_GF and any(remote_boot_flags) and
994*800a58d9SAndroid Build Coastguard Worker            not all(remote_boot_flags)):
995*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
996*800a58d9SAndroid Build Coastguard Worker            "Either none or all of --boot-branch, --boot-build-target, "
997*800a58d9SAndroid Build Coastguard Worker            "--boot-build-id, and --boot-artifact must be specified for "
998*800a58d9SAndroid Build Coastguard Worker            "goldfish.")
999*800a58d9SAndroid Build Coastguard Worker
1000*800a58d9SAndroid Build Coastguard Worker    remote_system_flags = [
1001*800a58d9SAndroid Build Coastguard Worker        args.system_build_target,
1002*800a58d9SAndroid Build Coastguard Worker        args.system_build_id,
1003*800a58d9SAndroid Build Coastguard Worker        args.system_branch,
1004*800a58d9SAndroid Build Coastguard Worker    ]
1005*800a58d9SAndroid Build Coastguard Worker    if (args.avd_type == constants.TYPE_GF and any(remote_system_flags) and
1006*800a58d9SAndroid Build Coastguard Worker            not all(remote_system_flags)):
1007*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
1008*800a58d9SAndroid Build Coastguard Worker            "Either none or all of --system-branch, --system-build-target, "
1009*800a58d9SAndroid Build Coastguard Worker            "and --system-build-id must be specified for goldfish.")
1010*800a58d9SAndroid Build Coastguard Worker
1011*800a58d9SAndroid Build Coastguard Worker    remote_host_only_flags = remote_boot_flags + remote_system_flags
1012*800a58d9SAndroid Build Coastguard Worker    if args.avd_type == constants.TYPE_GF and args.remote_host is None and any(
1013*800a58d9SAndroid Build Coastguard Worker            remote_host_only_flags):
1014*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
1015*800a58d9SAndroid Build Coastguard Worker            "--boot-* and --system-* for goldfish are only supported for "
1016*800a58d9SAndroid Build Coastguard Worker            "remote host.")
1017*800a58d9SAndroid Build Coastguard Worker
1018*800a58d9SAndroid Build Coastguard Worker
1019*800a58d9SAndroid Build Coastguard Workerdef _VerifyTrustyArgs(args):
1020*800a58d9SAndroid Build Coastguard Worker    """Verify trusty args.
1021*800a58d9SAndroid Build Coastguard Worker
1022*800a58d9SAndroid Build Coastguard Worker    Args:
1023*800a58d9SAndroid Build Coastguard Worker        args: Namespace object from argparse.parse_args.
1024*800a58d9SAndroid Build Coastguard Worker
1025*800a58d9SAndroid Build Coastguard Worker    Raises:
1026*800a58d9SAndroid Build Coastguard Worker        errors.UnsupportedCreateArgs: When specified arguments are
1027*800a58d9SAndroid Build Coastguard Worker                                      unsupported for trusty.
1028*800a58d9SAndroid Build Coastguard Worker        errors.CheckPathError: A specified local path does not exist.
1029*800a58d9SAndroid Build Coastguard Worker    """
1030*800a58d9SAndroid Build Coastguard Worker    if args.avd_type != constants.TYPE_TRUSTY:
1031*800a58d9SAndroid Build Coastguard Worker        if args.local_trusty_image:
1032*800a58d9SAndroid Build Coastguard Worker            raise errors.UnsupportedCreateArgs(
1033*800a58d9SAndroid Build Coastguard Worker                "--local-trusty-image is only valid with "
1034*800a58d9SAndroid Build Coastguard Worker                f"avd_type == {constants.TYPE_TRUSTY}")
1035*800a58d9SAndroid Build Coastguard Worker        if args.trusty_host_package:
1036*800a58d9SAndroid Build Coastguard Worker            raise errors.UnsupportedCreateArgs(
1037*800a58d9SAndroid Build Coastguard Worker                "--trusty-host-package is only valid with "
1038*800a58d9SAndroid Build Coastguard Worker                f"avd_type == {constants.TYPE_TRUSTY}")
1039*800a58d9SAndroid Build Coastguard Worker        # Only check these args if AVD type is Trusty
1040*800a58d9SAndroid Build Coastguard Worker        return
1041*800a58d9SAndroid Build Coastguard Worker
1042*800a58d9SAndroid Build Coastguard Worker    for arg_type, unsupported_args in [
1043*800a58d9SAndroid Build Coastguard Worker        (
1044*800a58d9SAndroid Build Coastguard Worker            "--boot-*",
1045*800a58d9SAndroid Build Coastguard Worker            [
1046*800a58d9SAndroid Build Coastguard Worker                args.boot_build_id,
1047*800a58d9SAndroid Build Coastguard Worker                args.boot_build_target,
1048*800a58d9SAndroid Build Coastguard Worker                args.boot_branch,
1049*800a58d9SAndroid Build Coastguard Worker                args.boot_artifact,
1050*800a58d9SAndroid Build Coastguard Worker            ],
1051*800a58d9SAndroid Build Coastguard Worker        ),
1052*800a58d9SAndroid Build Coastguard Worker        (
1053*800a58d9SAndroid Build Coastguard Worker            "--bootloader-*",
1054*800a58d9SAndroid Build Coastguard Worker            [
1055*800a58d9SAndroid Build Coastguard Worker                args.bootloader_build_id,
1056*800a58d9SAndroid Build Coastguard Worker                args.bootloader_build_target,
1057*800a58d9SAndroid Build Coastguard Worker                args.bootloader_branch,
1058*800a58d9SAndroid Build Coastguard Worker            ],
1059*800a58d9SAndroid Build Coastguard Worker        ),
1060*800a58d9SAndroid Build Coastguard Worker        (
1061*800a58d9SAndroid Build Coastguard Worker            "--android-efi-loader-*",
1062*800a58d9SAndroid Build Coastguard Worker            [
1063*800a58d9SAndroid Build Coastguard Worker                args.android_efi_loader_build_id,
1064*800a58d9SAndroid Build Coastguard Worker                args.android_efi_loader_artifact,
1065*800a58d9SAndroid Build Coastguard Worker            ],
1066*800a58d9SAndroid Build Coastguard Worker        ),
1067*800a58d9SAndroid Build Coastguard Worker        (
1068*800a58d9SAndroid Build Coastguard Worker            "--ota-*",
1069*800a58d9SAndroid Build Coastguard Worker            [
1070*800a58d9SAndroid Build Coastguard Worker                args.ota_branch,
1071*800a58d9SAndroid Build Coastguard Worker                args.ota_build_target,
1072*800a58d9SAndroid Build Coastguard Worker                args.ota_build_id,
1073*800a58d9SAndroid Build Coastguard Worker            ],
1074*800a58d9SAndroid Build Coastguard Worker        ),
1075*800a58d9SAndroid Build Coastguard Worker    ]:
1076*800a58d9SAndroid Build Coastguard Worker        if any(unsupported_args):
1077*800a58d9SAndroid Build Coastguard Worker            raise errors.UnsupportedCreateArgs(
1078*800a58d9SAndroid Build Coastguard Worker                f"{arg_type} is not supported for Trusty."
1079*800a58d9SAndroid Build Coastguard Worker            )
1080*800a58d9SAndroid Build Coastguard Worker
1081*800a58d9SAndroid Build Coastguard Worker    if args.local_image is None and not args.build_target:
1082*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
1083*800a58d9SAndroid Build Coastguard Worker            "Trusty android build target not provided and cannot be "
1084*800a58d9SAndroid Build Coastguard Worker            "auto-detected, use --build-target to specify a build target, "
1085*800a58d9SAndroid Build Coastguard Worker            "e.g. qemu_trusty_arm64-trunk_staging-userdebug")
1086*800a58d9SAndroid Build Coastguard Worker    if args.local_trusty_image:
1087*800a58d9SAndroid Build Coastguard Worker        if not os.path.exists(args.local_trusty_image):
1088*800a58d9SAndroid Build Coastguard Worker            raise errors.CheckPathError(
1089*800a58d9SAndroid Build Coastguard Worker                f"Specified path doesn't exist: {args.local_trusty_image}")
1090*800a58d9SAndroid Build Coastguard Worker    if args.trusty_host_package:
1091*800a58d9SAndroid Build Coastguard Worker        if not os.path.exists(args.trusty_host_package):
1092*800a58d9SAndroid Build Coastguard Worker            raise errors.CheckPathError(
1093*800a58d9SAndroid Build Coastguard Worker                f"Specified path doesn't exist: {args.trusty_host_package}")
1094*800a58d9SAndroid Build Coastguard Worker
1095*800a58d9SAndroid Build Coastguard Worker
1096*800a58d9SAndroid Build Coastguard Workerdef VerifyArgs(args):
1097*800a58d9SAndroid Build Coastguard Worker    """Verify args.
1098*800a58d9SAndroid Build Coastguard Worker
1099*800a58d9SAndroid Build Coastguard Worker    Args:
1100*800a58d9SAndroid Build Coastguard Worker        args: Namespace object from argparse.parse_args.
1101*800a58d9SAndroid Build Coastguard Worker
1102*800a58d9SAndroid Build Coastguard Worker    Raises:
1103*800a58d9SAndroid Build Coastguard Worker        errors.UnsupportedMultiAdbPort: multi adb port doesn't support.
1104*800a58d9SAndroid Build Coastguard Worker        errors.UnsupportedCreateArgs: When a create arg is specified but
1105*800a58d9SAndroid Build Coastguard Worker                                      unsupported for a particular avd type.
1106*800a58d9SAndroid Build Coastguard Worker                                      (e.g. --system-build-id for gf)
1107*800a58d9SAndroid Build Coastguard Worker    """
1108*800a58d9SAndroid Build Coastguard Worker    # Verify that user specified flavor name is in support list.
1109*800a58d9SAndroid Build Coastguard Worker    # We don't use argparse's builtin validation because we need to be able to
1110*800a58d9SAndroid Build Coastguard Worker    # tell when a user doesn't specify a flavor.
1111*800a58d9SAndroid Build Coastguard Worker    if args.flavor and args.flavor not in constants.ALL_FLAVORS:
1112*800a58d9SAndroid Build Coastguard Worker        logger.debug("Flavor[%s] isn't in default support list: %s",
1113*800a58d9SAndroid Build Coastguard Worker                     args.flavor, constants.ALL_FLAVORS)
1114*800a58d9SAndroid Build Coastguard Worker
1115*800a58d9SAndroid Build Coastguard Worker    if args.avd_type not in (constants.TYPE_CF, constants.TYPE_GF):
1116*800a58d9SAndroid Build Coastguard Worker        if args.system_branch or args.system_build_id or args.system_build_target:
1117*800a58d9SAndroid Build Coastguard Worker            raise errors.UnsupportedCreateArgs(
1118*800a58d9SAndroid Build Coastguard Worker                "--system-* args are not supported for AVD type: %s"
1119*800a58d9SAndroid Build Coastguard Worker                % args.avd_type)
1120*800a58d9SAndroid Build Coastguard Worker
1121*800a58d9SAndroid Build Coastguard Worker    if args.num > 1 and args.adb_port:
1122*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedMultiAdbPort(
1123*800a58d9SAndroid Build Coastguard Worker            "--adb-port is not supported for multi-devices.")
1124*800a58d9SAndroid Build Coastguard Worker
1125*800a58d9SAndroid Build Coastguard Worker    if args.num > 1 and args.local_instance is not None:
1126*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
1127*800a58d9SAndroid Build Coastguard Worker            "--num is not supported for local instance.")
1128*800a58d9SAndroid Build Coastguard Worker
1129*800a58d9SAndroid Build Coastguard Worker    if args.local_instance is None and args.gpu == _DEFAULT_GPU:
1130*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
1131*800a58d9SAndroid Build Coastguard Worker            "Please assign one gpu model for GCE instance. Reference: "
1132*800a58d9SAndroid Build Coastguard Worker            "https://cloud.google.com/compute/docs/gpus")
1133*800a58d9SAndroid Build Coastguard Worker
1134*800a58d9SAndroid Build Coastguard Worker    if args.adb_port:
1135*800a58d9SAndroid Build Coastguard Worker        utils.CheckPortFree(args.adb_port)
1136*800a58d9SAndroid Build Coastguard Worker
1137*800a58d9SAndroid Build Coastguard Worker    hw_properties = create_common.ParseKeyValuePairArgs(args.hw_property)
1138*800a58d9SAndroid Build Coastguard Worker    for key in hw_properties:
1139*800a58d9SAndroid Build Coastguard Worker        if key not in constants.HW_PROPERTIES:
1140*800a58d9SAndroid Build Coastguard Worker            raise errors.InvalidHWPropertyError(
1141*800a58d9SAndroid Build Coastguard Worker                "[%s] is an invalid hw property, supported values are:%s. "
1142*800a58d9SAndroid Build Coastguard Worker                % (key, constants.HW_PROPERTIES))
1143*800a58d9SAndroid Build Coastguard Worker
1144*800a58d9SAndroid Build Coastguard Worker    cheeps_only_flags = [args.stable_cheeps_host_image_name,
1145*800a58d9SAndroid Build Coastguard Worker                         args.stable_cheeps_host_image_project,
1146*800a58d9SAndroid Build Coastguard Worker                         args.username,
1147*800a58d9SAndroid Build Coastguard Worker                         args.password,
1148*800a58d9SAndroid Build Coastguard Worker                         args.cheeps_betty_image,
1149*800a58d9SAndroid Build Coastguard Worker                         args.cheeps_features]
1150*800a58d9SAndroid Build Coastguard Worker    if args.avd_type != constants.TYPE_CHEEPS and any(cheeps_only_flags):
1151*800a58d9SAndroid Build Coastguard Worker        raise errors.UnsupportedCreateArgs(
1152*800a58d9SAndroid Build Coastguard Worker            "--stable-cheeps-*, --betty-image, --cheeps-feature, --username "
1153*800a58d9SAndroid Build Coastguard Worker            "and --password are only valid with avd_type == %s"
1154*800a58d9SAndroid Build Coastguard Worker            % constants.TYPE_CHEEPS)
1155*800a58d9SAndroid Build Coastguard Worker    if (args.username or args.password) and not (args.username and args.password):
1156*800a58d9SAndroid Build Coastguard Worker        raise ValueError("--username and --password must both be set")
1157*800a58d9SAndroid Build Coastguard Worker    if not args.autoconnect and args.unlock_screen:
1158*800a58d9SAndroid Build Coastguard Worker        raise ValueError("--no-autoconnect and --unlock couldn't be "
1159*800a58d9SAndroid Build Coastguard Worker                         "passed in together.")
1160*800a58d9SAndroid Build Coastguard Worker
1161*800a58d9SAndroid Build Coastguard Worker    _VerifyGoldfishArgs(args)
1162*800a58d9SAndroid Build Coastguard Worker    _VerifyTrustyArgs(args)
1163*800a58d9SAndroid Build Coastguard Worker    _VerifyLocalArgs(args)
1164*800a58d9SAndroid Build Coastguard Worker    _VerifyHostArgs(args)
1165