Beispiel #1
0
    def get_physical_disks(self):
        ret = []
        output = subprocess.getoutput(
            'storcli /c{}/eall/sall show all J'.format(self.controller_index)
        )
        drive_infos = json.loads(output)['Controllers'][self.controller_index]['Response Data']

        for physical_drive in self.data['PD LIST']:
            enclosure = physical_drive.get('EID:Slt').split(':')[0]
            slot = physical_drive.get('EID:Slt').split(':')[1]
            size = physical_drive.get('Size').strip()
            media_type = physical_drive.get('Med').strip()
            drive_identifier = 'Drive /c{}/e{}/s{}'.format(
                str(self.controller_index), str(enclosure), str(slot)
            )
            drive_attr = drive_infos['{} - Detailed Information'.format(drive_identifier)][
                '{} Device attributes'.format(drive_identifier)]
            model = drive_attr.get('Model Number', '').strip()
            ret.append({
                'Model': model,
                'Vendor': get_vendor(model),
                'SN': drive_attr.get('SN', '').strip(),
                'Size': size,
                'Type': media_type,
                '_src': self.__class__.__name__,
            })
        return ret
Beispiel #2
0
    def get_hw_disks(self):
        disks = []

        for disk in self.lshw.get_hw_linux("storage"):
            if self.is_virtual_disk(disk):
                continue

            logicalname = disk.get('logicalname')
            description = disk.get('description')
            size = disk.get('size', 0)
            product = disk.get('product')
            serial = disk.get('serial')

            d = {}
            d["name"] = ""
            d['Size'] = '{} GB'.format(int(size / 1024 / 1024 / 1024))
            d['logicalname'] = logicalname
            d['description'] = description
            d['SN'] = serial
            d['Model'] = product
            if disk.get('vendor'):
                d['Vendor'] = disk['vendor']
            else:
                d['Vendor'] = get_vendor(disk['product'])
            disks.append(d)

        for raid_card in self.get_raid_cards():
            disks += raid_card.get_physical_disks()

        # remove duplicate serials
        seen = set()
        uniq = [x for x in disks if x['SN'] not in seen and not seen.add(x['SN'])]
        return uniq
Beispiel #3
0
 def get_physical_disks(self):
     ret = []
     output = subprocess.getoutput(
         'omreport storage controller controller={} -fmt xml'.format(
             self.controller_index))
     root = ET.fromstring(output)
     et_array_disks = root.find('ArrayDisks')
     if et_array_disks is not None:
         for obj in et_array_disks.findall('DCStorageObject'):
             ret.append({
                 'Vendor':
                 get_vendor(get_field(obj, 'Vendor')),
                 'Model':
                 get_field(obj, 'ProductID'),
                 'SN':
                 get_field(obj, 'DeviceSerialNumber'),
                 'Size':
                 '{:.0f}GB'.format(
                     int(get_field(obj, 'Length')) / 1024 / 1024 / 1024),
                 'Type':
                 'HDD' if int(get_field(obj, 'MediaType')) == 1 else 'SSD',
                 '_src':
                 self.__class__.__name__,
             })
     return ret
Beispiel #4
0
    def get_physical_disks(self):
        ret = []
        output = subprocess.getoutput(
            'ssacli ctrl slot={slot} pd all show detail'.format(
                slot=self.data['Slot']))
        lines = output.split('\n')
        lines = list(filter(None, lines))
        j = -1
        while j < len(lines):
            info_dict, j = _get_dict(lines, j + 1, 0)

        key = next(iter(info_dict))
        for array, physical_disk in info_dict[key].items():
            for _, pd_attr in physical_disk.items():
                model = pd_attr.get('Model', '').strip()
                vendor = None
                if model.startswith('HP'):
                    vendor = 'HP'
                elif len(model.split()) > 1:
                    vendor = get_vendor(model.split()[1])
                else:
                    vendor = get_vendor(model)

                ret.append({
                    'Model':
                    model,
                    'Vendor':
                    vendor,
                    'SN':
                    pd_attr.get('Serial Number', '').strip(),
                    'Size':
                    pd_attr.get('Size', '').strip(),
                    'Type':
                    'SSD' if pd_attr.get('Interface Type')
                    == 'Solid State SATA' else 'HDD',
                    '_src':
                    self.__class__.__name__,
                })
        return ret