1#!/usr/bin/env python 2# 3# Copyright 2018 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16r"""Delete args. 17 18Defines the delete arg parser that holds delete specific args. 19""" 20import argparse 21 22from acloud.internal import constants 23 24 25CMD_DELETE = "delete" 26 27 28def GetDeleteArgParser(subparser): 29 """Return the delete arg parser. 30 31 Args: 32 subparser: argparse.ArgumentParser that is attached to main acloud cmd. 33 34 Returns: 35 argparse.ArgumentParser with delete options defined. 36 """ 37 delete_parser = subparser.add_parser(CMD_DELETE) 38 delete_parser.required = False 39 delete_parser.set_defaults(which=CMD_DELETE) 40 delete_group = delete_parser.add_mutually_exclusive_group() 41 delete_group.add_argument( 42 "--instance-names", 43 dest="instance_names", 44 nargs="+", 45 required=False, 46 help="The names of the instances that need to delete, separated by " 47 "spaces, e.g. --instance-names instance-1 local-instance-1") 48 delete_group.add_argument( 49 "--all", 50 action="store_true", 51 dest="all", 52 required=False, 53 help="If more than 1 AVD instance is found, delete them all.") 54 delete_group.add_argument( 55 "--adb-port", "-p", 56 type=int, 57 dest="adb_port", 58 required=False, 59 help="Delete instance with specified adb-port.") 60 delete_parser.add_argument( 61 "--local-only", 62 action="store_true", 63 dest="local_only", 64 required=False, 65 help="Do not authenticate and query remote instances.") 66 delete_parser.add_argument( 67 "--host", 68 type=str, 69 dest="remote_host", 70 default=None, 71 help="'cuttlefish only' Provide host name to clean up the remote host. " 72 "For example: '--host 1.1.1.1'") 73 delete_parser.add_argument( 74 "--host-user", 75 type=str, 76 dest="host_user", 77 default=constants.GCE_USER, 78 help="'remote host only' Provide host user for logging in to the host. " 79 "The default value is vsoc-01. For example: '--host 1.1.1.1 --host-user " 80 "vsoc-02'") 81 delete_parser.add_argument( 82 "--host-ssh-private-key-path", 83 type=str, 84 dest="host_ssh_private_key_path", 85 default=None, 86 help="'remote host only' Provide host ssh private key path for logging " 87 "in to the host. For exmaple: '--host-ssh-private-key-path " 88 "~/.ssh/acloud_rsa'") 89 90 # TODO(b/118439885): Old arg formats to support transition, delete when 91 # transistion is done. 92 delete_group.add_argument( 93 "--instance_names", 94 dest="instance_names", 95 nargs="+", 96 required=False, 97 help=argparse.SUPPRESS) 98 99 return delete_parser 100