Ignore:
Timestamp:
Nov 11, 2008, 3:50:13 AM (16 years ago)
Author:
broder
Message:

Move the remctl code into invirt.remctl

Location:
trunk/packages/invirt-web/code
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-web/code/controls.py

    r1612 r1613  
    1 """
    2 Functions to perform remctls.
    3 """
    4 
    51import validation
    62from invirt.common import CodeError, InvalidInput
    73import random
    8 import subprocess
    94import sys
    105import time
     
    1510from invirt.config import structs as config
    1611from invirt.database import Machine, Disk, Type, NIC, CDROM, session, meta
     12from invirt.remctl import remctl
    1713
    1814# ... and stolen from xend/uuid.py
     
    2723                     "%02x" * 6]) % tuple(u)
    2824# 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()
    6325
    6426def lvcreate(machine, disk):
  • trunk/packages/invirt-web/code/main.py

    r1612 r1613  
    4444from invirt.config import structs as config
    4545from invirt.common import InvalidInput, CodeError
     46from invirt.remctl import remctl
    4647
    4748def pathSplit(path):
Note: See TracChangeset for help on using the changeset viewer.