From 82e904071a7ce413c9a8d70e9c97d9dd870cb833 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 11 Nov 2008 03:50:13 -0500 Subject: [PATCH] Move the remctl code into invirt.remctl svn path=/trunk/packages/invirt-web/; revision=1613 --- code/controls.py | 40 +--------------------------------------- code/main.py | 1 + 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/code/controls.py b/code/controls.py index 2ef8c9f..4576a2e 100644 --- a/code/controls.py +++ b/code/controls.py @@ -1,11 +1,6 @@ -""" -Functions to perform remctls. -""" - import validation from invirt.common import CodeError, InvalidInput import random -import subprocess import sys import time import re @@ -14,6 +9,7 @@ import yaml from invirt.config import structs as config from invirt.database import Machine, Disk, Type, NIC, CDROM, session, meta +from invirt.remctl import remctl # ... and stolen from xend/uuid.py def randomUUID(): @@ -27,40 +23,6 @@ def uuidToString(u): "%02x" * 6]) % tuple(u) # end stolen code -def kinit(): - """Kinit with a given username and keytab""" - p = subprocess.Popen(['kinit', "-k", "-t", '/etc/invirt/keytab', - 'daemon/'+config.web.hostname], - stderr=subprocess.PIPE) - e = p.wait() - if e: - raise CodeError("Error %s in kinit: %s" % (e, p.stderr.read())) - -def checkKinit(): - """If we lack tickets, kinit.""" - p = subprocess.Popen(['klist', '-s']) - if p.wait(): - kinit() - -def remctl(*args, **kws): - """Perform a remctl and return the output. - - kinits if necessary, and outputs errors to stderr. - """ - checkKinit() - p = subprocess.Popen(['remctl', config.remote.hostname] - + list(args), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - v = p.wait() - if kws.get('err'): - return p.stdout.read(), p.stderr.read() - if v: - print >> sys.stderr, 'Error', v, 'on remctl', args, ':' - print >> sys.stderr, p.stderr.read() - raise CodeError('ERROR on remctl') - return p.stdout.read() - def lvcreate(machine, disk): """Create a single disk for a machine""" remctl('web', 'lvcreate', machine.name, diff --git a/code/main.py b/code/main.py index cd37c0e..42fe3c7 100755 --- a/code/main.py +++ b/code/main.py @@ -43,6 +43,7 @@ from invirt import database from invirt.database import Machine, CDROM, session, connect, MachineAccess, Type, Autoinstall from invirt.config import structs as config from invirt.common import InvalidInput, CodeError +from invirt.remctl import remctl def pathSplit(path): if path.startswith('/'): -- 1.7.9.5