Index: trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/__init__.py
===================================================================
--- trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/__init__.py	(revision 1197)
+++ 	(revision )
@@ -1,27 +1,0 @@
-'''Invirt - a virtualization management system
-
-Invirt was developed at the Student Information Processing Board of
-the Massachusetts Institute of Technology.  See http://xvm.mit.edu/.
-
-Invirt is free software available under the GNU GPL, version 2 or later.
-Consult the source files for details.
-'''
-
-# Invirt is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 2 of the License, or (at your
-# option) any later version.
-
-# Invirt is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Invirt.  If not, see <http://www.gnu.org/licenses/>.
-
-__author__    = 'MIT SIPB'
-__version__   = '0.1'
-__copyright__ = 'Copyright (c) 2008 MIT SIPB'
-
-# vim:et:sw=4:ts=4
Index: trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/common.py
===================================================================
--- trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/common.py	(revision 1197)
+++ 	(revision )
@@ -1,58 +1,0 @@
-from __future__ import with_statement
-
-import unittest
-from fcntl import flock, LOCK_EX, LOCK_SH, LOCK_UN
-import contextlib as clib
-
-class struct(object):
-    'A simple namespace object.'
-    def __init__(self, d = {}, **kwargs):
-        'd is the dictionary to update my __dict__ with.'
-        self.__dict__.update(d)
-        self.__dict__.update(kwargs)
-
-def dicts2struct(x):
-    """
-    Given a tree of lists/dicts, perform a deep traversal to transform all the
-    dicts to structs.
-    """
-    if type(x) == dict:
-        return struct((k, dicts2struct(v)) for k,v in x.iteritems())
-    elif type(x) == list:
-        return [dicts2struct(v) for v in x]
-    else:
-        return x
-
-@clib.contextmanager
-def lock_file(path, exclusive = True):
-    with clib.closing(file(path, 'w')) as f:
-        if exclusive:
-            locktype = LOCK_EX
-        else:
-            locktype = LOCK_SH
-        flock(f, locktype)
-        try:
-            yield
-        finally:
-            flock(f, LOCK_UN)
-
-#
-# Tests.
-#
-
-class common_tests(unittest.TestCase):
-    def test_dicts2structs(self):
-        dicts = {
-                'atom': 0,
-                'dict': { 'atom': 'atom', 'list': [1,2,3] },
-                'list': [ 'atom', {'key': 'value'} ]
-                }
-        structs = dicts2struct(dicts)
-        self.assertEqual(structs.atom,        dicts['atom'])
-        self.assertEqual(structs.dict.atom,   dicts['dict']['atom'])
-        self.assertEqual(structs.dict.list,   dicts['dict']['list'])
-        self.assertEqual(structs.list[0],     dicts['list'][0])
-        self.assertEqual(structs.list[1].key, dicts['list'][1]['key'])
-
-if __name__ == '__main__':
-    unittest.main()
Index: trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/config.py
===================================================================
--- trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/config.py	(revision 1197)
+++ 	(revision )
@@ -1,91 +1,0 @@
-from __future__ import with_statement
-
-import json
-from invirt.common import *
-from os import rename
-from os.path import getmtime
-from contextlib import closing
-
-default_src_path   = '/etc/invirt/master.yaml'
-default_cache_path = '/var/lib/invirt/cache.json'
-lock_path          = '/var/lib/invirt/cache.lock'
-
-def load(src_path = default_src_path,
-         cache_path = default_cache_path,
-         force_refresh = False):
-    """
-    Try loading the configuration from the faster-to-load JSON cache at
-    cache_path.  If it doesn't exist or is outdated, load the configuration
-    instead from the original YAML file at src_path and regenerate the cache.
-    I assume I have the permissions to write to the cache directory.
-    """
-
-    # Namespace container for state variables, so that they can be updated by
-    # closures.
-    ns = struct()
-
-    if force_refresh:
-        do_refresh = True
-    else:
-        src_mtime = getmtime(src_path)
-        try:            cache_mtime = getmtime(cache_path)
-        except OSError: do_refresh  = True
-        else:           do_refresh  = src_mtime + 1 >= cache_mtime
-
-        # We chose not to simply say
-        #
-        #   do_refresh = src_mtime >= cache_time
-        #
-        # because between the getmtime(src_path) and the time the cache is
-        # rewritten, the master configuration may have been updated, so future
-        # checks here would find a cache with a newer mtime than the master
-        # (and thus treat the cache as containing the latest version of the
-        # master).  The +1 means that for at least a full second following the
-        # update to the master, this function will refresh the cache, giving us
-        # 1 second to write the cache.  Note that if it takes longer than 1
-        # second to write the cache, then this situation could still arise.
-        #
-        # The getmtime calls should logically be part of the same transaction
-        # as the rest of this function (cache read + conditional cache
-        # refresh), but to wrap everything in an flock would cause the
-        # following cache read to be less streamlined.
-
-    if not do_refresh:
-        # Try reading from the cache first.  This must be transactionally
-        # isolated from concurrent writes to prevent reading an incomplete
-        # (changing) version of the data (but the transaction can share the
-        # lock with other concurrent reads).  This isolation is accomplished
-        # using an atomic filesystem rename in the refreshing stage.
-        try: 
-            with closing(file(cache_path)) as f:
-                ns.cfg = json.read(f.read())
-        except: do_refresh = True
-
-    if do_refresh:
-        # Atomically reload the source and regenerate the cache.  The read and
-        # write must be a single transaction, or a stale version may be
-        # written (if another read/write of a more recent configuration
-        # is interleaved).  The final atomic rename is to keep this
-        # transactionally isolated from the above cache read.  If we fail to
-        # acquire the lock, just try to load the master configuration.
-        import yaml
-        try:    loader = yaml.CSafeLoader
-        except: loader = yaml.SafeLoader
-        try:
-            with lock_file(lock_path):
-                with closing(file(src_path)) as f:
-                    ns.cfg = yaml.load(f, loader)
-                try: 
-                    with closing(file(cache_path + '.tmp', 'w')) as f:
-                        f.write(json.write(ns.cfg))
-                except: pass # silent failure
-                else: rename(cache_path + '.tmp', cache_path)
-        except IOError:
-            with closing(file(src_path)) as f:
-                ns.cfg = yaml.load(f, loader)
-    return ns.cfg
-
-dicts = load()
-structs = dicts2struct(dicts)
-
-# vim:et:sw=4:ts=4
Index: trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/remote.py
===================================================================
--- trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/remote.py	(revision 1197)
+++ 	(revision )
@@ -1,19 +1,0 @@
-from subprocess import PIPE, Popen
-from invirt.config import structs as config
-import yaml
-
-def bcast(cmd, hosts = [h.hostname for h in config.hosts]):
-    """
-    Given a command and a list of hostnames or IPs, issue the command to all
-    the nodes and return a list of (host, output) pairs (the order should be
-    the same as the order of the hosts).
-    """
-    pipes = [(host,
-              Popen(['remctl', host, 'remote', 'web', cmd], stdout=PIPE))
-             for host in hosts]
-    outputs = [(s, p.communicate()[0]) for (s, p) in pipes]
-    for (s, p) in pipes:
-        if p.returncode != 0:
-            raise RuntimeError("remctl to host %s returned non-zero exit status %d"
-                               % (s, p.returncode))
-    return [(s, yaml.load(o, yaml.CSafeLoader)) for (s, o) in outputs]
