neil / rpms / python-blivet

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