Changeset 1034 for trunk/packages
- Timestamp:
- Oct 4, 2008, 8:13:08 PM (16 years ago)
- Location:
- trunk/packages/sipb-xen-dhcp
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-dhcp/code/dhcpserver.py
r1033 r1034 10 10 import IN 11 11 12 import event_logger 13 if '__main__' == __name__: 14 event_logger.init("stdout", 'DEBUG', {}) 15 from event_logger import Log 12 import syslog as s 16 13 17 14 import psycopg2 … … 51 48 parts = line.split() 52 49 if parts[1] == ipstr: 53 Log.Output(Log.debug, "find_interface found "+str(nic.ip)+" on "+parts[0])50 s.syslog(s.LOG_DEBUG, "find_interface found "+str(nic.ip)+" on "+parts[0]) 54 51 return parts[0] 55 52 return … … 108 105 109 106 def Discover(self, packet): 110 Log.Output(Log.debug,"dhcp_backend : Discover ")107 s.syslog(s.LOG_DEBUG, "dhcp_backend : Discover ") 111 108 chaddr = hwmac(packet.GetHardwareAddress()) 112 109 nic = self.findNIC(str(chaddr)) … … 131 128 if ip is not None: 132 129 ip = ipv4(ip) 133 Log.Output(Log.debug,"dhcp_backend : Discover result = "+str(ip))130 s.syslog(s.LOG_DEBUG,"dhcp_backend : Discover result = "+str(ip)) 134 131 packet_parameters = self.getParameters(**options) 135 132 … … 142 139 143 140 def Request(self, packet): 144 Log.Output(Log.debug, "dhcp_backend : Request")141 s.syslog(s.LOG_DEBUG, "dhcp_backend : Request") 145 142 146 143 discover = self.Discover(packet) … … 153 150 154 151 if not discover: 155 Log.Output(Log.info,"Unknown MAC address: "+str(chaddr))152 s.syslog(s.LOG_INFO,"Unknown MAC address: "+str(chaddr)) 156 153 return False 157 154 158 155 if yiaddr!="0.0.0.0" and yiaddr == request : 159 Log.Output(Log.info,"Ack ip "+str(yiaddr)+" for "+str(chaddr))156 s.syslog(s.LOG_INFO,"Ack ip "+str(yiaddr)+" for "+str(chaddr)) 160 157 return True 161 158 else: 162 Log.Output(Log.info,"Requested ip "+str(request)+" not available for "+str(chaddr))159 s.syslog(s.LOG_INFO,"Requested ip "+str(request)+" not available for "+str(chaddr)) 163 160 return False 164 161 … … 173 170 pydhcplib.dhcp_network.DhcpServer.__init__(self,"0.0.0.0",options["client_listen_port"],options["server_listen_port"],) 174 171 self.backend = backend 175 Log.Output(Log.debug, "__init__ DhcpServer")172 s.syslog(s.LOG_DEBUG, "__init__ DhcpServer") 176 173 177 174 def SendDhcpPacketTo(self, To, packet): … … 198 195 agent_ip = ".".join(map(str,giaddr)) 199 196 self.SendDhcpPacketTo(agent_ip,packet) 200 Log.Output(Log.debug, "SendPacket to agent : "+agent_ip)197 s.syslog(s.LOG_DEBUG, "SendPacket to agent : "+agent_ip) 201 198 202 199 # FIXME: This shouldn't broadcast if it has an IP address to send 203 200 # it to instead. See RFC2131 part 4.1 for full details 204 201 else : 205 Log.Output(Log.debug, "No agent, broadcast packet.")202 s.syslog(s.LOG_DEBUG, "No agent, broadcast packet.") 206 203 self.SendDhcpPacketTo("255.255.255.255",packet) 207 204 … … 213 210 logmsg = "Get DHCPDISCOVER packet from " + hwmac(packet.GetHardwareAddress()).str() 214 211 215 Log.Output(Log.info, logmsg)212 s.syslog(s.LOG_INFO, logmsg) 216 213 offer = DhcpPacket() 217 214 offer.CreateDhcpOfferPacketFrom(packet) … … 233 230 234 231 if sid != [0,0,0,0] and ciaddr == [0,0,0,0] : 235 Log.Output(Log.info, "Get DHCPREQUEST_SELECTING_STATE packet")232 s.syslog(s.LOG_INFO, "Get DHCPREQUEST_SELECTING_STATE packet") 236 233 237 234 elif sid == [0,0,0,0] and ciaddr == [0,0,0,0] and ip : 238 Log.Output(Log.info, "Get DHCPREQUEST_INITREBOOT_STATE packet")235 s.syslog(s.LOG_INFO, "Get DHCPREQUEST_INITREBOOT_STATE packet") 239 236 240 237 elif sid == [0,0,0,0] and ciaddr != [0,0,0,0] and not ip : 241 Log.Output(Log.info,"Get DHCPREQUEST_INITREBOOT_STATE packet")242 243 else : Log.Output(Log.info,"Get DHCPREQUEST_UNKNOWN_STATE packet : not implemented")238 s.syslog(s.LOG_INFO,"Get DHCPREQUEST_INITREBOOT_STATE packet") 239 240 else : s.syslog(s.LOG_INFO,"Get DHCPREQUEST_UNKNOWN_STATE packet : not implemented") 244 241 245 242 if self.backend.Request(packet) : packet.TransformToDhcpAckPacket() … … 252 249 # FIXME: These are not yet implemented. 253 250 def HandleDhcpDecline(self, packet): 254 Log.Output(Log.info, "Get DHCPDECLINE packet")251 s.syslog(s.LOG_INFO, "Get DHCPDECLINE packet") 255 252 self.backend.Decline(packet) 256 253 257 254 def HandleDhcpRelease(self, packet): 258 Log.Output(Log.info,"Get DHCPRELEASE packet")255 s.syslog(s.LOG_INFO,"Get DHCPRELEASE packet") 259 256 self.backend.Release(packet) 260 257 261 258 def HandleDhcpInform(self, packet): 262 Log.Output(Log.info, "Get DHCPINFORM packet")259 s.syslog(s.LOG_INFO, "Get DHCPINFORM packet") 263 260 264 261 if self.backend.Request(packet) : -
trunk/packages/sipb-xen-dhcp/debian/changelog
r1033 r1034 2 2 3 3 * invirt-configurize dhcp 4 * Use the syslog instead of the event_logger module 4 5 5 -- Evan Broder <broder@mit.edu> Sat, 04 Oct 2008 19:55:49 -04006 -- Evan Broder <broder@mit.edu> Sat, 04 Oct 2008 20:08:29 -0400 6 7 7 8 sipb-xen-dhcp (2) unstable; urgency=low
Note: See TracChangeset
for help on using the changeset viewer.