Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
0
    def test_ld_get_num(self):
        self.output = '''
 Number of Virtual Drives Configured on Adapter 0: 1'''
        self.assertEqual(megacli.ld_get_num(0), 1)
Ejemplo n.º 5
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
Ejemplo n.º 6
0
    def test_ld_get_num(self):
        self.output = '''
 Number of Virtual Drives Configured on Adapter 0: 1'''
        self.assertEqual(megacli.ld_get_num(0), 1)
Ejemplo n.º 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):
            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