2 Functions to perform remctls.
5 from invirt.common import CodeError
9 """Kinit with a given username and keytab"""
10 p = subprocess.Popen(['kinit', "-k", "-t", '/etc/invirt/keytab',
11 'daemon/'+config.web.hostname],
12 stderr=subprocess.PIPE)
15 raise CodeError("Error %s in kinit: %s" % (e, p.stderr.read()))
18 """If we lack tickets, kinit."""
19 p = subprocess.Popen(['klist', '-s'])
23 def remctl(*args, **kws):
24 """Perform a remctl and return the output.
26 kinits if necessary, and outputs errors to stderr.
29 p = subprocess.Popen(['remctl', config.remote.hostname]
31 stdout=subprocess.PIPE,
32 stderr=subprocess.PIPE)
35 return p.stdout.read(), p.stderr.read()
37 print >> sys.stderr, 'Error', v, 'on remctl', args, ':'
38 print >> sys.stderr, p.stderr.read()
39 raise CodeError('ERROR on remctl')
40 return p.stdout.read()