Changeset 1613 for trunk/packages/invirt-web/code/controls.py
- Timestamp:
- Nov 11, 2008, 3:50:13 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-web/code/controls.py
r1612 r1613 1 """2 Functions to perform remctls.3 """4 5 1 import validation 6 2 from invirt.common import CodeError, InvalidInput 7 3 import random 8 import subprocess9 4 import sys 10 5 import time … … 15 10 from invirt.config import structs as config 16 11 from invirt.database import Machine, Disk, Type, NIC, CDROM, session, meta 12 from invirt.remctl import remctl 17 13 18 14 # ... and stolen from xend/uuid.py … … 27 23 "%02x" * 6]) % tuple(u) 28 24 # end stolen code 29 30 def kinit():31 """Kinit with a given username and keytab"""32 p = subprocess.Popen(['kinit', "-k", "-t", '/etc/invirt/keytab',33 'daemon/'+config.web.hostname],34 stderr=subprocess.PIPE)35 e = p.wait()36 if e:37 raise CodeError("Error %s in kinit: %s" % (e, p.stderr.read()))38 39 def checkKinit():40 """If we lack tickets, kinit."""41 p = subprocess.Popen(['klist', '-s'])42 if p.wait():43 kinit()44 45 def remctl(*args, **kws):46 """Perform a remctl and return the output.47 48 kinits if necessary, and outputs errors to stderr.49 """50 checkKinit()51 p = subprocess.Popen(['remctl', config.remote.hostname]52 + list(args),53 stdout=subprocess.PIPE,54 stderr=subprocess.PIPE)55 v = p.wait()56 if kws.get('err'):57 return p.stdout.read(), p.stderr.read()58 if v:59 print >> sys.stderr, 'Error', v, 'on remctl', args, ':'60 print >> sys.stderr, p.stderr.read()61 raise CodeError('ERROR on remctl')62 return p.stdout.read()63 25 64 26 def lvcreate(machine, disk):
Note: See TracChangeset
for help on using the changeset viewer.