24 lines
790 B
Python
Executable file
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
|
|
|