Changeset 1042 for trunk/packages/sipb-xen-dhcp/files/usr/sbin
- Timestamp:
- Oct 4, 2008, 11:23:12 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.