root / scripts / gnt-debug @ 067d927b
History | View | Annotate | Download (11.5 kB)
1 | fd3ee040 | Iustin Pop | #!/usr/bin/python |
---|---|---|---|
2 | fd3ee040 | Iustin Pop | # |
3 | fd3ee040 | Iustin Pop | |
4 | fd3ee040 | Iustin Pop | # Copyright (C) 2006, 2007 Google Inc. |
5 | fd3ee040 | Iustin Pop | # |
6 | fd3ee040 | Iustin Pop | # This program is free software; you can redistribute it and/or modify |
7 | fd3ee040 | Iustin Pop | # it under the terms of the GNU General Public License as published by |
8 | fd3ee040 | Iustin Pop | # the Free Software Foundation; either version 2 of the License, or |
9 | fd3ee040 | Iustin Pop | # (at your option) any later version. |
10 | fd3ee040 | Iustin Pop | # |
11 | fd3ee040 | Iustin Pop | # This program is distributed in the hope that it will be useful, but |
12 | fd3ee040 | Iustin Pop | # WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | fd3ee040 | Iustin Pop | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | fd3ee040 | Iustin Pop | # General Public License for more details. |
15 | fd3ee040 | Iustin Pop | # |
16 | fd3ee040 | Iustin Pop | # You should have received a copy of the GNU General Public License |
17 | fd3ee040 | Iustin Pop | # along with this program; if not, write to the Free Software |
18 | fd3ee040 | Iustin Pop | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
19 | fd3ee040 | Iustin Pop | # 02110-1301, USA. |
20 | fd3ee040 | Iustin Pop | |
21 | 7260cfbe | Iustin Pop | """Debugging commands""" |
22 | fd3ee040 | Iustin Pop | |
23 | 7260cfbe | Iustin Pop | # pylint: disable-msg=W0401,W0614,C0103 |
24 | 2f79bd34 | Iustin Pop | # W0401: Wildcard import ganeti.cli |
25 | 2f79bd34 | Iustin Pop | # W0614: Unused import %s from wildcard import (since we need cli) |
26 | 7260cfbe | Iustin Pop | # C0103: Invalid name gnt-backup |
27 | 2f79bd34 | Iustin Pop | |
28 | fd3ee040 | Iustin Pop | import sys |
29 | f1c66d13 | Iustin Pop | import simplejson |
30 | f1c66d13 | Iustin Pop | import time |
31 | e58f87a9 | Michael Hanselmann | import socket |
32 | e58f87a9 | Michael Hanselmann | import logging |
33 | f1c66d13 | Iustin Pop | |
34 | fd3ee040 | Iustin Pop | from ganeti.cli import * |
35 | 9d5ba39a | Iustin Pop | from ganeti import cli |
36 | e58f87a9 | Michael Hanselmann | from ganeti import constants |
37 | fd3ee040 | Iustin Pop | from ganeti import opcodes |
38 | fd3ee040 | Iustin Pop | from ganeti import utils |
39 | fd3ee040 | Iustin Pop | from ganeti import errors |
40 | fd3ee040 | Iustin Pop | |
41 | fd3ee040 | Iustin Pop | |
42 | fd3ee040 | Iustin Pop | def Delay(opts, args): |
43 | fd3ee040 | Iustin Pop | """Sleeps for a while |
44 | fd3ee040 | Iustin Pop | |
45 | 6099bfcf | Iustin Pop | @param opts: the command line options selected by the user |
46 | 6099bfcf | Iustin Pop | @type args: list |
47 | 6099bfcf | Iustin Pop | @param args: should contain only one element, the duration |
48 | 6099bfcf | Iustin Pop | the sleep |
49 | 6099bfcf | Iustin Pop | @rtype: int |
50 | 6099bfcf | Iustin Pop | @return: the desired exit code |
51 | 6099bfcf | Iustin Pop | |
52 | fd3ee040 | Iustin Pop | """ |
53 | fd3ee040 | Iustin Pop | delay = float(args[0]) |
54 | fd3ee040 | Iustin Pop | op = opcodes.OpTestDelay(duration=delay, |
55 | fd3ee040 | Iustin Pop | on_master=opts.on_master, |
56 | 85a87e21 | Guido Trotter | on_nodes=opts.on_nodes, |
57 | 85a87e21 | Guido Trotter | repeat=opts.repeat) |
58 | 400ca2f7 | Iustin Pop | SubmitOpCode(op, opts=opts) |
59 | fd3ee040 | Iustin Pop | |
60 | fd3ee040 | Iustin Pop | return 0 |
61 | fd3ee040 | Iustin Pop | |
62 | fd3ee040 | Iustin Pop | |
63 | f1c66d13 | Iustin Pop | def GenericOpCodes(opts, args): |
64 | 6099bfcf | Iustin Pop | """Send any opcode to the master. |
65 | 6099bfcf | Iustin Pop | |
66 | 6099bfcf | Iustin Pop | @param opts: the command line options selected by the user |
67 | 6099bfcf | Iustin Pop | @type args: list |
68 | 6099bfcf | Iustin Pop | @param args: should contain only one element, the path of |
69 | 6099bfcf | Iustin Pop | the file with the opcode definition |
70 | 6099bfcf | Iustin Pop | @rtype: int |
71 | 6099bfcf | Iustin Pop | @return: the desired exit code |
72 | f1c66d13 | Iustin Pop | |
73 | f1c66d13 | Iustin Pop | """ |
74 | 9d5ba39a | Iustin Pop | cl = cli.GetClient() |
75 | cb573a31 | Iustin Pop | jex = cli.JobExecutor(cl=cl, verbose=opts.verbose, opts=opts) |
76 | 9d95c3af | Iustin Pop | |
77 | 9d95c3af | Iustin Pop | job_cnt = 0 |
78 | 9d95c3af | Iustin Pop | op_cnt = 0 |
79 | 9d95c3af | Iustin Pop | if opts.timing_stats: |
80 | 9d95c3af | Iustin Pop | ToStdout("Loading...") |
81 | 9d95c3af | Iustin Pop | for job_idx in range(opts.rep_job): |
82 | 9d95c3af | Iustin Pop | for fname in args: |
83 | 7260cfbe | Iustin Pop | # pylint: disable-msg=W0142 |
84 | 4d5fe81b | Michael Hanselmann | op_data = simplejson.loads(utils.ReadFile(fname)) |
85 | 9d95c3af | Iustin Pop | op_list = [opcodes.OpCode.LoadOpCode(val) for val in op_data] |
86 | 9d95c3af | Iustin Pop | op_list = op_list * opts.rep_op |
87 | 9d95c3af | Iustin Pop | jex.QueueJob("file %s/%d" % (fname, job_idx), *op_list) |
88 | 9d95c3af | Iustin Pop | op_cnt += len(op_list) |
89 | 9d95c3af | Iustin Pop | job_cnt += 1 |
90 | 9d95c3af | Iustin Pop | |
91 | 9d95c3af | Iustin Pop | if opts.timing_stats: |
92 | 9d95c3af | Iustin Pop | t1 = time.time() |
93 | 9d95c3af | Iustin Pop | ToStdout("Submitting...") |
94 | 4d5fe81b | Michael Hanselmann | |
95 | 66ecc479 | Guido Trotter | jex.SubmitPending(each=opts.each) |
96 | 9d95c3af | Iustin Pop | |
97 | 9d95c3af | Iustin Pop | if opts.timing_stats: |
98 | 9d95c3af | Iustin Pop | t2 = time.time() |
99 | 9d95c3af | Iustin Pop | ToStdout("Executing...") |
100 | b59252fe | Iustin Pop | |
101 | b59252fe | Iustin Pop | jex.GetResults() |
102 | 9d95c3af | Iustin Pop | if opts.timing_stats: |
103 | 9d95c3af | Iustin Pop | t3 = time.time() |
104 | 9d95c3af | Iustin Pop | ToStdout("C:op %4d" % op_cnt) |
105 | 9d95c3af | Iustin Pop | ToStdout("C:job %4d" % job_cnt) |
106 | 9d95c3af | Iustin Pop | ToStdout("T:submit %4.4f" % (t2-t1)) |
107 | 9d95c3af | Iustin Pop | ToStdout("T:exec %4.4f" % (t3-t2)) |
108 | 9d95c3af | Iustin Pop | ToStdout("T:total %4.4f" % (t3-t1)) |
109 | f1c66d13 | Iustin Pop | return 0 |
110 | f1c66d13 | Iustin Pop | |
111 | f1c66d13 | Iustin Pop | |
112 | d61df03e | Iustin Pop | def TestAllocator(opts, args): |
113 | 6099bfcf | Iustin Pop | """Runs the test allocator opcode. |
114 | d61df03e | Iustin Pop | |
115 | 6099bfcf | Iustin Pop | @param opts: the command line options selected by the user |
116 | 6099bfcf | Iustin Pop | @type args: list |
117 | 6099bfcf | Iustin Pop | @param args: should contain only one element, the iallocator name |
118 | 6099bfcf | Iustin Pop | @rtype: int |
119 | 6099bfcf | Iustin Pop | @return: the desired exit code |
120 | 6099bfcf | Iustin Pop | |
121 | 6099bfcf | Iustin Pop | """ |
122 | d61df03e | Iustin Pop | try: |
123 | d61df03e | Iustin Pop | disks = [{"size": utils.ParseUnit(val), "mode": 'w'} |
124 | d61df03e | Iustin Pop | for val in opts.disks.split(",")] |
125 | d61df03e | Iustin Pop | except errors.UnitParseError, err: |
126 | 3a24c527 | Iustin Pop | ToStderr("Invalid disks parameter '%s': %s", opts.disks, err) |
127 | d61df03e | Iustin Pop | return 1 |
128 | d61df03e | Iustin Pop | |
129 | d61df03e | Iustin Pop | nics = [val.split("/") for val in opts.nics.split(",")] |
130 | d61df03e | Iustin Pop | for row in nics: |
131 | d61df03e | Iustin Pop | while len(row) < 3: |
132 | d61df03e | Iustin Pop | row.append(None) |
133 | d61df03e | Iustin Pop | for i in range(3): |
134 | d61df03e | Iustin Pop | if row[i] == '': |
135 | d61df03e | Iustin Pop | row[i] = None |
136 | d61df03e | Iustin Pop | nic_dict = [{"mac": v[0], "ip": v[1], "bridge": v[2]} for v in nics] |
137 | d61df03e | Iustin Pop | |
138 | d61df03e | Iustin Pop | if opts.tags is None: |
139 | d61df03e | Iustin Pop | opts.tags = [] |
140 | d61df03e | Iustin Pop | else: |
141 | d61df03e | Iustin Pop | opts.tags = opts.tags.split(",") |
142 | d61df03e | Iustin Pop | |
143 | d61df03e | Iustin Pop | op = opcodes.OpTestAllocator(mode=opts.mode, |
144 | d61df03e | Iustin Pop | name=args[0], |
145 | 823a72bc | Iustin Pop | evac_nodes=args, |
146 | d61df03e | Iustin Pop | mem_size=opts.mem, |
147 | d61df03e | Iustin Pop | disks=disks, |
148 | d61df03e | Iustin Pop | disk_template=opts.disk_template, |
149 | d61df03e | Iustin Pop | nics=nic_dict, |
150 | 705dd60e | Iustin Pop | os=opts.os, |
151 | d61df03e | Iustin Pop | vcpus=opts.vcpus, |
152 | d61df03e | Iustin Pop | tags=opts.tags, |
153 | d61df03e | Iustin Pop | direction=opts.direction, |
154 | 705dd60e | Iustin Pop | allocator=opts.iallocator, |
155 | d61df03e | Iustin Pop | ) |
156 | 400ca2f7 | Iustin Pop | result = SubmitOpCode(op, opts=opts) |
157 | 3a24c527 | Iustin Pop | ToStdout("%s" % result) |
158 | d61df03e | Iustin Pop | return 0 |
159 | d61df03e | Iustin Pop | |
160 | d61df03e | Iustin Pop | |
161 | e58f87a9 | Michael Hanselmann | class _JobQueueTestReporter(cli.StdioJobPollReportCb): |
162 | e58f87a9 | Michael Hanselmann | def __init__(self): |
163 | e58f87a9 | Michael Hanselmann | """Initializes this class. |
164 | e58f87a9 | Michael Hanselmann | |
165 | e58f87a9 | Michael Hanselmann | """ |
166 | e58f87a9 | Michael Hanselmann | cli.StdioJobPollReportCb.__init__(self) |
167 | e58f87a9 | Michael Hanselmann | self._testmsgs = [] |
168 | e58f87a9 | Michael Hanselmann | self._job_id = None |
169 | e58f87a9 | Michael Hanselmann | |
170 | e58f87a9 | Michael Hanselmann | def GetTestMessages(self): |
171 | e58f87a9 | Michael Hanselmann | """Returns all test log messages received so far. |
172 | e58f87a9 | Michael Hanselmann | |
173 | e58f87a9 | Michael Hanselmann | """ |
174 | e58f87a9 | Michael Hanselmann | return self._testmsgs |
175 | e58f87a9 | Michael Hanselmann | |
176 | e58f87a9 | Michael Hanselmann | def GetJobId(self): |
177 | e58f87a9 | Michael Hanselmann | """Returns the job ID. |
178 | e58f87a9 | Michael Hanselmann | |
179 | e58f87a9 | Michael Hanselmann | """ |
180 | e58f87a9 | Michael Hanselmann | return self._job_id |
181 | e58f87a9 | Michael Hanselmann | |
182 | e58f87a9 | Michael Hanselmann | def ReportLogMessage(self, job_id, serial, timestamp, log_type, log_msg): |
183 | e58f87a9 | Michael Hanselmann | """Handles a log message. |
184 | e58f87a9 | Michael Hanselmann | |
185 | e58f87a9 | Michael Hanselmann | """ |
186 | e58f87a9 | Michael Hanselmann | if self._job_id is None: |
187 | e58f87a9 | Michael Hanselmann | self._job_id = job_id |
188 | e58f87a9 | Michael Hanselmann | elif self._job_id != job_id: |
189 | e58f87a9 | Michael Hanselmann | raise errors.ProgrammerError("The same reporter instance was used for" |
190 | e58f87a9 | Michael Hanselmann | " more than one job") |
191 | e58f87a9 | Michael Hanselmann | |
192 | e58f87a9 | Michael Hanselmann | if log_type == constants.ELOG_JQUEUE_TEST: |
193 | e58f87a9 | Michael Hanselmann | (sockname, test, arg) = log_msg |
194 | e58f87a9 | Michael Hanselmann | return self._ProcessTestMessage(job_id, sockname, test, arg) |
195 | e58f87a9 | Michael Hanselmann | |
196 | e58f87a9 | Michael Hanselmann | elif (log_type == constants.ELOG_MESSAGE and |
197 | e58f87a9 | Michael Hanselmann | log_msg.startswith(constants.JQT_MSGPREFIX)): |
198 | e58f87a9 | Michael Hanselmann | self._testmsgs.append(log_msg[len(constants.JQT_MSGPREFIX):]) |
199 | e58f87a9 | Michael Hanselmann | return |
200 | e58f87a9 | Michael Hanselmann | |
201 | e58f87a9 | Michael Hanselmann | return cli.StdioJobPollReportCb.ReportLogMessage(self, job_id, serial, |
202 | e58f87a9 | Michael Hanselmann | timestamp, log_type, |
203 | e58f87a9 | Michael Hanselmann | log_msg) |
204 | e58f87a9 | Michael Hanselmann | |
205 | e58f87a9 | Michael Hanselmann | def _ProcessTestMessage(self, job_id, sockname, test, arg): |
206 | e58f87a9 | Michael Hanselmann | """Handles a job queue test message. |
207 | e58f87a9 | Michael Hanselmann | |
208 | e58f87a9 | Michael Hanselmann | """ |
209 | e58f87a9 | Michael Hanselmann | if test not in constants.JQT_ALL: |
210 | e58f87a9 | Michael Hanselmann | raise errors.OpExecError("Received invalid test message %s" % test) |
211 | e58f87a9 | Michael Hanselmann | |
212 | e58f87a9 | Michael Hanselmann | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) |
213 | e58f87a9 | Michael Hanselmann | try: |
214 | e58f87a9 | Michael Hanselmann | sock.settimeout(30.0) |
215 | e58f87a9 | Michael Hanselmann | |
216 | e58f87a9 | Michael Hanselmann | logging.debug("Connecting to %s", sockname) |
217 | e58f87a9 | Michael Hanselmann | sock.connect(sockname) |
218 | e58f87a9 | Michael Hanselmann | |
219 | e58f87a9 | Michael Hanselmann | logging.debug("Checking status") |
220 | e58f87a9 | Michael Hanselmann | jobdetails = cli.GetClient().QueryJobs([job_id], ["status"])[0] |
221 | e58f87a9 | Michael Hanselmann | if not jobdetails: |
222 | e58f87a9 | Michael Hanselmann | raise errors.OpExecError("Can't find job %s" % job_id) |
223 | e58f87a9 | Michael Hanselmann | |
224 | e58f87a9 | Michael Hanselmann | status = jobdetails[0] |
225 | e58f87a9 | Michael Hanselmann | |
226 | e58f87a9 | Michael Hanselmann | logging.debug("Status of job %s is %s", job_id, status) |
227 | e58f87a9 | Michael Hanselmann | |
228 | e58f87a9 | Michael Hanselmann | if test == constants.JQT_EXPANDNAMES: |
229 | e58f87a9 | Michael Hanselmann | if status != constants.JOB_STATUS_WAITLOCK: |
230 | e58f87a9 | Michael Hanselmann | raise errors.OpExecError("Job status while expanding names is '%s'," |
231 | e58f87a9 | Michael Hanselmann | " not '%s' as expected" % |
232 | e58f87a9 | Michael Hanselmann | (status, constants.JOB_STATUS_WAITLOCK)) |
233 | e58f87a9 | Michael Hanselmann | elif test in (constants.JQT_EXEC, constants.JQT_LOGMSG): |
234 | e58f87a9 | Michael Hanselmann | if status != constants.JOB_STATUS_RUNNING: |
235 | e58f87a9 | Michael Hanselmann | raise errors.OpExecError("Job status while executing opcode is '%s'," |
236 | e58f87a9 | Michael Hanselmann | " not '%s' as expected" % |
237 | e58f87a9 | Michael Hanselmann | (status, constants.JOB_STATUS_RUNNING)) |
238 | e58f87a9 | Michael Hanselmann | |
239 | e58f87a9 | Michael Hanselmann | if test == constants.JQT_LOGMSG: |
240 | e58f87a9 | Michael Hanselmann | if len(self._testmsgs) != arg: |
241 | e58f87a9 | Michael Hanselmann | raise errors.OpExecError("Received %s test messages when %s are" |
242 | e58f87a9 | Michael Hanselmann | " expected" % (len(self._testmsgs), arg)) |
243 | e58f87a9 | Michael Hanselmann | finally: |
244 | e58f87a9 | Michael Hanselmann | logging.debug("Closing socket") |
245 | e58f87a9 | Michael Hanselmann | sock.close() |
246 | e58f87a9 | Michael Hanselmann | |
247 | e58f87a9 | Michael Hanselmann | |
248 | e58f87a9 | Michael Hanselmann | def TestJobqueue(opts, _): |
249 | e58f87a9 | Michael Hanselmann | """Runs a few tests on the job queue. |
250 | e58f87a9 | Michael Hanselmann | |
251 | e58f87a9 | Michael Hanselmann | """ |
252 | e58f87a9 | Michael Hanselmann | test_messages = [ |
253 | e58f87a9 | Michael Hanselmann | "Hello World", |
254 | e58f87a9 | Michael Hanselmann | "A", |
255 | e58f87a9 | Michael Hanselmann | "", |
256 | e58f87a9 | Michael Hanselmann | "B" |
257 | e58f87a9 | Michael Hanselmann | "Foo|bar|baz", |
258 | e58f87a9 | Michael Hanselmann | utils.TimestampForFilename(), |
259 | e58f87a9 | Michael Hanselmann | ] |
260 | e58f87a9 | Michael Hanselmann | |
261 | e58f87a9 | Michael Hanselmann | for fail in [False, True]: |
262 | e58f87a9 | Michael Hanselmann | if fail: |
263 | e58f87a9 | Michael Hanselmann | ToStdout("Testing job failure") |
264 | e58f87a9 | Michael Hanselmann | else: |
265 | e58f87a9 | Michael Hanselmann | ToStdout("Testing job success") |
266 | e58f87a9 | Michael Hanselmann | |
267 | e58f87a9 | Michael Hanselmann | op = opcodes.OpTestJobqueue(notify_waitlock=True, |
268 | e58f87a9 | Michael Hanselmann | notify_exec=True, |
269 | e58f87a9 | Michael Hanselmann | log_messages=test_messages, |
270 | e58f87a9 | Michael Hanselmann | fail=fail) |
271 | e58f87a9 | Michael Hanselmann | |
272 | e58f87a9 | Michael Hanselmann | reporter = _JobQueueTestReporter() |
273 | e58f87a9 | Michael Hanselmann | try: |
274 | e58f87a9 | Michael Hanselmann | SubmitOpCode(op, reporter=reporter, opts=opts) |
275 | 067d927b | Michael Hanselmann | except errors.OpExecError: |
276 | e58f87a9 | Michael Hanselmann | if not fail: |
277 | e58f87a9 | Michael Hanselmann | raise |
278 | e58f87a9 | Michael Hanselmann | # Ignore error |
279 | e58f87a9 | Michael Hanselmann | else: |
280 | e58f87a9 | Michael Hanselmann | if fail: |
281 | e58f87a9 | Michael Hanselmann | raise errors.OpExecError("Job didn't fail when it should") |
282 | e58f87a9 | Michael Hanselmann | |
283 | e58f87a9 | Michael Hanselmann | # Check received log messages |
284 | e58f87a9 | Michael Hanselmann | if reporter.GetTestMessages() != test_messages: |
285 | e58f87a9 | Michael Hanselmann | raise errors.OpExecError("Received test messages don't match input" |
286 | e58f87a9 | Michael Hanselmann | " (input %r, received %r)" % |
287 | e58f87a9 | Michael Hanselmann | (test_messages, reporter.GetTestMessages())) |
288 | e58f87a9 | Michael Hanselmann | |
289 | e58f87a9 | Michael Hanselmann | # Check final status |
290 | e58f87a9 | Michael Hanselmann | job_id = reporter.GetJobId() |
291 | e58f87a9 | Michael Hanselmann | |
292 | e58f87a9 | Michael Hanselmann | jobdetails = cli.GetClient().QueryJobs([job_id], ["status"])[0] |
293 | e58f87a9 | Michael Hanselmann | if not jobdetails: |
294 | e58f87a9 | Michael Hanselmann | raise errors.OpExecError("Can't find job %s" % job_id) |
295 | e58f87a9 | Michael Hanselmann | |
296 | e58f87a9 | Michael Hanselmann | if fail: |
297 | e58f87a9 | Michael Hanselmann | exp_status = constants.JOB_STATUS_ERROR |
298 | e58f87a9 | Michael Hanselmann | else: |
299 | e58f87a9 | Michael Hanselmann | exp_status = constants.JOB_STATUS_SUCCESS |
300 | e58f87a9 | Michael Hanselmann | |
301 | e58f87a9 | Michael Hanselmann | final_status = jobdetails[0] |
302 | e58f87a9 | Michael Hanselmann | if final_status != exp_status: |
303 | e58f87a9 | Michael Hanselmann | raise errors.OpExecError("Final job status is %s, not %s as expected" % |
304 | e58f87a9 | Michael Hanselmann | (final_status, exp_status)) |
305 | e58f87a9 | Michael Hanselmann | |
306 | e58f87a9 | Michael Hanselmann | return 0 |
307 | e58f87a9 | Michael Hanselmann | |
308 | e58f87a9 | Michael Hanselmann | |
309 | fd3ee040 | Iustin Pop | commands = { |
310 | 6ea815cf | Iustin Pop | 'delay': ( |
311 | 6ea815cf | Iustin Pop | Delay, [ArgUnknown(min=1, max=1)], |
312 | 064c21f8 | Iustin Pop | [cli_option("--no-master", dest="on_master", default=True, |
313 | 6ea815cf | Iustin Pop | action="store_false", help="Do not sleep in the master code"), |
314 | 6ea815cf | Iustin Pop | cli_option("-n", dest="on_nodes", default=[], |
315 | 6ea815cf | Iustin Pop | action="append", help="Select nodes to sleep on"), |
316 | 85a87e21 | Guido Trotter | cli_option("-r", "--repeat", type="int", default="0", dest="repeat", |
317 | 85a87e21 | Guido Trotter | help="Number of times to repeat the sleep"), |
318 | 6ea815cf | Iustin Pop | ], |
319 | 6ea815cf | Iustin Pop | "[opts...] <duration>", "Executes a TestDelay OpCode"), |
320 | 6ea815cf | Iustin Pop | 'submit-job': ( |
321 | 6ea815cf | Iustin Pop | GenericOpCodes, [ArgFile(min=1)], |
322 | 064c21f8 | Iustin Pop | [VERBOSE_OPT, |
323 | 6ea815cf | Iustin Pop | cli_option("--op-repeat", type="int", default="1", dest="rep_op", |
324 | 6ea815cf | Iustin Pop | help="Repeat the opcode sequence this number of times"), |
325 | 6ea815cf | Iustin Pop | cli_option("--job-repeat", type="int", default="1", dest="rep_job", |
326 | 6ea815cf | Iustin Pop | help="Repeat the job this number of times"), |
327 | 6ea815cf | Iustin Pop | cli_option("--timing-stats", default=False, |
328 | 6ea815cf | Iustin Pop | action="store_true", help="Show timing stats"), |
329 | 66ecc479 | Guido Trotter | cli_option("--each", default=False, action="store_true", |
330 | 66ecc479 | Guido Trotter | help="Submit each job separately"), |
331 | 6ea815cf | Iustin Pop | ], |
332 | 6ea815cf | Iustin Pop | "<op_list_file...>", "Submits jobs built from json files" |
333 | 6ea815cf | Iustin Pop | " containing a list of serialized opcodes"), |
334 | 6ea815cf | Iustin Pop | 'allocator': ( |
335 | 823a72bc | Iustin Pop | TestAllocator, [ArgUnknown(min=1)], |
336 | 064c21f8 | Iustin Pop | [cli_option("--dir", dest="direction", |
337 | 6ea815cf | Iustin Pop | default="in", choices=["in", "out"], |
338 | 6ea815cf | Iustin Pop | help="Show allocator input (in) or allocator" |
339 | 6ea815cf | Iustin Pop | " results (out)"), |
340 | 6ea815cf | Iustin Pop | IALLOCATOR_OPT, |
341 | 6ea815cf | Iustin Pop | cli_option("-m", "--mode", default="relocate", |
342 | 823a72bc | Iustin Pop | choices=["relocate", "allocate", "multi-evacuate"], |
343 | 6ea815cf | Iustin Pop | help="Request mode, either allocate or relocate"), |
344 | 6ea815cf | Iustin Pop | cli_option("--mem", default=128, type="unit", |
345 | 6ea815cf | Iustin Pop | help="Memory size for the instance (MiB)"), |
346 | 6ea815cf | Iustin Pop | cli_option("--disks", default="4096,4096", |
347 | 6ea815cf | Iustin Pop | help="Comma separated list of disk sizes (MiB)"), |
348 | 6ea815cf | Iustin Pop | DISK_TEMPLATE_OPT, |
349 | 6ea815cf | Iustin Pop | cli_option("--nics", default="00:11:22:33:44:55", |
350 | 6ea815cf | Iustin Pop | help="Comma separated list of nics, each nic" |
351 | 6ea815cf | Iustin Pop | " definition is of form mac/ip/bridge, if" |
352 | 6ea815cf | Iustin Pop | " missing values are replace by None"), |
353 | 6ea815cf | Iustin Pop | OS_OPT, |
354 | 6ea815cf | Iustin Pop | cli_option("-p", "--vcpus", default=1, type="int", |
355 | 6ea815cf | Iustin Pop | help="Select number of VCPUs for the instance"), |
356 | 6ea815cf | Iustin Pop | cli_option("--tags", default=None, |
357 | 6ea815cf | Iustin Pop | help="Comma separated list of tags"), |
358 | 6ea815cf | Iustin Pop | ], |
359 | 6ea815cf | Iustin Pop | "{opts...} <instance>", "Executes a TestAllocator OpCode"), |
360 | e58f87a9 | Michael Hanselmann | "test-jobqueue": ( |
361 | e58f87a9 | Michael Hanselmann | TestJobqueue, ARGS_NONE, [], |
362 | e58f87a9 | Michael Hanselmann | "", "Test a few aspects of the job queue") |
363 | fd3ee040 | Iustin Pop | } |
364 | fd3ee040 | Iustin Pop | |
365 | fd3ee040 | Iustin Pop | |
366 | fd3ee040 | Iustin Pop | if __name__ == '__main__': |
367 | fd3ee040 | Iustin Pop | sys.exit(GenericMain(commands)) |