disk plugin: use hardware enumeration
This commit is contained in:
parent
ff6b179455
commit
148203c54a
1 changed files with 12 additions and 17 deletions
|
|
@ -12,7 +12,18 @@ class DiskPlugin(base.Plugin):
|
|||
Plugin for tuning options of disks.
|
||||
"""
|
||||
|
||||
_supported_vendors = ["ATA", "SCSI"]
|
||||
@classmethod
|
||||
def device_requirements(cls):
|
||||
return {
|
||||
"subsystem": "block",
|
||||
"device_type": "disk",
|
||||
"custom": cls._is_supported_disk,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def _is_supported_disk(cls, device):
|
||||
return device.attributes["removable"] == "0" \
|
||||
and device.parent is not None and device.parent.subsystem in ["scsi", "virtio"]
|
||||
|
||||
def _post_init(self):
|
||||
self.devidle = {}
|
||||
|
|
@ -26,22 +37,6 @@ class DiskPlugin(base.Plugin):
|
|||
else:
|
||||
self._dynamic_tuning = False
|
||||
|
||||
@classmethod
|
||||
def tunable_devices(cls):
|
||||
block_devices = os.listdir("/sys/block")
|
||||
available = set(filter(cls._is_device_supported, block_devices))
|
||||
return available
|
||||
|
||||
@classmethod
|
||||
def _is_device_supported(cls, device):
|
||||
vendor_file = "/sys/block/%s/device/vendor" % device
|
||||
try:
|
||||
vendor = open(vendor_file).read().strip()
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
return vendor in cls._supported_vendors
|
||||
|
||||
@classmethod
|
||||
def _get_default_options(cls):
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in a new issue