[PATCH v2][Kimchi 0/2] Makes Kimchi better use /etc

v2: - Apply review changes v1: - Kimchi package version was not looking at /etc/kimchi - Moves template.conf to /etc Rodrigo Trujillo (2): Fix issue #840: Change distros.d internal path Move 'template.conf' to /etc Makefile.am | 7 +++++-- config.py.in | 5 ++++- contrib/kimchi.spec.fedora.in | 1 - contrib/kimchi.spec.suse.in | 1 - model/config.py | 4 ++++ model/networks.py | 4 ++-- model/storagepools.py | 5 ++--- osinfo.py | 3 ++- tests/test_model.py | 8 ++++---- 9 files changed, 23 insertions(+), 15 deletions(-) -- 2.1.0

When you install Kimchi package, it is going to install distros.d in /etc/kimchi. However, internally, Kimchi is using the path /etc/wok/plugins.d/kimchi, leading to errors. This patch fixes this problem making Kimchi use /etc/kimchi/distros.d. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- config.py.in | 5 ++++- model/config.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.py.in b/config.py.in index 3c1c13a..e645d5d 100644 --- a/config.py.in +++ b/config.py.in @@ -42,7 +42,7 @@ def get_kimchi_version(): def get_distros_store(): - return os.path.join(PluginPaths('kimchi').conf_dir, 'distros.d') + return os.path.join(kimchiPaths.sysconf_dir, 'distros.d') def get_debugreports_path(): @@ -115,8 +115,11 @@ class KimchiPaths(PluginPaths): if self.installed: self.spice_css_file = os.path.join(self.spice_dir, 'spice.css') + # Expose system configuration directory + self.sysconf_dir = os.path.join('@sysconfdir@', 'kimchi') else: self.spice_css_file = os.path.join(self.spice_dir, 'css/spice.css') + self.sysconf_dir = self.add_prefix(self.plugin_dir) self.serial_dir = os.path.join(self.ui_dir, 'serial') diff --git a/model/config.py b/model/config.py index ccfd1b3..f5d2792 100644 --- a/model/config.py +++ b/model/config.py @@ -134,6 +134,10 @@ class DistrosModel(object): return distro['name'] n_processes = len(self.distros.keys()) + # Avoid problems if the for some reason the files are not in the right + # place, or were deleted, or moved or not supported in the arch + if n_processes < 1: + return [] pool = ThreadPool(processes=n_processes) map_res = pool.map_async(validate_distro, self.distros.values()) pool.close() -- 2.1.0

