generate: trigger dans un fichier à part

**Eye of the trigger**
This commit is contained in:
Daniel STAN 2014-02-28 23:23:39 +01:00
parent b47b1174d4
commit 2da409cf8c
2 changed files with 25 additions and 20 deletions

View file

@ -15,7 +15,7 @@ arguments peuvent être founis pour une même option, les séparer par &
"""
import sys, signal, os, getopt
import subprocess
from trigger import trigger_generate as trigger
sys.path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap, hostname
@ -31,25 +31,6 @@ openlog("generate")
db = crans_ldap()
make_lock('auto_generate', 'Big lock', nowait=1)
def trigger(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
class base_reconfigure:
try:
sys.path.append('/etc/crans/')

24
gestion/gen_confs/trigger.py Executable file
View 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