import collections


def generate_component_report(host_results):
    """Aggregate a list of results from the `components` deploy command."""
    report = collections.defaultdict(collections.Counter)
    for host, results in host_results.iteritems():
        for result in results.get('output', []):
            if result.command[0] != 'components':
                continue
            # Example result.result['components']:
            #
            #     {
            #         'foo': {
            #             'abcdef': 2,
            #         },
            #     }
            for component, sha_counts in result.result['components'].iteritems():
                for sha, count in sha_counts.iteritems():
                    report[component][sha] += count
    return report