Changeset 453

Show
Ignore:
Timestamp:
05/12/08 14:06:31 (8 months ago)
Author:
mgoldman
Message:

Add server auto-download log logic.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/trunk-pmd-intproto/server/master.py

    r452 r453  
    5858        def service_client(self): 
    5959                pass 
     60 
     61### 
     62###  Auxillary functions to handle specific tasks. 
     63### 
     64###  The functions that query agents should be updated to create the  
     65###  message for a specific client only.  The sending to specific (or all) 
     66###  clients should be handled by the function self.comm() 
     67### 
     68###  Querys against the server itself should continue to to return the msg 
     69###  to be sent back to the manager. 
    6070 
    6171        def updatep(self, (mgr, info), msg, clientid=None): 
     
    242252 
    243253        def comm(self, func, msg, (mgr, info)): 
     254                ''' 
     255                This function takes a function that "personalizes" a message for 
     256                a particular client 
     257                The message to personalize, 
     258                and a manager and info. 
     259                Also, it takes a targetid. 
     260 
     261                The functions sends messages to the targets in the original message 
     262                and returns a list of their result pairs. ''' 
    244263                target = msg.targets 
    245264                msg.targets = None 
     
    254273                        tlist = targetexpand(target) 
    255274                        for t in tlist: 
    256                                 self.clients.send_key(func((mgr, info), deepcopy(msg)), t) 
     275                                self.clients.send_key(func((mgr, info), deepcopy(msg), t), t) 
    257276                        res = [] 
    258277                        for t in tlist: 
     
    271290                return [self.service_manager(m) for m in self.manager.accept_and_wait(timeout)] 
    272291 
     292        def updatelogs(self): 
     293                ''' Updates server side logs for all known clients. ''' 
     294                msg = protocol.Message() 
     295                msg.msg = "log" 
     296                msg.type = "query" 
     297                msg.body = "UPDATE" 
     298                # Call the comm function to send the messages and collect the results 
     299                # first function just returns the message, pass in the message and 
     300                # None for the manager and info since we aren't going to use it. 
     301                res = self.comm(lambda *x: msg, msg, (None, None)) 
     302                # FIXME: Put in code here to store the messages in the storage subsytem 
     303 
     304 
    273305 
    274306if __name__ == "__main__": 
    275307        m = Master() 
     308        cntr = 0 
    276309        while True: 
    277310                print "sheep" 
    278311                m.run2(5) 
     312                if(cntr % 12 == 0): 
     313                        m.updatelogs() 
     314                cntr += 1