[gen_confs/generate] possibilité de lancer trigger en arrière plan

This commit is contained in:
Valentin Samir 2014-02-22 19:00:25 +01:00
parent f58ef89ffc
commit 7026643353

View file

@ -33,7 +33,7 @@ signal.signal(signal.SIGINT, signal.SIG_IGN) # Pas de Ctrl-C
db = crans_ldap()
make_lock('auto_generate', 'Big lock', nowait=1)
def trigger(host):
def trigger(host, background=False):
if not 'adm.crans.org' in host:
host=host + '.adm.crans.org'
options = ['PasswordAuthentication=no', 'ConnectTimeout=1', 'VerifyHostKeyDNS=yes',
@ -43,11 +43,14 @@ def trigger(host):
args.append('-o')
args.append(opt)
args.extend(["rpcssh@%s" % host, "generate"])
p=subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if err:
raise Exception(err)
return out
if background:
subprocess.Popen(args)
else:
p=subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if err:
raise Exception(err)
return out
class base_reconfigure:
try: