• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#
3# Copyright 2016 - The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17"""Common code used by both acloud and acloud_kernel tools."""
18
19import argparse
20
21
22def AddCommonArguments(parser):
23    """Adds arguments common to parsers.
24
25    Args:
26        parser: ArgumentParser object, used to parse flags.
27    """
28    parser.add_argument("--email",
29                        type=str,
30                        dest="email",
31                        help="Email account to use for authentcation.")
32    parser.add_argument("--config-file",
33                        type=str,
34                        dest="config_file",
35                        default=None,
36                        help="Path to the config file, default to "
37                        "acloud.config in the current working directory.")
38    parser.add_argument("--service-account-json-private-key-path",
39                        type=str,
40                        dest="service_account_json_private_key_path",
41                        help="Path to service account's json private key "
42                        "file.")
43    parser.add_argument("--report-file",
44                        type=str,
45                        dest="report_file",
46                        default=None,
47                        help="Dump the report this file in json format. "
48                        "If not specified, just log the report.")
49    parser.add_argument("--log-file",
50                        dest="log_file",
51                        type=str,
52                        default=None,
53                        help="Path to log file.")
54    parser.add_argument('--verbose', '-v',
55                        action='count',
56                        default=0,
57                        help="Enable verbose log. Use --verbose or -v for "
58                        "logging at INFO level, and -vv for DEBUG level.")
59    parser.add_argument("--no-metrics",
60                        action="store_true",
61                        dest="no_metrics",
62                        required=False,
63                        default=False,
64                        help="Don't log metrics.")
65
66    # Allow for using the underscore args as well to keep it backward
67    # compatible with the infra use case. Remove when g3 acloud is
68    # deprecated (b/118439885).
69    parser.add_argument("--config_file",
70                        type=str,
71                        dest="config_file",
72                        default=None,
73                        help=argparse.SUPPRESS)
74    parser.add_argument("--service_account_json_private_key_path",
75                        type=str,
76                        dest="service_account_json_private_key_path",
77                        help=argparse.SUPPRESS)
78    parser.add_argument("--report_file",
79                        type=str,
80                        dest="report_file",
81                        default=None,
82                        help=argparse.SUPPRESS)
83    parser.add_argument("--log_file",
84                        dest="log_file",
85                        type=str,
86                        default=None,
87                        help=argparse.SUPPRESS)
88