1# Copyright 2021 - The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14r"""Restart args. 15 16Defines the restart arg parser that holds restart specific args. 17""" 18import argparse 19 20 21CMD_RESTART = "restart" 22 23 24def GetRestartArgParser(subparser): 25 """Return the restart arg parser. 26 27 Args: 28 subparser: argparse.ArgumentParser that is attached to main acloud cmd. 29 30 Returns: 31 argparse.ArgumentParser with restart options defined. 32 """ 33 restart_parser = subparser.add_parser(CMD_RESTART) 34 restart_parser.required = False 35 restart_parser.set_defaults(which=CMD_RESTART) 36 restart_group = restart_parser.add_mutually_exclusive_group() 37 restart_group.add_argument( 38 "--instance-name", 39 dest="instance_name", 40 type=str, 41 required=False, 42 help="The name of the remote instance that need to restart the AVDs.") 43 # TODO(b/118439885): Old arg formats to support transition, delete when 44 # transistion is done. 45 restart_group.add_argument( 46 "--instance_name", 47 dest="instance_name", 48 type=str, 49 required=False, 50 help=argparse.SUPPRESS) 51 restart_parser.add_argument( 52 "--instance-id", 53 dest="instance_id", 54 type=int, 55 required=False, 56 default=1, 57 help="The instance id of the remote instance that need to be restart.") 58 restart_parser.add_argument( 59 "--powerwash", 60 dest="powerwash", 61 action="store_true", 62 required=False, 63 help="Erase all userdata in the AVD.") 64 65 return restart_parser 66