Index: trunk/packages/sipb-xen-dhcp/code/dhcpserver.py
===================================================================
--- trunk/packages/sipb-xen-dhcp/code/dhcpserver.py	(revision 942)
+++ trunk/packages/sipb-xen-dhcp/code/dhcpserver.py	(revision 1033)
@@ -17,22 +17,20 @@
 import psycopg2
 import time
-import sipb_xen_database
-from sqlalchemy import create_engine
-
-dhcp_options = {'subnet_mask': '255.255.0.0',
-                'router': '18.181.0.1',
-                'domain_name_server': '18.70.0.160,18.71.0.151,18.72.0.3',
+from invirt import database
+from invirt.config import structs as config
+
+dhcp_options = {'subnet_mask': config.dhcp.netmask,
+                'router': config.dhcp.gateway,
+                'domain_name_server': ','.join(config.dhcp.dns),
                 'ip_address_lease_time': 60*60*24}
 
 class DhcpBackend:
-    def __init__(self, database=None):
-        if database is not None:
-            self.database = database
-            sipb_xen_database.connect(create_engine(database))
+    def __init__(self):
+        database.connect()
     def findNIC(self, mac):
-        sipb_xen_database.clear_cache()
+        database.clear_cache()
         for i in range(3):
             try:
-                value = sipb_xen_database.NIC.get_by(mac_addr=mac)
+                value = database.NIC.query().filter_by(mac_addr=mac).one()
             except psycopg2.OperationalError:
                 time.sleep(0.5)
@@ -40,5 +38,5 @@
                     raise
                 #Sigh.  SQLAlchemy should do this itself.
-                sipb_xen_database.connect(create_engine(self.database))
+                database.connect()
             else:
                 break
@@ -48,5 +46,5 @@
         nic = self.findNIC(str(chaddr))
         if nic is None or nic.ip is None:
-            return ("18.181.0.60", None)
+            return
         ipstr = ''.join(reversed(['%02X' % i for i in ipv4(nic.ip).list()]))
         for line in open('/proc/net/route'):
@@ -54,6 +52,6 @@
             if parts[1] == ipstr:
                 Log.Output(Log.debug, "find_interface found "+str(nic.ip)+" on "+parts[0])
-                return ("18.181.0.60", parts[0])
-        return ("18.181.0.60", None)
+                return parts[0]
+        return
                             
     def getParameters(self, **extra):
@@ -124,5 +122,5 @@
         elif nic.machine.name:
             options['host_name'] = nic.machine.name
-            options['domain_name'] = 'xvm.mit.edu'
+            options['domain_name'] = config.dns.domains[0]
         else:
             hostname = None
@@ -130,5 +128,5 @@
             options['host_name'] += '.' + options['domain_name']
             del options['domain_name']
-            options['domain_search'] = ['mit.edu']
+            options['domain_search'] = [config.dhcp.search_domain]
         if ip is not None:
             ip = ipv4(ip)
@@ -178,5 +176,5 @@
 
     def SendDhcpPacketTo(self, To, packet):
-        (ip, intf) = self.backend.find_interface(packet)
+        intf = self.backend.find_interface(packet)
         if intf:
             out_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -275,5 +273,5 @@
                 "client_listen_port":68,
                 "listen_address":"0.0.0.0"}
-    backend = DhcpBackend('postgres://sipb-xen@sipb-xen-dev/sipb_xen')
+    backend = DhcpBackend()
     server = DhcpServer(backend, options)
 
Index: trunk/packages/sipb-xen-dhcp/config.todo
===================================================================
--- trunk/packages/sipb-xen-dhcp/config.todo	(revision 942)
+++ 	(revision )
@@ -1,3 +1,0 @@
-code/dhcpserver.py somehow avoids db uri?
-code/dhcpserver.py: gateway, netmask, nameservers
-code/dhcpserver.py: host ip (?)
Index: trunk/packages/sipb-xen-dhcp/debian/changelog
===================================================================
--- trunk/packages/sipb-xen-dhcp/debian/changelog	(revision 942)
+++ trunk/packages/sipb-xen-dhcp/debian/changelog	(revision 1033)
@@ -1,2 +1,8 @@
+sipb-xen-dhcp (3) unstable; urgency=low
+
+  * invirt-configurize dhcp
+
+ -- Evan Broder <broder@mit.edu>  Sat, 04 Oct 2008 19:55:49 -0400
+
 sipb-xen-dhcp (2) unstable; urgency=low
 
