Пример #1
0
def detect_ipmi(hw_lst):
    'Detect IPMI interfaces.'
    modprobe("ipmi_smb")
    modprobe("ipmi_si")
    modprobe("ipmi_devintf")
    if (os.path.exists('/dev/ipmi0') or os.path.exists('/dev/ipmi/0')
            or os.path.exists('/dev/ipmidev/0')):
        for channel in range(0, 16):
            status, _ = cmd(
                'ipmitool channel info %d 2>&1 | grep -sq Volatile' % channel)
            if status == 0:
                hw_lst.append(('system', 'ipmi', 'channel', '%s' % channel))
                break
        status, output = cmd('ipmitool lan print')
        if status == 0:
            ipmi.parse_lan_info(output, hw_lst)

        return True

    # do we need a fake ipmi device for testing purpose ?
    status, _ = cmd('grep -qi FAKEIPMI /proc/cmdline')
    if status == 0:
        # Yes ! So let's create a fake entry
        hw_lst.append(('system', 'ipmi-fake', 'channel', '0'))
        sys.stderr.write('Info: Added fake IPMI device\n')
        return True

    sys.stderr.write('Info: No IPMI device found\n')
    return False
Пример #2
0
def detect_ipmi(hw_lst):
    'Detect IPMI interfaces.'
    modprobe("ipmi_smb")
    modprobe("ipmi_si")
    modprobe("ipmi_devintf")
    if (os.path.exists('/dev/ipmi0') or os.path.exists('/dev/ipmi/0') or
       os.path.exists('/dev/ipmidev/0')):
        for channel in range(0, 16):
            status, _ = cmd('ipmitool channel info %d 2>&1 | grep -sq Volatile'
                            % channel)
            if status == 0:
                hw_lst.append(('system', 'ipmi', 'channel', '%s' % channel))
                break
        status, output = cmd('ipmitool lan print')
        if status == 0:
            ipmi.parse_lan_info(output, hw_lst)
    else:
        # do we need a fake ipmi device for testing purpose ?
        status, _ = cmd('grep -qi FAKEIPMI /proc/cmdline')
        if status == 0:
            # Yes ! So let's create a fake entry
            hw_lst.append(('system', 'ipmi-fake', 'channel', '0'))
            sys.stderr.write('Info: Added fake IPMI device\n')
            return True
        else:
            sys.stderr.write('Info: No IPMI device found\n')
            return False
Пример #3
0
def detect_ipmi(hw_lst):
    "Detect IPMI interfaces."
    modprobe("ipmi_smb")
    modprobe("ipmi_si")
    modprobe("ipmi_devintf")
    if os.path.exists("/dev/ipmi0") or os.path.exists("/dev/ipmi/0") or os.path.exists("/dev/ipmidev/0"):
        for channel in range(0, 16):
            status, _ = cmd("ipmitool channel info %d 2>&1 | grep -sq Volatile" % channel)
            if status == 0:
                hw_lst.append(("system", "ipmi", "channel", "%s" % channel))
                break
        status, output = cmd("ipmitool lan print")
        if status == 0:
            ipmi.parse_lan_info(output, hw_lst)
    else:
        # do we need a fake ipmi device for testing purpose ?
        status, _ = cmd("grep -qi FAKEIPMI /proc/cmdline")
        if status == 0:
            # Yes ! So let's create a fake entry
            hw_lst.append(("system", "ipmi-fake", "channel", "0"))
            sys.stderr.write("Info: Added fake IPMI device\n")
            return True
        else:
            sys.stderr.write("Info: No IPMI device found\n")
            return False
Пример #4
0
 def test_parse_lan_info(self):
     res = []
     ipmi.parse_lan_info(sample('ipmi_lan_info'), res)
     self.assertEqual(len(res), 19)
Пример #5
0
 def test_parse_lan_info(self):
     res = []
     ipmi.parse_lan_info(sample('ipmi_lan_info'), res)
     self.assertEqual(len(res), 19)