[generate] Une fonction pour trigger generate sur un hôte distant
Lève une exception si une quelconque erreure arrive.
This commit is contained in:
parent
aeb8b55ce1
commit
470fa70f14
1 changed files with 17 additions and 1 deletions
|
@ -15,7 +15,7 @@ arguments peuvent être founis pour une même option, les séparer par &
|
|||
"""
|
||||
|
||||
import sys, signal, os, getopt
|
||||
|
||||
import subprocess
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
|
||||
from ldap_crans import crans_ldap, hostname
|
||||
|
@ -33,6 +33,22 @@ 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):
|
||||
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"])
|
||||
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/')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue