async def async_snapshots_cleaner(instance): vm = Instance(instance) logger.info( f'Search and deleting snapshots older than {config.lifetime} days for instance {vm.name}' ) snapshots = vm.get_old_snapshots() if not snapshots: logger.info( f'Snapshots older than {config.lifetime} days not found for instance {vm.name}' ) return for snapshot in snapshots: await vm.async_operation_complete(vm.delete_snapshot(data=snapshot))
def snapshots_cleaner(): logger.info( f'Search and deleting snapshots older than {config.lifetime} days') for instance in INSTANCES: vm = Instance(instance) snapshots = vm.get_old_snapshots() if not snapshots: logger.info( f'Snapshots older than {config.lifetime} days not found for instance {vm.name}' ) continue for snapshot in snapshots: delete_snap = vm.delete_snapshot(data=snapshot) if vm.operation_complete(delete_snap): continue