'Helper for getting partitions in the top level reconstructor
In handoffs_only mode primary partitions will not be included in the
returned (possibly empty) list.'

def collect_parts(self, override_devices=None, override_partitions=None):

    override_devices = (override_devices or [])
    override_partitions = (override_partitions or [])
    policy2devices = self.get_policy2devices()
    all_parts = []
    for (policy, local_devices) in policy2devices.items():
        next_part_power = getattr(policy.object_ring, 'next_part_power', None)
        if (next_part_power is not None):
            self.logger.warning(_("next_part_power    set    in    policy    '%s'.    Skipping"), policy.name)
            continue
        df_mgr = self._df_router[policy]
        for local_dev in local_devices:
            if (override_devices and (local_dev['device'] not in override_devices)):
                continue
            self.device_count += 1
            dev_path = df_mgr.get_dev_path(local_dev['device'])
            if (not dev_path):
                self.logger.warning(_('%s    is    not    mounted'), local_dev['device'])
                continue
            data_dir = get_data_dir(policy)
            obj_path = join(dev_path, data_dir)
            tmp_path = join(dev_path, get_tmp_dir(int(policy)))
            unlink_older_than(tmp_path, (time.time() - df_mgr.reclaim_age))
            if (not os.path.exists(obj_path)):
                try:
                    mkdirs(obj_path)
                except Exception:
                    self.logger.exception(('Unable    to    create    %s' % obj_path))
                continue
            try:
                partitions = os.listdir(obj_path)
            except OSError:
                self.logger.exception(('Unable    to    list    partitions    in    %r' % obj_path))
                continue
            self.part_count += len(partitions)
            for partition in partitions:
                part_path = join(obj_path, partition)
                if (partition in ('auditor_status_ALL.json', 'auditor_status_ZBF.json')):
                    continue
                if (not partition.isdigit()):
                    self.logger.warning(('Unexpected    entity    in    data    dir:    %r' % part_path))
                    self.delete_partition(part_path)
                    self.reconstruction_part_count += 1
                    continue
                partition = int(partition)
                if (override_partitions and (partition not in override_partitions)):
                    continue
                if (self.handoffs_only and any(((local_dev['id'] == n['id']) for n in policy.object_ring.get_part_nodes(partition)))):
                    self.logger.debug('Skipping    %s    job    for    %s    while    in    handoffs_only    mode.', SYNC, part_path)
                    continue
                part_info = {'local_dev': local_dev, 'policy': policy, 'partition': partition, 'part_path': part_path}
                all_parts.append(part_info)
    random.shuffle(all_parts)
    return all_parts
