Ejemplo n.º 1
0
def get_system_core_count(dictionary):
    """
    Args:
        dictionary - lshw dict
    Return:
        Total number of cores in the system
    """
    cpu_dict = json_parse._get_dictionary_using_unique_pair(
        dictionary, 'description', 'CPU')
    return cpu_dict['configuration']['cores']
Ejemplo n.º 2
0
def get_mem_slot_count(dictionary):
    """
    Args:
        dictionary - lshw dict
    Return:
        number of memory slots in system
    """
    slots = json_parse._get_dictionary_using_unique_pair(
        dictionary, 'id', 'memory')
    if slots != None:
        slot_num = 1
    else:
        slot_num = 0
        slots = json_parse._get_dictionary_using_unique_pair(
            dictionary, 'id', 'memory:' + str(slot_num))
        while slots != None:
            slot_num += 1
            slots = json_parse._get_dictionary_using_unique_pair(
                dictionary, 'id', 'memory:' + str(slot_num))
    return slot_num
Ejemplo n.º 3
0
def get_memory_dictionary(dictionary):
    """
    Args:
        dictionary - lshw dict
    Return:
        list of entire child dictionaries that contains key: class value: memory<#>
    """
    mem_list = []
    slots = get_mem_slot_count(dictionary)
    if slots == 1:
        mem_list.append(
            json_parse._get_dictionary_using_unique_pair(
                dictionary, 'id', 'memory'))
    else:
        for mem in range(slots):
            mem_list.append(
                json_parse._get_dictionary_using_unique_pair(
                    dictionary, 'id', 'memory:' + str(mem)))

    return mem_list
Ejemplo n.º 4
0
def get_dpdk_driver(dictionary, pci):
    """
    Args:
        dictionary - lshw dict
        interface - interface that you are looking fir
            ex.  0000:00:14.3
    Return:
        the interface driver for the network with pci
    """
    return json_parse._get_dictionary_using_unique_pair(
        dictionary, 'businfo', 'pci@' + str(pci))['configuration']['driver']
Ejemplo n.º 5
0
def get_dpdk_nic(dictionary, pci):
    """
    Args:
        dictionary - lshw dict
        pci - pci of host system
            ex.
    Return:
        Nic linked to the system network with pci
    """
    return json_parse._get_dictionary_using_unique_pair(
        dictionary, 'businfo', 'pci@' + str(pci))['product']
Ejemplo n.º 6
0
def get_network_interface_dictionary(dictionary, interface):
    """
    Args:
        dictionary - lshw dict
        interface - interface that you are looking fir
            ex.  0000:00:14.3
    Return:
        the interface child dictionary that contains the key: logicalname value: *interface*
    """
    return json_parse._get_dictionary_using_unique_pair(
        dictionary, 'logicalname', interface)
Ejemplo n.º 7
0
def get_cpu_info(dictionary):
    """
    Args:
        dictionary - lshw dict
    Return:
        A stripped down version of CPU info
    """
    cpu_count = get_cpu_count(dictionary)
    cpu_info = json_parse._get_dictionary_using_unique_pair(
        dictionary, 'description', 'CPU')
    cpu_info['cpu_count'] = cpu_count
    clear_fields = [
        'vendor', 'id', 'slot', 'handle', 'description', 'businfo',
        'capabilities', 'physid', 'size'
    ]
    for field in clear_fields:
        cpu_info.pop(field, None)
    return cpu_info