Changeset 1614 for trunk/packages
- Timestamp:
- Nov 11, 2008, 4:32:17 AM (16 years ago)
- Location:
- trunk/packages
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-base/python/invirt/remctl.py
r1613 r1614 5 5 from invirt.common import CodeError 6 6 import subprocess 7 from socket import getfqdn 7 8 8 def kinit( ):9 def kinit(principal=None, keytab=None): 9 10 """Kinit with a given username and keytab""" 10 p = subprocess.Popen(['kinit', "-k", "-t", '/etc/invirt/keytab', 11 'daemon/'+config.web.hostname], 11 if principal is None: 12 principal = 'daemon/' + getfqdn() 13 if keytab is None: 14 keytab = '/etc/invirt/keytab' 15 p = subprocess.Popen(['kinit', "-k", "-t", keytab, principal], 12 16 stderr=subprocess.PIPE) 13 17 e = p.wait() … … 15 19 raise CodeError("Error %s in kinit: %s" % (e, p.stderr.read())) 16 20 17 def checkKinit( ):21 def checkKinit(principal=None, keytab=None): 18 22 """If we lack tickets, kinit.""" 19 23 p = subprocess.Popen(['klist', '-s']) 20 24 if p.wait(): 21 kinit( )25 kinit(principal, keytab) 22 26 23 def remctl( *args, **kws):27 def remctl(host, *args, **kws): 24 28 """Perform a remctl and return the output. 25 29 26 30 kinits if necessary, and outputs errors to stderr. 27 31 """ 28 checkKinit( )29 p = subprocess.Popen(['remctl', config.remote.hostname]32 checkKinit(kws.get('principal'), kws.get('keytab')) 33 p = subprocess.Popen(['remctl', host] 30 34 + list(args), 31 35 stdout=subprocess.PIPE, -
trunk/packages/invirt-web/code/controls.py
r1613 r1614 10 10 from invirt.config import structs as config 11 11 from invirt.database import Machine, Disk, Type, NIC, CDROM, session, meta 12 from invirt.remctl import remctl 12 from invirt.remctl import remctl as gen_remctl 13 13 14 14 # ... and stolen from xend/uuid.py … … 23 23 "%02x" * 6]) % tuple(u) 24 24 # end stolen code 25 26 def remctl(*args, **kwargs): 27 return gen_remctl(config.remote.hostname, *args, 28 principal='daemon/'+config.web.hostname, 29 **kwargs) 25 30 26 31 def lvcreate(machine, disk):
Note: See TracChangeset
for help on using the changeset viewer.