Commit a4af651e authored by Iustin Pop's avatar Iustin Pop
Browse files

Move the 'cmd' lock from cli.py to ganeti-masterd

This patch removes the lock and the lock options from cli.py and moves
them to the master.

Later during development we can remove it completely, but for now it's
good to protect any other tool that uses the lock directly.

Reviewed-by: imsnah,ultrotter
parent 685ee993
......@@ -342,11 +342,23 @@ def main():
utils.Daemonize(logfile=constants.LOG_MASTERDAEMON,
noclose_fds=[master.fileno()])
master.setup_processors()
try:
master.serve_forever()
finally:
utils.Lock('cmd', debug=options.debug)
except errors.LockError, err:
print >> sys.stderr, str(err)
master.server_cleanup()
return
try:
master.setup_processors()
try:
master.serve_forever()
finally:
master.server_cleanup()
finally:
utils.Unlock('cmd')
utils.LockCleanup()
if __name__ == "__main__":
main()
......@@ -177,9 +177,6 @@ FIELDS_OPT = make_option("-o", "--output", dest="output", action="store",
FORCE_OPT = make_option("-f", "--force", dest="force", action="store_true",
default=False, help="Force the operation")
_LOCK_OPT = make_option("--lock-retries", default=None,
type="int", help=SUPPRESS_HELP)
TAG_SRC_OPT = make_option("--from", dest="tags_source",
default=None, help="File with tag names")
......@@ -283,7 +280,6 @@ def _ParseArgs(argv, commands, aliases):
cmd = aliases[cmd]
func, nargs, parser_opts, usage, description = commands[cmd]
parser_opts.append(_LOCK_OPT)
parser = OptionParser(option_list=parser_opts,
description=description,
formatter=TitledHelpFormatter(),
......@@ -519,14 +515,6 @@ def GenericMain(commands, override=None, aliases=None):
logger.SetupLogging(debug=options.debug, program=binary)
utils.debug = options.debug
try:
utils.Lock('cmd', max_retries=options.lock_retries, debug=options.debug)
except errors.LockError, err:
logger.ToStderr(str(err))
return 1
except KeyboardInterrupt:
logger.ToStderr("Aborting.")
return 1
if old_cmdline:
logger.Info("run with arguments '%s'" % old_cmdline)
......@@ -534,14 +522,10 @@ def GenericMain(commands, override=None, aliases=None):
logger.Info("run with no arguments")
try:
try:
result = func(options, args)
except errors.GenericError, err:
result, err_msg = FormatError(err)
logger.ToStderr(err_msg)
finally:
utils.Unlock('cmd')
utils.LockCleanup()
result = func(options, args)
except errors.GenericError, err:
result, err_msg = FormatError(err)
logger.ToStderr(err_msg)
return result
......
......@@ -427,17 +427,7 @@ def main():
"""Main function"""
burner = Burner()
try:
utils.Lock('cmd', max_retries=15, debug=True)
except errors.LockError, err:
logger.ToStderr(str(err))
return 1
try:
retval = burner.BurninCluster()
finally:
utils.Unlock('cmd')
utils.LockCleanup()
return retval
return burner.BurninCluster()
if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment