'Generates statistics from backend and volume data.'

def _generate_stats(self, backend_state, filter_properties):

    backend_stats = {'host': backend_state.host, 'cluster_name': backend_state.cluster_name, 'backend_id': backend_state.backend_id, 'volume_backend_name': backend_state.volume_backend_name, 'vendor_name': backend_state.vendor_name, 'driver_version': backend_state.driver_version, 'storage_protocol': backend_state.storage_protocol, 'QoS_support': backend_state.QoS_support, 'total_capacity_gb': backend_state.total_capacity_gb, 'allocated_capacity_gb': backend_state.allocated_capacity_gb, 'free_capacity_gb': backend_state.free_capacity_gb, 'reserved_percentage': backend_state.reserved_percentage, 'updated': backend_state.updated}
    backend_caps = backend_state.capabilities
    filter_function = None
    if (('filter_function' in backend_caps) and (backend_caps['filter_function'] is not None)):
        filter_function = six.text_type(backend_caps['filter_function'])
    qos_specs = filter_properties.get('qos_specs', {})
    volume_type = filter_properties.get('volume_type', {})
    extra_specs = volume_type.get('extra_specs', {})
    request_spec = filter_properties.get('request_spec', {})
    volume_stats = request_spec.get('volume_properties', {})
    stats = {'backend_stats': backend_stats, 'backend_caps': backend_caps, 'extra_specs': extra_specs, 'qos_specs': qos_specs, 'volume_stats': volume_stats, 'volume_type': volume_type, 'filter_function': filter_function}
    return stats
