Alex | 0989ecf | 2022-03-29 13:43:21 -0500 | [diff] [blame] | 1 | # Author: Alex Savatieiev (osavatieiev@mirantis.com; a.savex@gmail.com) |
| 2 | # Copyright 2019-2022 Mirantis, Inc. |
Alex | ccb72e0 | 2021-01-20 16:38:03 -0600 | [diff] [blame] | 3 | import os |
| 4 | |
| 5 | from cfg_checker.common.settings import pkg_dir |
| 6 | |
| 7 | _env_name = "local" |
| 8 | _config_path = os.path.join(pkg_dir, 'etc', _env_name + '.env') |
| 9 | |
| 10 | |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 11 | def add_global_arguments(parser): |
| 12 | parser.add_argument( |
| 13 | "-d", |
| 14 | "--debug", |
| 15 | action="store_true", default=False, |
| 16 | help="Set CLI logging level to DEBUG" |
| 17 | ) |
| 18 | parser.add_argument( |
Alex | 3374781 | 2021-04-07 10:11:39 -0500 | [diff] [blame] | 19 | "-k", |
| 20 | "--insecure", |
| 21 | action="store_true", default=False, |
| 22 | help="Use insecure way in SSL requests" |
| 23 | ) |
| 24 | parser.add_argument( |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 25 | '-s', |
| 26 | '--sudo', |
| 27 | action='store_true', default=True, |
| 28 | help="Use sudo for getting salt creds" |
| 29 | ) |
| 30 | parser.add_argument( |
Alex | effa068 | 2021-06-04 12:18:33 -0500 | [diff] [blame] | 31 | '--ssh-direct', |
| 32 | action='store_true', default=False, |
| 33 | help="Force SSH to do direct connection instead of port forwarding" |
| 34 | ) |
| 35 | |
| 36 | parser.add_argument( |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 37 | '--force-no-key', |
| 38 | action='store_true', default=False, |
Alex | effa068 | 2021-06-04 12:18:33 -0500 | [diff] [blame] | 39 | help="Force SSH to login with no key" |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 40 | ) |
| 41 | parser.add_argument( |
| 42 | '--skip-nodes', |
| 43 | metavar='skip_string', default=None, |
| 44 | help="String with nodes to skip. Only trailing '*' supported!" |
| 45 | " Example: 'cmp*,ctl01'" |
| 46 | ) |
| 47 | parser.add_argument( |
Alex | ccb72e0 | 2021-01-20 16:38:03 -0600 | [diff] [blame] | 48 | '--kube-config', |
| 49 | metavar='kube_config', default="/root/.kube/config", |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 50 | help="Kube config path with certificates and keys. " |
| 51 | "Default: '/root/.kube/config'" |
| 52 | ) |
| 53 | parser.add_argument( |
Alex | ccb72e0 | 2021-01-20 16:38:03 -0600 | [diff] [blame] | 54 | '--force-env-type', |
| 55 | metavar='force_env_type', |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 56 | help="Specify env to use if function supports multiple among detected" |
| 57 | " Example: SALT/KUBE" |
| 58 | ) |
Alex | ccb72e0 | 2021-01-20 16:38:03 -0600 | [diff] [blame] | 59 | parser.add_argument( |
| 60 | '--env-name', |
| 61 | metavar='env_name', default=_env_name, |
| 62 | help="Use of given env name instead of MCP_ENV var" |
| 63 | "Default: {}".format(_env_name) |
| 64 | ) |
| 65 | |
| 66 | parser.add_argument( |
| 67 | '--env-config', |
| 68 | metavar='env_config', default=_config_path, |
| 69 | help="Force use of given env file" |
| 70 | "Default: '{}'".format(_config_path) |
| 71 | ) |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 72 | |
| 73 | parser.add_argument( |
| 74 | '--skip-nodes-file', |
| 75 | metavar='skip_nodes_file', default=None, |
| 76 | help="Filename with nodes to skip. Note: use fqdn node names." |
| 77 | ) |