Ignore:
Timestamp:
Oct 4, 2008, 8:13:08 PM (16 years ago)
Author:
broder
Message:

Use the syslog module instead of the event_logger module

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  
    1010import IN
    1111
    12 import event_logger
    13 if '__main__' == __name__:
    14     event_logger.init("stdout", 'DEBUG', {})
    15 from event_logger import Log
     12import syslog as s
    1613
    1714import psycopg2
     
    5148            parts = line.split()
    5249            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])
    5451                return parts[0]
    5552        return
     
    108105
    109106    def Discover(self, packet):
    110         Log.Output(Log.debug,"dhcp_backend : Discover ")
     107        s.syslog(s.LOG_DEBUG, "dhcp_backend : Discover ")
    111108        chaddr = hwmac(packet.GetHardwareAddress())
    112109        nic = self.findNIC(str(chaddr))
     
    131128        if ip is not None:
    132129            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))
    134131            packet_parameters = self.getParameters(**options)
    135132
     
    142139       
    143140    def Request(self, packet):
    144         Log.Output(Log.debug, "dhcp_backend : Request")
     141        s.syslog(s.LOG_DEBUG, "dhcp_backend : Request")
    145142       
    146143        discover = self.Discover(packet)
     
    153150
    154151        if not discover:
    155             Log.Output(Log.info,"Unknown MAC address: "+str(chaddr))
     152            s.syslog(s.LOG_INFO,"Unknown MAC address: "+str(chaddr))
    156153            return False
    157154       
    158155        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))
    160157            return True
    161158        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))
    163160        return False
    164161
     
    173170        pydhcplib.dhcp_network.DhcpServer.__init__(self,"0.0.0.0",options["client_listen_port"],options["server_listen_port"],)
    174171        self.backend = backend
    175         Log.Output(Log.debug, "__init__ DhcpServer")
     172        s.syslog(s.LOG_DEBUG, "__init__ DhcpServer")
    176173
    177174    def SendDhcpPacketTo(self, To, packet):
     
    198195            agent_ip = ".".join(map(str,giaddr))
    199196            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)
    201198
    202199        # FIXME: This shouldn't broadcast if it has an IP address to send
    203200        # it to instead. See RFC2131 part 4.1 for full details
    204201        else :
    205             Log.Output(Log.debug, "No agent, broadcast packet.")
     202            s.syslog(s.LOG_DEBUG, "No agent, broadcast packet.")
    206203            self.SendDhcpPacketTo("255.255.255.255",packet)
    207204           
     
    213210        logmsg = "Get DHCPDISCOVER packet from " + hwmac(packet.GetHardwareAddress()).str()
    214211
    215         Log.Output(Log.info, logmsg)
     212        s.syslog(s.LOG_INFO, logmsg)
    216213        offer = DhcpPacket()
    217214        offer.CreateDhcpOfferPacketFrom(packet)
     
    233230
    234231        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")
    236233
    237234        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")
    239236
    240237        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")
    244241
    245242        if self.backend.Request(packet) : packet.TransformToDhcpAckPacket()
     
    252249    # FIXME: These are not yet implemented.
    253250    def HandleDhcpDecline(self, packet):
    254         Log.Output(Log.info, "Get DHCPDECLINE packet")
     251        s.syslog(s.LOG_INFO, "Get DHCPDECLINE packet")
    255252        self.backend.Decline(packet)
    256253       
    257254    def HandleDhcpRelease(self, packet):
    258         Log.Output(Log.info,"Get DHCPRELEASE packet")
     255        s.syslog(s.LOG_INFO,"Get DHCPRELEASE packet")
    259256        self.backend.Release(packet)
    260257       
    261258    def HandleDhcpInform(self, packet):
    262         Log.Output(Log.info, "Get DHCPINFORM packet")
     259        s.syslog(s.LOG_INFO, "Get DHCPINFORM packet")
    263260
    264261        if self.backend.Request(packet) :
  • trunk/packages/sipb-xen-dhcp/debian/changelog

    r1033 r1034  
    22
    33  * invirt-configurize dhcp
     4  * Use the syslog instead of the event_logger module
    45
    5  -- Evan Broder <broder@mit.edu>  Sat, 04 Oct 2008 19:55:49 -0400
     6 -- Evan Broder <broder@mit.edu>  Sat, 04 Oct 2008 20:08:29 -0400
    67
    78sipb-xen-dhcp (2) unstable; urgency=low
Note: See TracChangeset for help on using the changeset viewer.