neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

Blame SOURCES/0006-Fix-potential-AttributeError-when-getting-stratis-bl.patch

a9158f
From 7931a74e691979dd23a16e7a017b4ef5bc296b79 Mon Sep 17 00:00:00 2001
a9158f
From: Vojtech Trefny <vtrefny@redhat.com>
a9158f
Date: Tue, 18 Oct 2022 12:28:37 +0200
a9158f
Subject: [PATCH] Fix potential AttributeError when getting stratis blockdev
a9158f
 info
a9158f
a9158f
---
a9158f
 blivet/static_data/stratis_info.py | 12 +++++++-----
a9158f
 1 file changed, 7 insertions(+), 5 deletions(-)
a9158f
a9158f
diff --git a/blivet/static_data/stratis_info.py b/blivet/static_data/stratis_info.py
a9158f
index bd1c5a18..42f230ee 100644
a9158f
--- a/blivet/static_data/stratis_info.py
a9158f
+++ b/blivet/static_data/stratis_info.py
a9158f
@@ -124,20 +124,22 @@ class StratisInfo(object):
a9158f
             log.error("Failed to get DBus properties of '%s'", blockdev_path)
a9158f
             return None
a9158f
 
a9158f
+        blockdev_uuid = str(uuid.UUID(properties["Uuid"]))
a9158f
+
a9158f
         pool_path = properties["Pool"]
a9158f
         if pool_path == "/":
a9158f
             pool_name = ""
a9158f
+            return StratisBlockdevInfo(path=properties["Devnode"], uuid=blockdev_uuid,
a9158f
+                                       pool_name="", pool_uuid="", object_path=blockdev_path)
a9158f
         else:
a9158f
             pool_info = self._get_pool_info(properties["Pool"])
a9158f
             if not pool_info:
a9158f
                 return None
a9158f
             pool_name = pool_info.name
a9158f
 
a9158f
-        blockdev_uuid = str(uuid.UUID(properties["Uuid"]))
a9158f
-
a9158f
-        return StratisBlockdevInfo(path=properties["Devnode"], uuid=blockdev_uuid,
a9158f
-                                   pool_name=pool_name, pool_uuid=pool_info.uuid,
a9158f
-                                   object_path=blockdev_path)
a9158f
+            return StratisBlockdevInfo(path=properties["Devnode"], uuid=blockdev_uuid,
a9158f
+                                       pool_name=pool_name, pool_uuid=pool_info.uuid,
a9158f
+                                       object_path=blockdev_path)
a9158f
 
a9158f
     def _get_locked_pools_info(self):
a9158f
         locked_pools = []
a9158f
-- 
a9158f
2.37.3
a9158f