Example #1
0
def detect_megacli(hw_lst):
    'Detect LSI MegaRAID controller configuration.'
    ctrl_num = megacli.adp_count()
    disk_count = 0
    global_pdisk_size = 0
    if ctrl_num > 0:
        for ctrl in range(ctrl_num):
            ctrl_info = megacli.adp_all_info(ctrl)
            for entry in ctrl_info.keys():
                hw_lst.append(('megaraid', 'Controller_%d' % (ctrl),
                               '%s' % entry, '%s' % ctrl_info[entry]))

            for enc in megacli.enc_info(ctrl):
                if "Enclosure" in enc.keys():
                    for key in enc.keys():
                        if "ExitCode" in key or "Enclosure" in key:
                            continue
                        hw_lst.append(
                            ('megaraid', 'Controller_%d/Enclosure_%s' %
                             (ctrl, enc["Enclosure"]), '%s' % key,
                             '%s' % enc[key]))

                for slot_num in range(enc['NumberOfSlots']):
                    disk = 'disk%d' % slot_num
                    info = megacli.pdinfo(ctrl, enc['DeviceId'], slot_num)

                    # If no PdType, it means that's not a disk
                    if 'PdType' not in info.keys():
                        continue

                    disk_count += 1
                    hw_lst.append(('pdisk', disk, 'ctrl', str(ctrl_num)))
                    hw_lst.append(('pdisk', disk, 'type', info['PdType']))
                    hw_lst.append(
                        ('pdisk', disk, 'id',
                         '%s:%d' % (info['EnclosureDeviceId'], slot_num)))
                    disk_size = size_in_gb("%s %s" %
                                           (info['CoercedSize'].split()[0],
                                            info['CoercedSize'].split()[1]))
                    global_pdisk_size = global_pdisk_size + float(disk_size)
                    hw_lst.append(('pdisk', disk, 'size', disk_size))

                    for key in info.keys():
                        ignore_list = [
                            'PdType', 'EnclosureDeviceId', 'CoercedSize',
                            'ExitCode'
                        ]
                        if key not in ignore_list:
                            if "DriveTemperature" in key:
                                if "C" in str(info[key].split()[0]):
                                    pdisk = info[key].split()[0].split("C")[0]
                                    hw_lst.append(('pdisk', disk, key,
                                                   str(pdisk).strip()))
                                    hw_lst.append(
                                        ('pdisk', disk, "%s_units" % key,
                                         "Celsius"))
                                else:
                                    hw_lst.append(('pdisk', disk, key,
                                                   str(info[key]).strip()))

                            elif "InquiryData" in key:
                                count = 0
                                for mystring in info[key].split():
                                    hw_lst.append(('pdisk', disk,
                                                   "%s[%d]" % (key, count),
                                                   str(mystring.strip())))
                                    count = count + 1

                            else:
                                hw_lst.append(('pdisk', disk, key,
                                               str(info[key]).strip()))

                if global_pdisk_size > 0:
                    hw_lst.append(
                        ('pdisk', 'all', 'size', "%.2f" % global_pdisk_size))

                for ld_num in range(megacli.ld_get_num(ctrl)):
                    disk = 'disk%d' % ld_num
                    info = megacli.ld_get_info(ctrl, ld_num)
                    ignore_list = ['Size']

                    for item in info.keys():
                        if item not in ignore_list:
                            hw_lst.append(
                                ('ldisk', disk, item, str(info[item])))
                    if 'Size' in info:
                        hw_lst.append(
                            ('ldisk', disk, 'Size', size_in_gb(info['Size'])))
        hw_lst.append(('disk', 'megaraid', 'count', str(disk_count)))
        return True
    else:
        return False
