Changeset 483
- 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
| r482 |
r483 |
|
| 111 | 111 | def updated_modules(self): |
|---|
| 112 | 112 | ''' |
|---|
| 113 | | Not sure what this should do at the moment. |
|---|
| 114 | | FIXME: Jeremy please help flesh this out. |
|---|
| 115 | | |
|---|
| 116 | 113 | compare current modules with modules in store |
|---|
| 117 | 114 | if different, return the modules message (currently |
|---|
| … | … | |
| 151 | 148 | file_set = msg.body |
|---|
| 152 | 149 | 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) |
|---|
| 156 | 153 | 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) |
|---|
| 158 | 155 | else: |
|---|
| 159 | 156 | msg.body[file_name] = True |
|---|
| 160 | | status.update() |
|---|
| | 157 | self.storage.update() |
|---|
| 161 | 158 | return msg |
|---|
| 162 | 159 | |
|---|
| 163 | 160 | 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) |
|---|
| 168 | 167 | return msg |
|---|
| 169 | 168 | |
|---|
| r482 |
r483 |
|
| 137 | 137 | store.update() |
|---|
| 138 | 138 | |
|---|
| | 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 | |
|---|
| 139 | 151 | def update(self): |
|---|
| 140 | 152 | '''Sync all data to disk''' |
|---|
| r482 |
r483 |
|
| 994 | 994 | def append_log_messages(self, id, messages): |
|---|
| 995 | 995 | '''Append log messages to the stored log cache for node id.''' |
|---|
| 996 | | if not storage: |
|---|
| | 996 | if not self.storage: |
|---|
| 997 | 997 | return False |
|---|
| 998 | 998 | if id not in self.list_nodes(): |
|---|
| … | … | |
| 1015 | 1015 | return messages |
|---|
| 1016 | 1016 | |
|---|
| 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 |
|---|
| 1018 | 1027 | |
|---|
| 1019 | 1028 | #other |
|---|
| … | … | |
| 1053 | 1062 | '''The node object holds all storage relevant data about a single node connected to the store.''' |
|---|
| 1054 | 1063 | |
|---|
| 1055 | | def __init__(self, id, root): |
|---|
| | 1064 | def __init__(self, id, root, classification=''): |
|---|
| 1056 | 1065 | self.modified = False # Set whenever the status data has been modified since last sync to disk |
|---|
| 1057 | 1066 | self.id = '' # Id of the node (currently its IP address) |
|---|
| … | … | |
| 1069 | 1078 | self.classify() |
|---|
| 1070 | 1079 | self.update() |
|---|
| | 1080 | if classification: |
|---|
| | 1081 | self.classify(classification) |
|---|
| | 1082 | self.update() |
|---|
| 1071 | 1083 | |
|---|
| 1072 | 1084 | def __del__(self): |
|---|
| … | … | |
| 1189 | 1201 | classification = os.path.dirname(classification) |
|---|
| 1190 | 1202 | 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 |
|---|
| 1191 | 1206 | old_dirs = self.list_layers() |
|---|
| 1192 | 1207 | cl = get_layer_by_group(self.root, classification) |
|---|
Download in other formats:
* Generating other formats may take time.