generate: trigger dans un fichier à part
**Eye of the trigger**
This commit is contained in:
parent
b47b1174d4
commit
2da409cf8c
2 changed files with 25 additions and 20 deletions
24
gestion/gen_confs/trigger.py
Executable file
24
gestion/gen_confs/trigger.py
Executable file
|
@ -0,0 +1,24 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import subprocess
|
||||
|
||||
def trigger_generate(host, background=False):
|
||||
if not 'adm.crans.org' in host:
|
||||
host=host + '.adm.crans.org'
|
||||
options = ['PasswordAuthentication=no', 'ConnectTimeout=1', 'VerifyHostKeyDNS=yes',
|
||||
'BatchMode=yes', 'ServerAliveInterval=5', 'ServerAliveCountMax=1']
|
||||
args = ["ssh", "-4", "-i", "/etc/crans/secrets/trigger-generate" ]
|
||||
for opt in options:
|
||||
args.append('-o')
|
||||
args.append(opt)
|
||||
args.extend(["rpcssh@%s" % host, "generate"])
|
||||
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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue