Blob Blame History Raw
From 8af58432afeec89467699b36d5e3d9fcc2120cc9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
Date: Fri, 5 May 2017 13:51:05 +0200
Subject: [PATCH] inventory: added workaround for pyudev < 0.18
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is needed for e.g. RHEL-7.4.

Related: rhbz#1251240

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
---
 tuned/hardware/inventory.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tuned/hardware/inventory.py b/tuned/hardware/inventory.py
index 7a24348..8c5117d 100644
--- a/tuned/hardware/inventory.py
+++ b/tuned/hardware/inventory.py
@@ -30,7 +30,11 @@ class Inventory(object):
 
 	def get_device(self, subsystem, sys_name):
 		"""Get a pyudev.Device object for the sys_name (e.g. 'sda')."""
-		return pyudev.Devices.from_name(self._udev_context, subsystem, sys_name)
+		try:
+			return pyudev.Devices.from_name(self._udev_context, subsystem, sys_name)
+		# workaround for pyudev < 0.18
+		except AttributeError:
+			return pyudev.Device.from_name(self._udev_context, subsystem, sys_name)
 
 	def get_devices(self, subsystem):
 		"""Get list of devices on a given subsystem."""
-- 
2.9.3