Changeset 483

Show
Ignore:
Timestamp:
05/23/08 14:16:22 (8 months ago)
Author:
jmowery
Message:

update to agent storage

Files:

Legend:

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

    r482 r483  
    111111        def updated_modules(self): 
    112112                ''' 
    113                 Not sure what this should do at the moment. 
    114                 FIXME: Jeremy please help flesh this out. 
    115  
    116113                compare current modules with modules in store 
    117114                if different, return the modules message (currently 
     
    151148                        file_set = msg.body 
    152149                        msg.body = {} 
    153                         for file_name, version, checksum in file_set: 
    154                                 print file_name, version #XXX debug 
    155                                 status.set_module(file_name, version
     150                        for file_name, group, version, local, checksum in file_set: 
     151                                print file_name, group, version, local #XXX debug 
     152                                self.storage.set_file_status(file_name, group, version, local
    156153                                if checksum != None: 
    157                                         msg.body[file_name] = status.verify_module(file_name, version, checksum) 
     154                                        msg.body[file_name] = self.storage.verify_file(file_name, version, checksum) 
    158155                                else: 
    159156                                        msg.body[file_name] = True 
    160                         status.update() 
     157                        self.storage.update() 
    161158                        return msg 
    162159 
    163160                if (msg.msg == "file status"): 
    164                         status = agent_storage.AgentSystemData() 
    165                         msg.type = "response" 
    166                         msg.body = status.get_status() 
    167                         status.update() 
     161                        msg.type = "response" 
     162                        if msg.body == 'ALL': 
     163                                file_list = None 
     164                        else: 
     165                                file_list = msg.body 
     166                        msg.body = self.storage.get_file_status(file_list) 
    168167                        return msg 
    169168 
  • branches/trunk-pmd-intproto/agent/agent_storage.py

    r482 r483  
    137137                store.update() 
    138138 
     139        def get_file_status(self, names=None): 
     140                '''Get a dictionary of file status entries for each file in names or all if names is None.''' 
     141                store = storage.Layer(self.store_path) 
     142                if not names: 
     143                        names = store.list_controlled_files() 
     144                stats = {} 
     145                for name in names: 
     146                        if not store.entries.has_key(name): 
     147                                raise RuntimeError, 'No entry for file \'' + name + '\'.' 
     148                        stats[name] = store.entries[name] 
     149                return stats 
     150 
    139151        def update(self): 
    140152                '''Sync all data to disk''' 
  • branches/trunk-pmd-intproto/server/storage.py

    r482 r483  
    994994        def append_log_messages(self, id, messages): 
    995995                '''Append log messages to the stored log cache for node id.''' 
    996                 if not storage: 
     996                if not self.storage: 
    997997                        return False 
    998998                if id not in self.list_nodes(): 
     
    10151015                return messages 
    10161016 
    1017         #TODO clear_log(self, id)? 
     1017        def clear_log(self, id): 
     1018                '''Clear the log messages for node id.''' 
     1019                if not self.storage: 
     1020                        return #nothing to do if not controlled 
     1021                if id not in self.list_nodes(): 
     1022                        return #nothing to clear 
     1023                #open write to truncate and close 
     1024                log_file = open(os.path.join(self.storage.logs_dir, id), 'w') 
     1025                log_file.close() 
     1026                return 
    10181027 
    10191028        #other 
     
    10531062        '''The node object holds all storage relevant data about a single node connected to the store.''' 
    10541063 
    1055         def __init__(self, id, root): 
     1064        def __init__(self, id, root, classification=''): 
    10561065                self.modified = False      # Set whenever the status data has been modified since last sync to disk 
    10571066                self.id = ''               # Id of the node (currently its IP address) 
     
    10691078                self.classify() 
    10701079                self.update() 
     1080                if classification: 
     1081                        self.classify(classification) 
     1082                        self.update() 
    10711083 
    10721084        def __del__(self): 
     
    11891201                                classification = os.path.dirname(classification) 
    11901202                        old_classification = self.classification 
     1203                        if os.path.basename(old_classification) == self.id: 
     1204                                if os.path.dirname(old_classification) == classification:# reclassifying to same place without the local customization directory; 
     1205                                        return # this actually does not change the classification 
    11911206                        old_dirs = self.list_layers() 
    11921207                        cl = get_layer_by_group(self.root, classification)