From: Evan Broder Date: Sun, 5 Oct 2008 03:23:12 +0000 (-0400) Subject: Remove the hack to reconnect to the database if it goes away X-Git-Tag: sipb-xen-dhcp/3.1^0 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dhcp.git/commitdiff_plain/b90bd05aabe0249b2cfc16f0385a55d4a9d306be Remove the hack to reconnect to the database if it goes away svn path=/trunk/packages/sipb-xen-dhcp/; revision=1042 --- diff --git a/debian/changelog b/debian/changelog index a2bbc7e..99db95b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +sipb-xen-dhcp (3.1) unstable; urgency=low + + * Take out the hack to reconnect to the database if it goes away + + -- Evan Broder Sat, 04 Oct 2008 23:22:19 -0400 + sipb-xen-dhcp (3) unstable; urgency=low * invirt-configurize dhcp diff --git a/files/usr/sbin/sipb-xen-dhcpserver b/files/usr/sbin/sipb-xen-dhcpserver index d5f35eb..74e554f 100755 --- a/files/usr/sbin/sipb-xen-dhcpserver +++ b/files/usr/sbin/sipb-xen-dhcpserver @@ -11,7 +11,6 @@ import IN import syslog as s -import psycopg2 import time from invirt import database from invirt.config import structs as config @@ -26,30 +25,19 @@ class DhcpBackend: database.connect() def findNIC(self, mac): database.clear_cache() - for i in range(3): - try: - value = database.NIC.query().filter_by(mac_addr=mac).one() - except psycopg2.OperationalError: - time.sleep(0.5) - if i == 2: #Try twice to reconnect. - raise - #Sigh. SQLAlchemy should do this itself. - database.connect() - else: - break - return value + return database.NIC.query().filter_by(mac_addr=mac).one() def find_interface(self, packet): chaddr = hwmac(packet.GetHardwareAddress()) nic = self.findNIC(str(chaddr)) if nic is None or nic.ip is None: - return + return None ipstr = ''.join(reversed(['%02X' % i for i in ipv4(nic.ip).list()])) for line in open('/proc/net/route'): parts = line.split() if parts[1] == ipstr: s.syslog(s.LOG_DEBUG, "find_interface found "+str(nic.ip)+" on "+parts[0]) return parts[0] - return + return None def getParameters(self, **extra): all_options=dict(dhcp_options)