Example #2
0
def detect_megacli(hw_lst):
    'Detect LSI MegaRAID controller configuration.'
    ctrl_num = megacli.adp_count()
    disk_count = 0
    global_pdisk_size = 0
    if ctrl_num > 0:
        for ctrl in range(ctrl_num):
            ctrl_info = megacli.adp_all_info(ctrl)
            for entry in ctrl_info.keys():
                hw_lst.append(('megaraid', 'Controller_%d' % (ctrl),
                               '%s' % entry, '%s' % ctrl_info[entry]))

            for enc in megacli.enc_info(ctrl):
                if "Enclosure" in enc.keys():
                    for key in enc.keys():
                        if "ExitCode" in key or "Enclosure" in key:
                            continue
                        hw_lst.append(('megaraid',
                                       'Controller_%d/Enclosure_%s' %
                                       (ctrl, enc["Enclosure"]),
                                       '%s' % key, '%s' % enc[key]))

                for slot_num in range(enc['NumberOfSlots']):
                    disk = 'disk%d' % slot_num
                    info = megacli.pdinfo(ctrl,
                                          enc['DeviceId'],
                                          slot_num)

                    # If no PdType, it means that's not a disk
                    if 'PdType' not in info.keys():
                        continue

                    disk_count += 1
                    hw_lst.append(('pdisk',
                                   disk,
                                   'ctrl',
                                   str(ctrl_num)))
                    hw_lst.append(('pdisk',
                                   disk,
                                   'type',
                                   info['PdType']))
                    hw_lst.append(('pdisk',
                                   disk,
                                   'id',
                                   '%s:%d' % (info['EnclosureDeviceId'],
                                              slot_num)))
                    disk_size = size_in_gb("%s %s" %
                                           (info['CoercedSize'].split()[0],
                                            info['CoercedSize'].split()[1]))
                    global_pdisk_size = global_pdisk_size + float(disk_size)
                    hw_lst.append(('pdisk',
                                   disk,
                                   'size',
                                   disk_size))

                    for key in info.keys():
                        ignore_list = ['PdType', 'EnclosureDeviceId',
                                       'CoercedSize', 'ExitCode']
                        if key not in ignore_list:
                            if "DriveTemperature" in key:
                                if "C" in str(info[key].split()[0]):
                                    pdisk = info[key].split()[0].split("C")[0]
                                    hw_lst.append(('pdisk', disk, key,
                                                   str(pdisk).strip()))
                                    hw_lst.append(('pdisk', disk,
                                                   "%s_units" % key,
                                                   "Celsius"))
                                else:
                                    hw_lst.append(('pdisk', disk, key,
                                                   str(info[key]).strip()))

                            elif "InquiryData" in key:
                                count = 0
                                for mystring in info[key].split():
                                    hw_lst.append(('pdisk', disk,
                                                   "%s[%d]" % (key, count),
                                                   str(mystring.strip())))
                                    count = count + 1

                            else:
                                hw_lst.append(('pdisk', disk, key,
                                               str(info[key]).strip()))

                if global_pdisk_size > 0:
                    hw_lst.append(('pdisk',
                                   'all',
                                   'size',
                                   "%.2f" % global_pdisk_size))

                for ld_num in range(megacli.ld_get_num(ctrl)):
                    disk = 'disk%d' % ld_num
                    info = megacli.ld_get_info(ctrl, ld_num)
                    hw_lst.append(('ldisk',
                                   disk,
                                   'current_access_policy',
                                   info['CurrentAccessPolicy']))
                    hw_lst.append(('ldisk',
                                   disk,
                                   'current_cache_policy',
                                   info['CurrentCachePolicy']))
                    hw_lst.append(('ldisk',
                                   disk,
                                   'disk_cache_policy',
                                   info['DiskCachePolicy']))
                    hw_lst.append(('ldisk',
                                   disk,
                                   'name',
                                   info['Name']))
                    try:
                        hw_lst.append(('ldisk',
                                       disk,
                                       'number_of_drives',
                                       str(info['NumberOfDrives'])))
                    except KeyError:
                        pass
                    try:
                        hw_lst.append(('ldisk',
                                       disk,
                                       'number_of_drives_per_span',
                                       str(info['NumberOfDrivesPerSpan'])))
                    except KeyError:
                        pass
                    hw_lst.append(('ldisk',
                                   disk,
                                   'raid_level',
                                   info['RaidLevel']))
                    hw_lst.append(('ldisk',
                                   disk,
                                   'sector_size',
                                   str(info['SectorSize'])))
                    hw_lst.append(('ldisk',
                                   disk,
                                   'state',
                                   info['State']))
                    hw_lst.append(('ldisk',
                                   disk,
                                   'Size',
                                   size_in_gb(info['Size'])))
                    hw_lst.append(('ldisk',
                                   disk,
                                   'strip_size',
                                   info['StripSize']))
        hw_lst.append(('disk', 'megaraid', 'count', str(disk_count)))
        return True
    else:
        return False
Example #3
0
 def test_adp_count(self):
     self.output = sample('megacli_adpcount')
     self.assertEqual(megacli.adp_count(), 1)
