コード例 #1
0
ファイル: disks.py プロジェクト: truenas/py-fenced
 def __init__(self, fence, name, log_info=None):
     self.fence = fence
     self.name = name
     self.log_info = log_info
     self.curkey = None
     self.scsi = libsgio.SCSIDevice(f'/dev/{name}')
     self.nvme = None
コード例 #2
0
    def get_rotational_rate(self, device_path):

        try:
            disk = libsgio.SCSIDevice(device_path)
            rotation_rate = disk.rotation_rate()
        except (OSError, RuntimeError):
            self.logger.error('Ioctl failed while retrieving rotational rate for disk %s', device_path)
            return

        if rotation_rate in (0, 1):
            # 0 = not reported
            # 1 = SSD
            return

        return str(rotation_rate)
コード例 #3
0
    def get_rotational_rate(self, device_path):
        try:
            disk = libsgio.SCSIDevice(device_path)
            rotation_rate = disk.rotation_rate()
        except (OSError, RuntimeError):
            if device_path not in self.DISK_ROTATION_ERROR_LOG_CACHE:
                self.DISK_ROTATION_ERROR_LOG_CACHE.add(device_path)
                self.logger.error('Ioctl failed while retrieving rotational rate for disk %s', device_path)
            return
        else:
            self.DISK_ROTATION_ERROR_LOG_CACHE.discard(device_path)

        if rotation_rate in (0, 1):
            # 0 = not reported
            # 1 = SSD
            return

        return str(rotation_rate)
コード例 #4
0
    def get_rotational_rate(self, device_path):

        try:
            disk = libsgio.SCSIDevice(device_path)
            rotation_rate = disk.rotation_rate()
        except Exception as e:
            self.logger.error(
                'Failed to retrieve rotational rate '
                'for disk %s with error: %r', device_path, e
            )
            return

        if rotation_rate in (0, 1):
            # 0 = not reported
            # 1 = SSD
            return

        return str(rotation_rate)