Beispiel #1
0
def detect_disks(hw_lst):
    """Detect disks."""

    names = diskinfo.disknames()
    sizes = diskinfo.disksizes(names)
    disks = [name for name, size in sizes.items() if size > 0]
    hw_lst.append(('disk', 'logical', 'count', str(len(disks))))
    for name in disks:
        diskinfo.get_disk_info(name, sizes, hw_lst)

        # nvme devices do not need standard cache mechanisms
        if not name.startswith('nvme'):
            diskinfo.get_disk_cache(name, hw_lst)

        diskinfo.get_disk_id(name, hw_lst)

        # smartctl support
        # run only if smartctl command is there
        if which("smartctl"):
            if name.startswith('nvme'):
                sys.stderr.write('Reading SMART for nvme\n')
                smart_utils.read_smart_nvme(hw_lst, name)
            else:
                smart_utils.read_smart(hw_lst, "/dev/%s" % name)
        else:
            sys.stderr.write("Cannot find smartctl, exiting\n")
Beispiel #2
0
    def test_read_smart_call_smart_scsi(self, mock_popen, mock_os_path_exists,
                                        mock_scsi):
        hwlst = []
        fake_output = sample('smartctl_scsi', mode='rb').splitlines()
        mock_popen.return_value = mock.Mock(stdout=fake_output)
        smart_utils.read_smart(hwlst, 'fake')

        mock_scsi.assert_called()
Beispiel #3
0
    def test_read_smart_call_smart_ata(self, mock_popen, mock_os_path_exists,
                                       mock_ata, mock_which):
        hwlst = []
        fake_output = sample('smartctl_ata').splitlines()
        mock_popen.return_value = mock.Mock(stdout=fake_output)
        smart_utils.read_smart(hwlst, 'fake')

        mock_ata.assert_called()
Beispiel #4
0
def detect_disks(hw_lst):
    """Detect disks."""

    names = diskinfo.disknames()
    sizes = diskinfo.disksizes(names)
    disks = [name for name, size in sizes.items() if size > 0]
    hw_lst.append(('disk', 'logical', 'count', str(len(disks))))
    for name in disks:
        diskinfo.get_disk_info(name, sizes, hw_lst)

        # nvme devices do not need standard cache mechanisms
        if not name.startswith('nvme'):
            diskinfo.get_disk_cache(name, hw_lst)

        diskinfo.get_disk_id(name, hw_lst)

        # TODO(rpittau): add smart-tools support for nvme devices
        if not name.startswith('nvme'):
            smart_utils.read_smart(hw_lst, "/dev/%s" % name)