+sipb-xen-dhcp (3.1) unstable; urgency=low
+
+ * Take out the hack to reconnect to the database if it goes away
+
+ -- Evan Broder <broder@mit.edu> Sat, 04 Oct 2008 23:22:19 -0400
+
sipb-xen-dhcp (3) unstable; urgency=low
* invirt-configurize dhcp
import syslog as s
-import psycopg2
import time
from invirt import database
from invirt.config import structs as config
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)