This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
arguments.py
161 lines (152 loc) · 4.5 KB
/
arguments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# !/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2022 Seagate Technology LLC and/or its Affiliates
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# For any questions about this software or licensing,
# please email opensource@seagate.com or cortx-questions@seagate.com.
#
#
"""Module to parse commandline arguments for CORIO Driver."""
import random
from argparse import ArgumentParser, Action
from distutils.util import strtobool
def parse_args():
"""Commandline arguments for CORIO Driver."""
parser = ArgumentParser()
parser.add_argument(
"-ti",
"--test_input",
type=str,
required=True,
help="Directory path containing test data input yaml files or input yaml file path.",
)
parser.add_argument(
"-v",
"--verbose",
action="store_true",
help="log level used verbose(debug), default is info.",
)
parser.add_argument(
"-us",
"--use_ssl",
type=lambda x: bool(strtobool(str(x))),
default=True,
help="Use HTTPS/SSL connection for S3 endpoint.",
)
parser.add_argument(
"-sd",
"--seed",
type=int,
help="seed.",
default=random.SystemRandom().randint(1, 9999999),
)
parser.add_argument(
"-sk",
"--secret_key",
type=str,
nargs="+",
action=SplitArguments,
required=True,
help="One or more(space/comma separated) s3 secret Key or keys in order.",
)
parser.add_argument(
"-ak",
"--access_key",
type=str,
nargs="+",
action=SplitArguments,
required=True,
help="One or more(space/comma separated) s3 access Key or keys in order.",
)
parser.add_argument(
"-ep",
"--endpoint",
type=str,
required=True,
help="fqdn/ip:port of s3 endpoint for io operations without http/https."
"protocol in endpoint is based on use_ssl flag.",
default="s3.seagate.com",
)
parser.add_argument(
"-nn",
"--number_of_nodes",
type=int,
help="number of nodes in k8s system",
default=1,
)
parser.add_argument(
"-sb",
"--support_bundle",
type=lambda x: bool(strtobool(str(x))),
default=False,
help="Capture Support bundle.",
)
parser.add_argument(
"-hc",
"--health_check",
type=lambda x: bool(strtobool(str(x))),
default=False,
help="Health Check.",
)
parser.add_argument(
"-tp",
"--test_plan",
type=str,
default=None,
help="jira xray test plan id"
)
parser.add_argument(
"-dm",
"--degraded_mode",
type=lambda x: bool(strtobool(str(x))),
default=False,
help="Degraded Mode, True/False",
)
parser.add_argument(
"-mr",
"--s3max_retry",
type=int,
default=0,
help="Max number of retries in case of any type of failure.",
)
parser.add_argument(
"-sr",
"--sequential_run",
action="store_true",
help="Run test sequentially from workload.",
)
return parser.parse_args()
class SplitArguments(Action):
"""Split space, comma separated arguments and set it to list."""
def __call__(self, parser, namespace, values, option_string=None) -> None:
"""strip comma from arguments."""
setattr(
namespace,
self.dest,
[
value.strip(",")
for value in (
values
if isinstance(values, list)
else (values.split(",") if ", " in values else values.split())
if isinstance(values, str)
else values
)
],
)
def __repr__(self):
"""string representation."""
return repr(self)
opts = parse_args()