Changeset 1042 for trunk/packages
- Timestamp:
- Oct 4, 2008, 11:23:12 PM (16 years ago)
- Location:
- trunk/packages/sipb-xen-dhcp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-dhcp/debian/changelog
r1035 r1042 1 sipb-xen-dhcp (3.1) unstable; urgency=low 2 3 * Take out the hack to reconnect to the database if it goes away 4 5 -- Evan Broder <broder@mit.edu> Sat, 04 Oct 2008 23:22:19 -0400 6 1 7 sipb-xen-dhcp (3) unstable; urgency=low 2 8 -
trunk/packages/sipb-xen-dhcp/files/usr/sbin/sipb-xen-dhcpserver
r1035 r1042 12 12 import syslog as s 13 13 14 import psycopg215 14 import time 16 15 from invirt import database … … 27 26 def findNIC(self, mac): 28 27 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() 41 29 def find_interface(self, packet): 42 30 chaddr = hwmac(packet.GetHardwareAddress()) 43 31 nic = self.findNIC(str(chaddr)) 44 32 if nic is None or nic.ip is None: 45 return 33 return None 46 34 ipstr = ''.join(reversed(['%02X' % i for i in ipv4(nic.ip).list()])) 47 35 for line in open('/proc/net/route'): … … 50 38 s.syslog(s.LOG_DEBUG, "find_interface found "+str(nic.ip)+" on "+parts[0]) 51 39 return parts[0] 52 return 40 return None 53 41 54 42 def getParameters(self, **extra):
Note: See TracChangeset
for help on using the changeset viewer.