Example #4
0
def detect_megacli(hw_lst):
    'Detect LSI MegaRAID controller configuration.'
    ctrl_num = megacli.adp_count()
    disk_count = 0
    global_pdisk_size = 0
    if ctrl_num > 0:
        for ctrl in range(ctrl_num):
            ctrl_info = megacli.adp_all_info(ctrl)
            for entry in ctrl_info.keys():
                hw_lst.append(('megaraid', 'Controller_%d' % (ctrl),
                               '%s' % entry, '%s' % ctrl_info[entry]))

            for enc in megacli.enc_info(ctrl):
                if "Enclosure" in enc.keys():
                    for key in enc.keys():
                        if "ExitCode" in key or "Enclosure" in key:
                            continue
                        hw_lst.append(
                            ('megaraid', 'Controller_%d/Enclosure_%s' %
                             (ctrl, enc["Enclosure"]), '%s' % key,
                             '%s' % enc[key]))

                for slot_num in range(enc['NumberOfSlots']):
                    disk_count += 1
                    disk = 'disk%d' % slot_num
                    info = megacli.pdinfo(ctrl, enc['DeviceId'], slot_num)

                    # If no PdType, it means that's not a disk
                    if 'PdType' not in info.keys():
                        continue

                    hw_lst.append(('pdisk', disk, 'ctrl', str(ctrl_num)))
                    hw_lst.append(('pdisk', disk, 'type', info['PdType']))
                    hw_lst.append(
                        ('pdisk', disk, 'id',
                         '%s:%d' % (info['EnclosureDeviceId'], slot_num)))
                    disk_size = size_in_gb("%s %s" %
                                           (info['CoercedSize'].split()[0],
                                            info['CoercedSize'].split()[1]))
                    global_pdisk_size = global_pdisk_size + float(disk_size)
                    hw_lst.append(('pdisk', disk, 'size', disk_size))

                    for key in info.keys():
                        ignore_list = [
                            'PdType', 'EnclosureDeviceId', 'CoercedSize',
                            'ExitCode'
                        ]
                        if key not in ignore_list:
                            if "DriveTemperature" in key:
                                if "C" in str(info[key].split()[0]):
                                    a = str(info[key].split()[0].split("C")[0])
                                    hw_lst.append(
                                        ('pdisk', disk, key, a.strip()))
                                    hw_lst.append(
                                        ('pdisk', disk, "%s_units" % key,
                                         "Celsius"))
                                else:
                                    hw_lst.append(('pdisk', disk, key,
                                                   str(info[key]).strip()))

                            elif "InquiryData" in key:
                                count = 0
                                for mystring in info[key].split():
                                    hw_lst.append(('pdisk', disk,
                                                   "%s[%d]" % (key, count),
                                                   str(mystring.strip())))
                                    count = count + 1

                            else:
                                hw_lst.append(('pdisk', disk, key,
                                               str(info[key]).strip()))

                if global_pdisk_size > 0:
                    hw_lst.append(
                        ('pdisk', 'all', 'size', "%.2f" % global_pdisk_size))

                for ld_num in range(megacli.ld_get_num(ctrl)):
                    disk = 'disk%d' % ld_num
                    info = megacli.ld_get_info(ctrl, ld_num)
                    hw_lst.append(('ldisk', disk, 'current_access_policy',
                                   info['CurrentAccessPolicy']))
                    hw_lst.append(('ldisk', disk, 'current_cache_policy',
                                   info['CurrentCachePolicy']))
                    hw_lst.append(('ldisk', disk, 'disk_cache_policy',
                                   info['DiskCachePolicy']))
                    hw_lst.append(('ldisk', disk, 'name', info['Name']))
                    try:
                        hw_lst.append(('ldisk', disk, 'number_of_drives',
                                       str(info['NumberOfDrives'])))
                    except KeyError:
                        pass
                    try:
                        hw_lst.append(
                            ('ldisk', disk, 'number_of_drives_per_span',
                             str(info['NumberOfDrivesPerSpan'])))
                    except KeyError:
                        pass
                    hw_lst.append(
                        ('ldisk', disk, 'raid_level', info['RaidLevel']))
                    hw_lst.append(('ldisk', disk, 'sector_size',
                                   str(info['SectorSize'])))
                    hw_lst.append(('ldisk', disk, 'state', info['State']))
                    hw_lst.append(
                        ('ldisk', disk, 'Size', size_in_gb(info['Size'])))
                    hw_lst.append(
                        ('ldisk', disk, 'strip_size', info['StripSize']))
        hw_lst.append(('disk', 'megaraid', 'count', str(disk_count)))
        return True
    else:
        return False
