Loads the internal store state from disk :return: None
(self)
| 286 | FACT_STORE_PATH.split(os.path.sep)[0]) |
| 287 | |
| 288 | async def _restore_state(self): |
| 289 | """ |
| 290 | Loads the internal store state from disk |
| 291 | |
| 292 | :return: None |
| 293 | """ |
| 294 | if os.path.exists(FACT_STORE_PATH): |
| 295 | _, store = await self.get_service('file_svc').read_file(FACT_STORE_PATH.split(os.path.sep)[1], |
| 296 | FACT_STORE_PATH.split(os.path.sep)[0]) |
| 297 | # Pickle is only used to load a local file that caldera creates. Pickled data is not |
| 298 | # received over the network. |
| 299 | ram = pickle.loads(store) # nosec |
| 300 | for key in ram.keys(): |
| 301 | self.fact_ram[key] = [] |
| 302 | for c_object in ram[key]: |
| 303 | handle = self._load_wrapper(key) |
| 304 | constraints = [] |
| 305 | if c_object._knowledge_id in ram[key]: |
| 306 | constraints = ram[key][c_object._knowledge_id] |
| 307 | await handle(c_object, constraints=constraints) |
| 308 | self.log.debug('Restored data from persistent storage') |
| 309 | |
| 310 | def _load_wrapper(self, key): |
| 311 | """ |
no test coverage detected