Ignore:
Timestamp:
Oct 4, 2008, 11:23:12 PM (16 years ago)
Author:
broder
Message:

Remove the hack to reconnect to the database if it goes away

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-dhcp/files/usr/sbin/sipb-xen-dhcpserver

    r1035 r1042  
    1212import syslog as s
    1313
    14 import psycopg2
    1514import time
    1615from invirt import database
     
    2726    def findNIC(self, mac):
    2827        database.clear_cache()
    29         for i in range(3):
    30             try:
    31                 value = database.NIC.query().filter_by(mac_addr=mac).one()
    32             except psycopg2.OperationalError:
    33                 time.sleep(0.5)
    34                 if i == 2:  #Try twice to reconnect.
    35                     raise
    36                 #Sigh.  SQLAlchemy should do this itself.
    37                 database.connect()
    38             else:
    39                 break
    40         return value
     28        return database.NIC.query().filter_by(mac_addr=mac).one()
    4129    def find_interface(self, packet):
    4230        chaddr = hwmac(packet.GetHardwareAddress())
    4331        nic = self.findNIC(str(chaddr))
    4432        if nic is None or nic.ip is None:
    45             return
     33            return None
    4634        ipstr = ''.join(reversed(['%02X' % i for i in ipv4(nic.ip).list()]))
    4735        for line in open('/proc/net/route'):
     
    5038                s.syslog(s.LOG_DEBUG, "find_interface found "+str(nic.ip)+" on "+parts[0])
    5139                return parts[0]
    52         return
     40        return None
    5341                           
    5442    def getParameters(self, **extra):
Note: See TracChangeset for help on using the changeset viewer.