def get_all_multipath_block_devices(self):
        from infi.devicemanager import DeviceManager
        from infi.wmpio import WmiClient, get_multipath_devices
        device_manager = DeviceManager()
        wmi_client = WmiClient()

        def _iter():
            for disk_drive in device_manager.disk_drives:
                if not is_disk_drive_managed_by_windows_mpio(disk_drive):
                    continue
                yield disk_drive

        devices = list(_iter())
        multipath_dict = get_multipath_devices(wmi_client)
        policies_dict = LazyLoadBalancingInfomrationDict(wmi_client)

        def _get_multipath_object(device_object):
            key = u"%s_0" % device_object._instance_id
            if key not in multipath_dict:
                raise RescanIsNeeded()
            return multipath_dict[key]

        def _get_multipath_device(device_object):
            return WindowsNativeMultipathBlockDevice(device_object, _get_multipath_object(device_object), policies_dict)

        def _is_physical_drive(device_object):
            return device_object.get_physical_drive_number() != -1

        return filter(_is_physical_drive, map(_get_multipath_device, devices))
Example #2
0
 def get_io_statistics(self):
     from infi.wmpio import get_device_performance, get_multipath_devices, WmiClient
     wmi_client = WmiClient()
     device_wmi_path = self._multipath_object.InstanceName
     all_performance_counters = get_device_performance(wmi_client)
     all_devices = get_multipath_devices(wmi_client)
     if device_wmi_path not in all_performance_counters:
         logger.warn('no perfomance countrs for device {}'.format(device_wmi_path), exc_info=1)
         return multipath.PathStatistics(0, 0, 0, 0)
     device_performance = all_performance_counters[device_wmi_path]
     path_perfromance = device_performance.PerfInfo[self.get_path_id()]
     return multipath.PathStatistics(path_perfromance.BytesRead,
                                     path_perfromance.BytesWritten,
                                     path_perfromance.NumberReads,
                                     path_perfromance.NumberWrites)
Example #3
0
 def get_io_statistics(self):
     from infi.wmpio import get_device_performance, get_multipath_devices, WmiClient
     wmi_client = WmiClient()
     device_wmi_path = self._multipath_object.InstanceName
     all_performance_counters = get_device_performance(wmi_client)
     all_devices = get_multipath_devices(wmi_client)
     if device_wmi_path not in all_performance_counters:
         logger.warn(
             'no perfomance countrs for device {}'.format(device_wmi_path),
             exc_info=1)
         return multipath.PathStatistics(0, 0, 0, 0)
     device_performance = all_performance_counters[device_wmi_path]
     path_perfromance = device_performance.PerfInfo[self.get_path_id()]
     return multipath.PathStatistics(path_perfromance.BytesRead,
                                     path_perfromance.BytesWritten,
                                     path_perfromance.NumberReads,
                                     path_perfromance.NumberWrites)
Example #4
0
    def get_all_multipath_block_devices(self):
        from infi.storagemodel.base.gevent_wrapper import run_together
        from infi.devicemanager import DeviceManager
        from infi.wmpio import WmiClient, get_multipath_devices
        from functools import partial
        device_manager = DeviceManager()
        wmi_client = WmiClient()
        physical_drives = set()

        multipath_dict = get_multipath_devices(wmi_client)
        policies_dict = LazyLoadBalancingInfomrationDict(wmi_client)

        def _get_multipath_object(device_object):
            prefix = u"%s_" % device_object._instance_id
            for key in multipath_dict:
                if key.startswith(prefix):
                    return multipath_dict[key]
            return None

        def _is_physical_drive(device_object):
            if device_object.get_physical_drive_number() != -1:
                physical_drives.add(device_object)

        def _iter_disk_drives():
            for disk_drive in device_manager.disk_drives:
                if not is_disk_drive_managed_by_windows_mpio(disk_drive):
                    logger.debug("disk drive {} is not managed by mpio".format(
                        disk_drive))
                    continue
                multipath_object = _get_multipath_object(disk_drive)
                if multipath_object is None:
                    logger.error(
                        "no matching MPIO WMI instance found for disk drive {} (instance_id={!r})"
                        .format(disk_drive, disk_drive._instance_id))
                    continue
                yield WindowsNativeMultipathBlockDevice(
                    disk_drive, multipath_object, policies_dict)

        run_together(
            partial(_is_physical_drive, drive)
            for drive in _iter_disk_drives())
        return list(physical_drives)
    def get_all_multipath_block_devices(self):
        from infi.devicemanager import DeviceManager
        from infi.wmpio import WmiClient, get_multipath_devices

        device_manager = DeviceManager()
        wmi_client = WmiClient()

        devices = filter(lambda device: device.parent._instance_id.lower() == MPIO_BUS_DRIVER_INSTANCE_ID,
                         device_manager.disk_drives)
        multipath_dict = get_multipath_devices(wmi_client)
        policies_dict = LazyLoadBalancingInfomrationDict(wmi_client)

        def _get_multipath_object(device_object):
            key = u"%s_0" % device_object._instance_id
            if not multipath_dict.has_key(key):
                raise RescanIsNeeded()
            return multipath_dict[key]

        def _get_multipath_device(device_object):
            return WindowsNativeMultipathBlockDevice(device_object, _get_multipath_object(device_object), policies_dict)

        return map(_get_multipath_device, devices)
    def get_all_multipath_block_devices(self):
        from infi.storagemodel.base.gevent_wrapper import run_together
        from infi.devicemanager import DeviceManager
        from infi.wmpio import WmiClient, get_multipath_devices
        from functools import partial
        device_manager = DeviceManager()
        wmi_client = WmiClient()
        physical_drives = set()

        multipath_dict = get_multipath_devices(wmi_client)
        policies_dict = LazyLoadBalancingInfomrationDict(wmi_client)

        def _get_multipath_object(device_object):
            prefix = u"%s_" % device_object._instance_id
            for key in multipath_dict:
                if key.startswith(prefix):
                    return multipath_dict[key]
            return None

        def _is_physical_drive(device_object):
            if device_object.get_physical_drive_number() != -1:
                physical_drives.add(device_object)

        def _iter_disk_drives():
            for disk_drive in device_manager.disk_drives:
                if not is_disk_drive_managed_by_windows_mpio(disk_drive):
                    logger.debug("disk drive {} is not managed by mpio".format(disk_drive))
                    continue
                multipath_object = _get_multipath_object(disk_drive)
                if multipath_object is None:
                    logger.error("no matching MPIO WMI instance found for disk drive {} (instance_id={!r})".format(disk_drive, disk_drive._instance_id))
                    continue
                yield WindowsNativeMultipathBlockDevice(disk_drive, multipath_object, policies_dict)


        run_together(partial(_is_physical_drive, drive) for drive in _iter_disk_drives())
        return list(physical_drives)