@contract
def init_state(config):
    vir_connection = libvirt.openReadOnly(None)
    if vir_connection is None:
        message = 'Failed to open a connection to the hypervisor'
        log.critical(message)
        raise OSError(message)

    hostname = vir_connection.getHostname()
    host_cpu_mhz, host_ram = get_host_characteristics(vir_connection)
    physical_cpus = common.physical_cpu_count(vir_connection)
    host_cpu_usable_by_vms = float(config['host_cpu_usable_by_vms'])

    db = init_db(config['sql_connection'])
    db.update_host(hostname,
                   int(host_cpu_mhz * host_cpu_usable_by_vms),
                   physical_cpus,
                   host_ram)

    return {'previous_time': 0.,
            'previous_cpu_time': dict(),
            'previous_cpu_mhz': dict(),
            'previous_host_cpu_time_total': 0.,
            'previous_host_cpu_time_busy': 0.,
            'previous_overload': -1,
            'vir_connection': vir_connection,
            'hostname': hostname,
            'host_cpu_overload_threshold':
                float(config['host_cpu_overload_threshold']) * \
                host_cpu_usable_by_vms,
            'physical_cpus': physical_cpus,
            'physical_cpu_mhz': host_cpu_mhz,
            'physical_core_mhz': host_cpu_mhz / physical_cpus,
            'db': db}
Initialize a dict for storing the state of the data collector.
dataset/ETHPy150Open beloglazov/openstack-neat/neat/locals/collector.py/init_state