| Conditions | 3 | 
| Total Lines | 28 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 2 | 
| CRAP Score | 8.8593 | 
| 1 | 1 | from plugin.core.backup.maintenance import BackupMaintenanceManager | |
| 16 | 1 | @classmethod | |
| 17 | 1 | def maintenance(cls, block=True): | |
| 18 | """Ensures number of backups in each group matches retention policy, runs consolidation | ||
| 19 | deletion, and archival tasks if the policy has been exceeded. | ||
| 20 | |||
| 21 | :param block: Block execution until maintenance is complete | ||
| 22 | :type block: bool | ||
| 23 | """ | ||
| 24 | |||
| 25 | if not block: | ||
| 26 | return spawn(cls.maintenance, block=True) | ||
| 27 | |||
| 28 | if not cls.maintenance_lock.acquire(False): | ||
| 29 |             log.debug('Backup maintenance already running') | ||
| 30 | return | ||
| 31 | |||
| 32 |         log.info('Starting backup maintenance...') | ||
| 33 | |||
| 34 | try: | ||
| 35 | # Run policy maintenance tasks | ||
| 36 | maintenance = BackupMaintenanceManager() | ||
| 37 | maintenance.run() | ||
| 38 | except Exception, ex: | ||
| 39 |             log.error('Exception raised during backup maintenance: %s', ex, exc_info=True) | ||
| 40 | finally: | ||
| 41 | cls.maintenance_lock.release() | ||
| 42 | |||
| 43 |         log.info('Backup maintenance complete') | ||
| 44 |