# Path: hardware/detect_utils.py
# AUXV_FLAGS = ["AT_HWCAP", "AT_HWCAP2", "AT_PAGESZ",
#               "AT_FLAGS", "AT_PLATFORM"]
# AUXV_OPT_FLAGS = ["AT_BASE_PLATFORM"]
# def cmd(cmdline):
# def output_lines(cmdline):
# def parse_lldtool(hw_lst, interface_name, lines):
# def get_lld_status(hw_lst, interface_name):
# def parse_ethtool(hw_lst, interface_name, lines):
# def get_ethtool_status(hw_lst, interface_name):
# def which(program):
#     def is_exe(fpath):
# def size_in_gb(size):
# def clean_str(val):
# def clean_tuples(lst):
# def _get_uuid_x86_64():
# def _get_uuid_ppc64le(hw_lst):
# def get_uuid(hw_lst):
# def get_value(hw_lst, *vect):
# def get_cidr(netmask):
# def from_file(filename):
# def fix_bad_serial(hw_lst, system_uuid, mobo_id, nic_id):
# def get_cpus(hw_lst):
#     def _maybe_int(v):
#     def _get_governor(lcpu):
# def modprobe(module):
# def detect_auxv():
# def parse_ahci(words):
# def parse_dmesg():
# 
# Path: hardware/detect_utils.py
# def cmd(cmdline):
#     """Equivalent of commands.getstatusoutput"""
#     try:
#         return 0, subprocess.check_output(cmdline,
#                                           shell=True, universal_newlines=True)
#     except subprocess.CalledProcessError as excpt:
#         return excpt.returncode, excpt.output


import re
import sys
from hardware import detect_utils
from hardware.detect_utils import cmd
            if re_dev is not None:
                global_card_info['device_type'] = re_dev.group(1)
            re_nb_ports = re.search('Number of ports: (.*)', line)
            if re_nb_ports is not None:
                global_card_info['nb_ports'] = re_nb_ports.group(1)
            re_fw_ver = re.search('Firmware version: (.*)', line)
            if re_fw_ver is not None:
                global_card_info['fw_ver'] = re_fw_ver.group(1)
            re_hw_ver = re.search('Hardware version: (.*)', line)
            if re_hw_ver is not None:
                global_card_info['hw_ver'] = re_hw_ver.group(1)
            re_node_guid = re.search('Node GUID: (.*)', line)
            if re_node_guid is not None:
                global_card_info['node_guid'] = re_node_guid.group(1)
            re_sys_guid = re.search('System image GUID: (.*)', line)
            if re_sys_guid is not None:
                global_card_info['sys_guid'] = re_sys_guid.group(1)
    return global_card_info


# {'base_lid': '0', 'port_guid': '0x0002c90300ea6841', 'rate': '40',
# 'physical_state': 'Down', 'sm_lid': '0', 'state': 'Down', 'lmc': '0'}
def ib_port_info(card_drv, port):
    """Return port infos of a IB card_drv in a python dict.

    :param card_drv: a card device ID (e.g. mlx4_0)
    :param port: the port number (e.g. 1)
    :returns: a list containing information on the port
    """
    port_infos = {}

# Path: hardware/detect_utils.py
# AUXV_FLAGS = ["AT_HWCAP", "AT_HWCAP2", "AT_PAGESZ",
#               "AT_FLAGS", "AT_PLATFORM"]
# AUXV_OPT_FLAGS = ["AT_BASE_PLATFORM"]
# def cmd(cmdline):
# def output_lines(cmdline):
# def parse_lldtool(hw_lst, interface_name, lines):
# def get_lld_status(hw_lst, interface_name):
# def parse_ethtool(hw_lst, interface_name, lines):
# def get_ethtool_status(hw_lst, interface_name):
# def which(program):
#     def is_exe(fpath):
# def size_in_gb(size):
# def clean_str(val):
# def clean_tuples(lst):
# def _get_uuid_x86_64():
# def _get_uuid_ppc64le(hw_lst):
# def get_uuid(hw_lst):
# def get_value(hw_lst, *vect):
# def get_cidr(netmask):
# def from_file(filename):
# def fix_bad_serial(hw_lst, system_uuid, mobo_id, nic_id):
# def get_cpus(hw_lst):
#     def _maybe_int(v):
#     def _get_governor(lcpu):
# def modprobe(module):
# def detect_auxv():
# def parse_ahci(words):
# def parse_dmesg():
# 
# Path: hardware/detect_utils.py
# def cmd(cmdline):
#     """Equivalent of commands.getstatusoutput"""
#     try:
#         return 0, subprocess.check_output(cmdline,
#                                           shell=True, universal_newlines=True)
#     except subprocess.CalledProcessError as excpt:
#         return excpt.returncode, excpt.output


# Path: hardware/infiniband.py
import re
import sys
from hardware import detect_utils
from hardware.detect_utils import cmd

            if re_dev is not None:
                global_card_info['device_type'] = re_dev.group(1)
            re_nb_ports = re.search('Number of ports: (.*)', line)
            if re_nb_ports is not None:
                global_card_info['nb_ports'] = re_nb_ports.group(1)
            re_fw_ver = re.search('Firmware version: (.*)', line)
            if re_fw_ver is not None:
                global_card_info['fw_ver'] = re_fw_ver.group(1)
            re_hw_ver = re.search('Hardware version: (.*)', line)
            if re_hw_ver is not None:
                global_card_info['hw_ver'] = re_hw_ver.group(1)
            re_node_guid = re.search('Node GUID: (.*)', line)
            if re_node_guid is not None:
                global_card_info['node_guid'] = re_node_guid.group(1)
            re_sys_guid = re.search('System image GUID: (.*)', line)
            if re_sys_guid is not None:
                global_card_info['sys_guid'] = re_sys_guid.group(1)
    return global_card_info


# {'base_lid': '0', 'port_guid': '0x0002c90300ea6841', 'rate': '40',
# 'physical_state': 'Down', 'sm_lid': '0', 'state': 'Down', 'lmc': '0'}
def ib_port_info(card_drv, port):
    """Return port infos of a IB card_drv in a python dict.

    :param card_drv: a card device ID (e.g. mlx4_0)
    :param port: the port number (e.g. 1)
    :returns: a list containing information on the port
    """
    port_infos = {}

    ret, port_desc = cmd('ibstat %s %i' % (card_drv, port))