Beispiel #1
0
def detect_megacli(hw_lst):
    'Detect LSI MegaRAID controller configuration.'
    ctrl_num = megacli.adp_count()
    if ctrl_num > 0:
        for ctrl in range(ctrl_num):
            enc = megacli.enc_info(ctrl)
            for disk_num in range(megacli.pd_get_num(ctrl)):
                disk = 'disk%d' % disk_num
                info = megacli.pdinfo(ctrl,
                                      enc['DeviceId'],
                                      disk_num)
                hw_lst.append(('disk',
                               disk,
                               'ctrl',
                               str(ctrl_num)))
                hw_lst.append(('disk',
                               disk,
                               'type',
                               info['PdType']))
                hw_lst.append(('disk',
                               disk,
                               'id',
                               '%s:%d' % (info['EnclosureDeviceId'],
                                          disk_num)))
                hw_lst.append(('disk',
                               disk,
                               'size',
                               info['CoercedSize'].split()[0]))
        return True
    else:
        return False
    def test_pdinfo(self):
        self.output = '''
Enclosure Device ID: 32
Slot Number: 5
Enclosure position: 1
Device Id: 5
WWN: 5000C50054C07E80
Sequence Number: 1
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS'''
        self.assertEqual(megacli.pdinfo(0, 32, 5),
                         {'DeviceId': 5,
                          'EnclosureDeviceId': 32,
                          'EnclosurePosition': 1,
                          'LastPredictiveFailureEventSeqNumber': 0,
                          'MediaErrorCount': 0,
                          'OtherErrorCount': 0,
                          'PdType': 'SAS',
                          'PredictiveFailureCount': 0,
                          'SequenceNumber': 1,
                          'SlotNumber': 5,
                          'Wwn': '5000C50054C07E80'}
                         )
Beispiel #3
0
    def test_pdinfo(self):
        self.output = '''
Enclosure Device ID: 32
Slot Number: 5
Enclosure position: 1
Device Id: 5
WWN: 5000C50054C07E80
Sequence Number: 1
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS'''
        self.assertEqual(
            megacli.pdinfo(0, 32, 5), {
                'DeviceId': 5,
                'EnclosureDeviceId': 32,
                'EnclosurePosition': 1,
                'LastPredictiveFailureEventSeqNumber': 0,
                'MediaErrorCount': 0,
                'OtherErrorCount': 0,
                'PdType': 'SAS',
                'PredictiveFailureCount': 0,
                'SequenceNumber': 1,
                'SlotNumber': 5,
                'Wwn': '5000C50054C07E80'
            })
Beispiel #4
0
def detect_megacli(hw_lst):
    'Detect LSI MegaRAID controller configuration.'
    ctrl_num = megacli.adp_count()
    disk_count = 0
    if ctrl_num > 0:
        for ctrl in range(ctrl_num):
            for enc in megacli.enc_info(ctrl):
                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)))
                    hw_lst.append(('pdisk', disk, 'size',
                                   info['CoercedSize'].split()[0]))
                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:
                        True
                    try:
                        hw_lst.append(
                            ('ldisk', disk, 'number_of_drives_per_span',
                             str(info['NumberOfDrivesPerSpan'])))
                    except:
                        True
                    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
Beispiel #5
0
def detect_megacli(hw_lst):
    'Detect LSI MegaRAID controller configuration.'
    ctrl_num = megacli.adp_count()
    disk_count = 0
    if ctrl_num > 0:
        for ctrl in range(ctrl_num):
            for enc in megacli.enc_info(ctrl):
                for disk_num in range(enc['NumberOfPhysicalDrives']):
                    disk_count += 1
                    disk = 'disk%d' % disk_num
                    info = megacli.pdinfo(ctrl,
                                          enc['DeviceId'],
                                          disk_num)
                    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'],
                                              disk_num)))
                    hw_lst.append(('pdisk',
                                   disk,
                                   'size',
                                   info['CoercedSize'].split()[0]))
                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:
                        True
                    try:
                        hw_lst.append(('ldisk',
                                       disk,
                                       'number_of_drives_per_span',
                                       str(info['NumberOfDrivesPerSpan'])))
                    except:
                        True
                    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
Beispiel #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_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]):
                                    hw_lst.append(('pdisk', disk, key, str(info[key].split()[0].split("C")[0]).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:
                        pass
                    try:
                        hw_lst.append(('ldisk',
                                       disk,
                                       'number_of_drives_per_span',
                                       str(info['NumberOfDrivesPerSpan'])))
                    except:
                        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
Beispiel #7
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):
            for enc in megacli.enc_info(ctrl):
                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))

                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:
                        pass
                    try:
                        hw_lst.append(('ldisk',
                                       disk,
                                       'number_of_drives_per_span',
                                       str(info['NumberOfDrivesPerSpan'])))
                    except:
                        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
Beispiel #8
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]):
                                    hw_lst.append(
                                        ('pdisk', disk, key,
                                         str(info[key].split()[0].split("C")
                                             [0]).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:
                        pass
                    try:
                        hw_lst.append(
                            ('ldisk', disk, 'number_of_drives_per_span',
                             str(info['NumberOfDrivesPerSpan'])))
                    except:
                        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