Changeset 1614 for trunk/packages/invirt-base/python
- Timestamp:
- Nov 11, 2008, 4:32:17 AM (16 years ago)
- File:
-
- 1 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,
Note: See TracChangeset
for help on using the changeset viewer.