[PATCH 01/11] First little step towards libblockdev
Anne Mulhern
amulhern at redhat.com
Tue Feb 3 12:04:55 UTC 2015
----- Original Message -----
> From: "Vratislav Podzimek" <vpodzime at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Sunday, February 1, 2015 7:15:51 PM
> Subject: [PATCH 01/11] First little step towards libblockdev
>
> We need to import and init the library first and give it the logging function
> for utils exection.
^exection^execution ?
>
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
> blivet/__init__.py | 9 +++++++++
> python-blivet.spec | 3 +++
> 2 files changed, 12 insertions(+)
>
> diff --git a/blivet/__init__.py b/blivet/__init__.py
> index 3128c89..1514a1d 100644
> --- a/blivet/__init__.py
> +++ b/blivet/__init__.py
> @@ -93,6 +93,15 @@ import contextlib
>
> import logging
> log = logging.getLogger("blivet")
> +program_log = logging.getLogger("program")
> +
> +# XXX: respect the level? Need to translate between C and Python log levels.
> +log_bd_message = lambda level, msg: program_log.info(msg)
> +
> +from gi.repository import BlockDev
> +if not BlockDev.is_initialized():
> + # for now, we want all the plugins to be available (i.e. init() to
> return True)
What will happen later?
> + assert BlockDev.init(force_plugins=None, log_func=log_bd_message)
>
I do not understand why you use assert here instead of the usual try/except,
i.e., I don't see why you would want to pass this in production and fail in
dev, asssuming we ever end up distinguishing the two.
> def enable_installer_mode():
> """ Configure the module for use by anaconda (OS installer). """
> diff --git a/python-blivet.spec b/python-blivet.spec
> index 258db88..b101bfa 100644
> --- a/python-blivet.spec
> +++ b/python-blivet.spec
> @@ -20,6 +20,7 @@ Source0:
> http://github.com/dwlehman/blivet/archive/%{realname}-%{version}.tar.gz
> %define pythoncryptsetupver 0.1.1
> %define utillinuxver 2.15.1
> %define lvm2ver 2.02.99
> +%define libblockdevver 0.5
>
> BuildArch: noarch
> BuildRequires: gettext
> @@ -43,6 +44,8 @@ Requires: btrfs-progs
> Requires: python-pyblock >= %{pythonpyblockver}
> Requires: device-mapper-multipath
> Requires: lsof
> +Requires: libblockdev >= %{libblockdevver}
> +Requires: libblockdev-plugins-all >= %{libblockdevver}
>
> %description
> The python-blivet package is a python module for examining and modifying
> --
> 2.1.0
>
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
>
About libblockdev:
Any chance you could use pointers to functions in
BDPluginStatus struct to turn that long chunk of loading code in load_plugins
into a loop? It looks like you have decided it is necessary to include all
plugin_api/*.c files in blockdev.c, so you might as well get the benefit.
- mulhern
More information about the anaconda-patches
mailing list