scripts/gestion/gen_confs/trigger.py
Daniel STAN 2da409cf8c generate: trigger dans un fichier à part
**Eye of the trigger**
2014-02-28 23:23:39 +01:00

24 lines
790 B
Python
Executable file

#! /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