Example #5
0
 def test_adp_count(self):
     self.output = sample('megacli_adpcount')
     self.assertEqual(megacli.adp_count(), 1)
Example #6
0
def detect_megacli(hw_lst):
    "Detect LSI MegaRAID controller configuration."
    ctrl_num = megacli.adp_count()
    disk_count = 0
    global_pdisk_size = 0
    if ctrl_num > 0:
        for ctrl in range(ctrl_num):
            ctrl_info = megacli.adp_all_info(ctrl)
            for entry in ctrl_info.keys():
                hw_lst.append(("megaraid", "Controller_%d" % (ctrl), "%s" % entry, "%s" % ctrl_info[entry]))

            for enc in megacli.enc_info(ctrl):
                if "Enclosure" in enc.keys():
                    for key in enc.keys():
                        if "ExitCode" in key or "Enclosure" in key:
                            continue
                        hw_lst.append(
                            (
                                "megaraid",
                                "Controller_%d/Enclosure_%s" % (ctrl, enc["Enclosure"]),
                                "%s" % key,
                                "%s" % enc[key],
                            )
                        )

                for slot_num in range(enc["NumberOfSlots"]):
                    disk = "disk%d" % slot_num
                    info = megacli.pdinfo(ctrl, enc["DeviceId"], slot_num)

                    # If no PdType, it means that's not a disk
                    if "PdType" not in info.keys():
                        continue

                    disk_count += 1
                    hw_lst.append(("pdisk", disk, "ctrl", str(ctrl_num)))
                    hw_lst.append(("pdisk", disk, "type", info["PdType"]))
                    hw_lst.append(("pdisk", disk, "id", "%s:%d" % (info["EnclosureDeviceId"], slot_num)))
                    disk_size = size_in_gb("%s %s" % (info["CoercedSize"].split()[0], info["CoercedSize"].split()[1]))
                    global_pdisk_size = global_pdisk_size + float(disk_size)
                    hw_lst.append(("pdisk", disk, "size", disk_size))

                    for key in info.keys():
                        ignore_list = ["PdType", "EnclosureDeviceId", "CoercedSize", "ExitCode"]
                        if key not in ignore_list:
                            if "DriveTemperature" in key:
                                if "C" in str(info[key].split()[0]):
                                    pdisk = info[key].split()[0].split("C")[0]
                                    hw_lst.append(("pdisk", disk, key, str(pdisk).strip()))
                                    hw_lst.append(("pdisk", disk, "%s_units" % key, "Celsius"))
                                else:
                                    hw_lst.append(("pdisk", disk, key, str(info[key]).strip()))

                            elif "InquiryData" in key:
                                count = 0
                                for mystring in info[key].split():
                                    hw_lst.append(("pdisk", disk, "%s[%d]" % (key, count), str(mystring.strip())))
                                    count = count + 1

                            else:
                                hw_lst.append(("pdisk", disk, key, str(info[key]).strip()))

                if global_pdisk_size > 0:
                    hw_lst.append(("pdisk", "all", "size", "%.2f" % global_pdisk_size))

                for ld_num in range(megacli.ld_get_num(ctrl)):
                    disk = "disk%d" % ld_num
                    info = megacli.ld_get_info(ctrl, ld_num)
                    hw_lst.append(("ldisk", disk, "current_access_policy", info["CurrentAccessPolicy"]))
                    hw_lst.append(("ldisk", disk, "current_cache_policy", info["CurrentCachePolicy"]))
                    hw_lst.append(("ldisk", disk, "disk_cache_policy", info["DiskCachePolicy"]))
                    hw_lst.append(("ldisk", disk, "name", info["Name"]))
                    try:
                        hw_lst.append(("ldisk", disk, "number_of_drives", str(info["NumberOfDrives"])))
                    except KeyError:
                        pass
                    try:
                        hw_lst.append(("ldisk", disk, "number_of_drives_per_span", str(info["NumberOfDrivesPerSpan"])))
                    except KeyError:
                        pass
                    hw_lst.append(("ldisk", disk, "raid_level", info["RaidLevel"]))
                    hw_lst.append(("ldisk", disk, "sector_size", str(info["SectorSize"])))
                    hw_lst.append(("ldisk", disk, "state", info["State"]))
                    hw_lst.append(("ldisk", disk, "Size", size_in_gb(info["Size"])))
                    hw_lst.append(("ldisk", disk, "strip_size", info["StripSize"]))
        hw_lst.append(("disk", "megaraid", "count", str(disk_count)))
        return True
    else:
        return False