[master 1/1] Adapt to the new libblockdev initialization API

vpodzime installerbot-noreply at redhat.com
Wed May 27 06:17:19 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

In version 1.0 the libblockdev library changes the initialization functions a
bit and thanks to that we may simplify our code.
---
 blivet/__init__.py | 19 ++++++-------------
 python-blivet.spec |  2 +-
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index 707b707..1ee9cef 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -67,20 +67,13 @@ def cb(self, exn):
 from gi.repository import BlockDev as blockdev
 _REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm"))
 _requested_plugins = blockdev.plugin_specs_from_names(_REQUESTED_PLUGIN_NAMES)
-if not blockdev.is_initialized():
-    try:
-        blockdev.try_init(require_plugins=_requested_plugins, log_func=log_bd_message)
-    except GLib.GError:
-        pass
+try:
+    succ_, avail_plugs = blockdev.try_reinit(require_plugins=_requested_plugins, reload=False, log_func=log_bd_message)
+except GLib.GError as err:
+    raise RuntimeError("Failed to intialize the libblockdev library: %s" % err)
 else:
-    avail_plugs = set(blockdev.get_available_plugin_names())
-    if avail_plugs != _REQUESTED_PLUGIN_NAMES:
-        try:
-            blockdev.reinit(require_plugins=_requested_plugins, reload=False, log_func=log_bd_message)
-        except GLib.GError:
-            pass
-
-avail_plugs = set(blockdev.get_available_plugin_names())
+    avail_plugs = set(avail_plugs)
+
 missing_plugs =  _REQUESTED_PLUGIN_NAMES - avail_plugs
 for p in missing_plugs:
     log.info("Failed to load plugin %s", p)
diff --git a/python-blivet.spec b/python-blivet.spec
index 975af8c..457dfb6 100644
--- a/python-blivet.spec
+++ b/python-blivet.spec
@@ -18,7 +18,7 @@ Source0: http://github.com/dwlehman/blivet/archive/%{realname}-%{version}.tar.gz
 %define pypartedver 3.10.4
 %define e2fsver 1.41.0
 %define utillinuxver 2.15.1
-%define libblockdevver 0.10
+%define libblockdevver 1.0
 
 BuildArch: noarch
 BuildRequires: gettext


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/8e31f6d48aa77aeec95ea7c957eac92853514121


More information about the anaconda-patches mailing list