Index: trunk/packages/invirt-base/debian/changelog
===================================================================
--- trunk/packages/invirt-base/debian/changelog	(revision 1612)
+++ trunk/packages/invirt-base/debian/changelog	(revision 1613)
@@ -2,6 +2,7 @@
 
   * Move useful Python exceptions into invirt.common
-
- -- Evan Broder <broder@mit.edu>  Tue, 11 Nov 2008 00:32:19 -0500
+  * Move the remctl code out of the website and into invirt-base
+
+ -- Evan Broder <broder@mit.edu>  Tue, 11 Nov 2008 01:14:42 -0500
 
 invirt-base (0.0.8) unstable; urgency=low
Index: trunk/packages/invirt-base/python/invirt/remctl.py
===================================================================
--- trunk/packages/invirt-base/python/invirt/remctl.py	(revision 1613)
+++ trunk/packages/invirt-base/python/invirt/remctl.py	(revision 1613)
@@ -0,0 +1,40 @@
+"""
+Functions to perform remctls.
+"""
+
+from invirt.common import CodeError
+import subprocess
+
+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()
Index: trunk/packages/invirt-web/code/controls.py
===================================================================
--- trunk/packages/invirt-web/code/controls.py	(revision 1612)
+++ trunk/packages/invirt-web/code/controls.py	(revision 1613)
@@ -1,10 +1,5 @@
-"""
-Functions to perform remctls.
-"""
-
 import validation
 from invirt.common import CodeError, InvalidInput
 import random
-import subprocess
 import sys
 import time
@@ -15,4 +10,5 @@
 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
@@ -27,38 +23,4 @@
                      "%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):
Index: trunk/packages/invirt-web/code/main.py
===================================================================
--- trunk/packages/invirt-web/code/main.py	(revision 1612)
+++ trunk/packages/invirt-web/code/main.py	(revision 1613)
@@ -44,4 +44,5 @@
 from invirt.config import structs as config
 from invirt.common import InvalidInput, CodeError
+from invirt.remctl import remctl
 
 def pathSplit(path):