'template.conf' is being written in /etc/wok/plugins.d, which is not the correct path, since template.conf is only related to Kimchi, wok does not make use of it. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- Makefile.am | 7 +++++-- contrib/kimchi.spec.fedora.in | 1 - contrib/kimchi.spec.suse.in | 1 - model/networks.py | 4 ++-- model/storagepools.py | 5 ++--- osinfo.py | 3 ++- tests/test_model.py | 8 ++++---- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8382a31..1b46773 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,8 +32,11 @@ endif wokdir = $(pythondir)/wok kimchidir = $(pythondir)/wok/plugins/kimchi -confdir = $(sysconfdir)/wok/plugins.d -dist_conf_DATA = kimchi.conf template.conf +wokconfdir = $(sysconfdir)/wok/plugins.d +dist_wokconf_DATA = kimchi.conf + +confdir = $(sysconfdir)/kimchi +dist_conf_DATA = template.conf AUTOMAKE_OPTIONS = foreign diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index c2111f9..292ad03 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -81,7 +81,6 @@ rm -rf $RPM_BUILD_ROOT %{_prefix}/share/locale/*/LC_MESSAGES/kimchi.mo %{_datadir}/wok/plugins/kimchi/ %{_sysconfdir}/wok/plugins.d/kimchi.conf -%{_sysconfdir}/wok/plugins.d/template.conf %{_sysconfdir}/kimchi/ %{_sharedstatedir}/kimchi/ %{_sysconfdir}/systemd/system/wokd.service.d/kimchi.conf diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in index 59207fd..7a57538 100644 --- a/contrib/kimchi.spec.suse.in +++ b/contrib/kimchi.spec.suse.in @@ -68,7 +68,6 @@ rm -rf $RPM_BUILD_ROOT %{_prefix}/share/locale/*/LC_MESSAGES/kimchi.mo %{_datadir}/wok/plugins/kimchi/ %{_sysconfdir}/wok/plugins.d/kimchi.conf -%{_sysconfdir}/wok/plugins.d/template.conf %{_sysconfdir}/kimchi/ %{_var}/lib/kimchi/ %{_sysconfdir}/systemd/system/wokd.service.d/kimchi.conf diff --git a/model/networks.py b/model/networks.py index f42be77..2664af3 100644 --- a/model/networks.py +++ b/model/networks.py @@ -24,7 +24,6 @@ import time from libvirt import VIR_INTERFACE_XML_INACTIVE from xml.sax.saxutils import escape -from wok.config import PluginPaths from wok.exception import InvalidOperation, InvalidParameter from wok.exception import MissingParameter, NotFoundError, OperationFailed from wok.utils import run_command, wok_log @@ -32,6 +31,7 @@ from wok.xmlutils.utils import xpath_get_text from wok.plugins.kimchi import netinfo from wok.plugins.kimchi import network as knetwork +from wok.plugins.kimchi.config import kimchiPaths from wok.plugins.kimchi.model.config import CapabilitiesModel from wok.plugins.kimchi.osinfo import defaults as tmpl_defaults from wok.plugins.kimchi.xmlutils.interface import get_iface_xml @@ -58,7 +58,7 @@ class NetworksModel(object): error_msg = ("Please, check the configuration in %s/template.conf to " "ensure it lists only valid networks." % - PluginPaths('kimchi').conf_dir) + kimchiPaths.sysconf_dir) for net_name in networks: try: diff --git a/model/storagepools.py b/model/storagepools.py index 20c1cd0..cf3ed21 100644 --- a/model/storagepools.py +++ b/model/storagepools.py @@ -22,13 +22,12 @@ import lxml.etree as ET import sys from lxml.builder import E -from wok.config import PluginPaths from wok.exception import InvalidOperation, MissingParameter from wok.exception import NotFoundError, OperationFailed from wok.utils import add_task, run_command, wok_log from wok.xmlutils.utils import xpath_get_text -from wok.plugins.kimchi.config import config, get_kimchi_version +from wok.plugins.kimchi.config import config, get_kimchi_version, kimchiPaths from wok.plugins.kimchi.model.config import CapabilitiesModel from wok.plugins.kimchi.model.host import DeviceModel from wok.plugins.kimchi.model.libvirtstoragepool import StoragePoolDef @@ -83,7 +82,7 @@ class StoragePoolsModel(object): error_msg = ("Please, check the configuration in %s/template.conf to " "ensure it has a valid storage pool." % - PluginPaths('kimchi').conf_dir) + kimchiPaths.sysconf_dir) conn = self.conn.get() for pool_name in pools: diff --git a/osinfo.py b/osinfo.py index 7560657..7b80f29 100644 --- a/osinfo.py +++ b/osinfo.py @@ -26,6 +26,7 @@ from configobj import ConfigObj from distutils.version import LooseVersion from wok.config import PluginPaths +from wok.plugins.kimchi.config import kimchiPaths SUPPORTED_ARCHS = {'x86': ('i386', 'i686', 'x86_64'), @@ -136,7 +137,7 @@ def _get_tmpl_defaults(): default_config = ConfigObj(tmpl_defaults) # Load template configuration file - config_file = os.path.join(PluginPaths('kimchi').conf_dir, 'template.conf') + config_file = os.path.join(kimchiPaths.sysconf_dir, 'template.conf') config = ConfigObj(config_file) # Merge default configuration with file configuration diff --git a/tests/test_model.py b/tests/test_model.py index fc7ee10..b461172 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -651,9 +651,9 @@ class ModelTests(unittest.TestCase): "format = %s\n\n[graphics]\n\n[processor]\n"\ % vol_format - config_file = os.path.join(paths.conf_dir, 'template.conf') + config_file = os.path.join(paths.sysconf_dir, 'template.conf') config_bkp_file = \ - os.path.join(paths.conf_dir, 'template.conf-unit_test_bkp') + os.path.join(paths.sysconf_dir, 'template.conf-unit_test_bkp') os.rename(config_file, config_bkp_file) @@ -663,9 +663,9 @@ class ModelTests(unittest.TestCase): osinfo.defaults = osinfo._get_tmpl_defaults() def _restore_template_conf_file(self): - config_file = os.path.join(paths.conf_dir, 'template.conf') + config_file = os.path.join(paths.sysconf_dir, 'template.conf') config_bkp_file = \ - os.path.join(paths.conf_dir, 'template.conf-unit_test_bkp') + os.path.join(paths.sysconf_dir, 'template.conf-unit_test_bkp') os.rename(config_bkp_file, config_file) osinfo.defaults = osinfo._get_tmpl_defaults() -- 2.1.0
participants (2)
-
Aline Manera
-
Rodrigo Trujillo