xref: /aosp_15_r20/tools/acloud/restart/restart_args.py (revision 800a58d989c669b8eb8a71d8df53b1ba3d411444)
1*800a58d9SAndroid Build Coastguard Worker# Copyright 2021 - 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"""Restart args.
15*800a58d9SAndroid Build Coastguard Worker
16*800a58d9SAndroid Build Coastguard WorkerDefines the restart arg parser that holds restart specific args.
17*800a58d9SAndroid Build Coastguard Worker"""
18*800a58d9SAndroid Build Coastguard Workerimport argparse
19*800a58d9SAndroid Build Coastguard Worker
20*800a58d9SAndroid Build Coastguard Worker
21*800a58d9SAndroid Build Coastguard WorkerCMD_RESTART = "restart"
22*800a58d9SAndroid Build Coastguard Worker
23*800a58d9SAndroid Build Coastguard Worker
24*800a58d9SAndroid Build Coastguard Workerdef GetRestartArgParser(subparser):
25*800a58d9SAndroid Build Coastguard Worker    """Return the restart arg parser.
26*800a58d9SAndroid Build Coastguard Worker
27*800a58d9SAndroid Build Coastguard Worker    Args:
28*800a58d9SAndroid Build Coastguard Worker       subparser: argparse.ArgumentParser that is attached to main acloud cmd.
29*800a58d9SAndroid Build Coastguard Worker
30*800a58d9SAndroid Build Coastguard Worker    Returns:
31*800a58d9SAndroid Build Coastguard Worker        argparse.ArgumentParser with restart options defined.
32*800a58d9SAndroid Build Coastguard Worker    """
33*800a58d9SAndroid Build Coastguard Worker    restart_parser = subparser.add_parser(CMD_RESTART)
34*800a58d9SAndroid Build Coastguard Worker    restart_parser.required = False
35*800a58d9SAndroid Build Coastguard Worker    restart_parser.set_defaults(which=CMD_RESTART)
36*800a58d9SAndroid Build Coastguard Worker    restart_group = restart_parser.add_mutually_exclusive_group()
37*800a58d9SAndroid Build Coastguard Worker    restart_group.add_argument(
38*800a58d9SAndroid Build Coastguard Worker        "--instance-name",
39*800a58d9SAndroid Build Coastguard Worker        dest="instance_name",
40*800a58d9SAndroid Build Coastguard Worker        type=str,
41*800a58d9SAndroid Build Coastguard Worker        required=False,
42*800a58d9SAndroid Build Coastguard Worker        help="The name of the remote instance that need to restart the AVDs.")
43*800a58d9SAndroid Build Coastguard Worker    # TODO(b/118439885): Old arg formats to support transition, delete when
44*800a58d9SAndroid Build Coastguard Worker    # transistion is done.
45*800a58d9SAndroid Build Coastguard Worker    restart_group.add_argument(
46*800a58d9SAndroid Build Coastguard Worker        "--instance_name",
47*800a58d9SAndroid Build Coastguard Worker        dest="instance_name",
48*800a58d9SAndroid Build Coastguard Worker        type=str,
49*800a58d9SAndroid Build Coastguard Worker        required=False,
50*800a58d9SAndroid Build Coastguard Worker        help=argparse.SUPPRESS)
51*800a58d9SAndroid Build Coastguard Worker    restart_parser.add_argument(
52*800a58d9SAndroid Build Coastguard Worker        "--instance-id",
53*800a58d9SAndroid Build Coastguard Worker        dest="instance_id",
54*800a58d9SAndroid Build Coastguard Worker        type=int,
55*800a58d9SAndroid Build Coastguard Worker        required=False,
56*800a58d9SAndroid Build Coastguard Worker        default=1,
57*800a58d9SAndroid Build Coastguard Worker        help="The instance id of the remote instance that need to be restart.")
58*800a58d9SAndroid Build Coastguard Worker    restart_parser.add_argument(
59*800a58d9SAndroid Build Coastguard Worker        "--powerwash",
60*800a58d9SAndroid Build Coastguard Worker        dest="powerwash",
61*800a58d9SAndroid Build Coastguard Worker        action="store_true",
62*800a58d9SAndroid Build Coastguard Worker        required=False,
63*800a58d9SAndroid Build Coastguard Worker        help="Erase all userdata in the AVD.")
64*800a58d9SAndroid Build Coastguard Worker
65*800a58d9SAndroid Build Coastguard Worker    return restart_parser
66