'Generates statistics from host and volume data.'

def _generate_stats(self, host_state, weight_properties):

    host_stats = {'host': host_state.host, 'volume_backend_name': host_state.volume_backend_name, 'vendor_name': host_state.vendor_name, 'driver_version': host_state.driver_version, 'storage_protocol': host_state.storage_protocol, 'QoS_support': host_state.QoS_support, 'total_capacity_gb': host_state.total_capacity_gb, 'allocated_capacity_gb': host_state.allocated_capacity_gb, 'free_capacity_gb': host_state.free_capacity_gb, 'reserved_percentage': host_state.reserved_percentage, 'updated': host_state.updated}
    host_caps = host_state.capabilities
    goodness_function = None
    if (('goodness_function' in host_caps) and (host_caps['goodness_function'] is not None)):
        goodness_function = six.text_type(host_caps['goodness_function'])
    qos_specs = weight_properties.get('qos_specs', {})
    volume_type = weight_properties.get('volume_type', {})
    extra_specs = volume_type.get('extra_specs', {})
    request_spec = weight_properties.get('request_spec', {})
    volume_stats = request_spec.get('volume_properties', {})
    stats = {'host_stats': host_stats, 'host_caps': host_caps, 'extra_specs': extra_specs, 'qos_specs': qos_specs, 'volume_stats': volume_stats, 'volume_type': volume_type, 'goodness_function': goodness_function}
    return stats
