Revision a4af651e
b/daemons/ganeti-masterd | ||
---|---|---|
342 | 342 |
utils.Daemonize(logfile=constants.LOG_MASTERDAEMON, |
343 | 343 |
noclose_fds=[master.fileno()]) |
344 | 344 |
|
345 |
master.setup_processors() |
|
346 | 345 |
try: |
347 |
master.serve_forever() |
|
348 |
finally: |
|
346 |
utils.Lock('cmd', debug=options.debug) |
|
347 |
except errors.LockError, err: |
|
348 |
print >> sys.stderr, str(err) |
|
349 | 349 |
master.server_cleanup() |
350 |
return |
|
351 |
|
|
352 |
try: |
|
353 |
master.setup_processors() |
|
354 |
try: |
|
355 |
master.serve_forever() |
|
356 |
finally: |
|
357 |
master.server_cleanup() |
|
358 |
finally: |
|
359 |
utils.Unlock('cmd') |
|
360 |
utils.LockCleanup() |
|
361 |
|
|
350 | 362 |
|
351 | 363 |
if __name__ == "__main__": |
352 | 364 |
main() |
b/lib/cli.py | ||
---|---|---|
177 | 177 |
FORCE_OPT = make_option("-f", "--force", dest="force", action="store_true", |
178 | 178 |
default=False, help="Force the operation") |
179 | 179 |
|
180 |
_LOCK_OPT = make_option("--lock-retries", default=None, |
|
181 |
type="int", help=SUPPRESS_HELP) |
|
182 |
|
|
183 | 180 |
TAG_SRC_OPT = make_option("--from", dest="tags_source", |
184 | 181 |
default=None, help="File with tag names") |
185 | 182 |
|
... | ... | |
283 | 280 |
cmd = aliases[cmd] |
284 | 281 |
|
285 | 282 |
func, nargs, parser_opts, usage, description = commands[cmd] |
286 |
parser_opts.append(_LOCK_OPT) |
|
287 | 283 |
parser = OptionParser(option_list=parser_opts, |
288 | 284 |
description=description, |
289 | 285 |
formatter=TitledHelpFormatter(), |
... | ... | |
519 | 515 |
logger.SetupLogging(debug=options.debug, program=binary) |
520 | 516 |
|
521 | 517 |
utils.debug = options.debug |
522 |
try: |
|
523 |
utils.Lock('cmd', max_retries=options.lock_retries, debug=options.debug) |
|
524 |
except errors.LockError, err: |
|
525 |
logger.ToStderr(str(err)) |
|
526 |
return 1 |
|
527 |
except KeyboardInterrupt: |
|
528 |
logger.ToStderr("Aborting.") |
|
529 |
return 1 |
|
530 | 518 |
|
531 | 519 |
if old_cmdline: |
532 | 520 |
logger.Info("run with arguments '%s'" % old_cmdline) |
... | ... | |
534 | 522 |
logger.Info("run with no arguments") |
535 | 523 |
|
536 | 524 |
try: |
537 |
try: |
|
538 |
result = func(options, args) |
|
539 |
except errors.GenericError, err: |
|
540 |
result, err_msg = FormatError(err) |
|
541 |
logger.ToStderr(err_msg) |
|
542 |
finally: |
|
543 |
utils.Unlock('cmd') |
|
544 |
utils.LockCleanup() |
|
525 |
result = func(options, args) |
|
526 |
except errors.GenericError, err: |
|
527 |
result, err_msg = FormatError(err) |
|
528 |
logger.ToStderr(err_msg) |
|
545 | 529 |
|
546 | 530 |
return result |
547 | 531 |
|
b/tools/burnin | ||
---|---|---|
427 | 427 |
"""Main function""" |
428 | 428 |
|
429 | 429 |
burner = Burner() |
430 |
try: |
|
431 |
utils.Lock('cmd', max_retries=15, debug=True) |
|
432 |
except errors.LockError, err: |
|
433 |
logger.ToStderr(str(err)) |
|
434 |
return 1 |
|
435 |
try: |
|
436 |
retval = burner.BurninCluster() |
|
437 |
finally: |
|
438 |
utils.Unlock('cmd') |
|
439 |
utils.LockCleanup() |
|
440 |
return retval |
|
430 |
return burner.BurninCluster() |
|
441 | 431 |
|
442 | 432 |
|
443 | 433 |
if __name__ == "__main__": |
Also available in: Unified diff