Skip to content

Commit

Permalink
FIXME: Use SettingPlugin to register config files
Browse files Browse the repository at this point in the history
/* Incomplete version, the missing pieces are:
 * 1. fix symlinks location
 * 2. make sure LTS works well (disable vt_settings on LTS)
 */

Recently Avocado introduced a SettingPlugin, that allows Avocado plugins
to register/modify paths to be processed by "avocado.core.settings".
Let's use this instead of symlinking of our etc config files.

For now we also have to keep the symlinking because the avocado 52.x
(LTS) does not support this feature.

Signed-off-by: Lukáš Doktor <[email protected]>
  • Loading branch information
ldoktor committed Aug 14, 2019
1 parent 5b6a0af commit 850ec0a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ develop:
$(PYTHON) setup.py develop $(PYTHON_DEVELOP_ARGS)

link: develop
for CONF in etc/avocado/conf.d/*; do\
[ -d "../$(AVOCADO_DIRNAME)/avocado/etc/avocado/conf.d" ] && ln -srf $(CURDIR)/$$CONF ../$(AVOCADO_DIRNAME)/avocado/$$CONF || true;\
[ -d "../$(AVOCADO_DIRNAME)/etc/avocado/conf.d" ] && ln -srf $(CURDIR)/$$CONF ../$(AVOCADO_DIRNAME)/$$CONF || true;\
for NAME in $$(ls -1 avocado_vt/conf.d); do\
[ -d "../$(AVOCADO_DIRNAME)/avocado/etc/avocado/conf.d" ] && ln -srf $(CURDIR)/avocado_vt/conf.d/$$NAME ../$(AVOCADO_DIRNAME)/avocado/etc/avocado/conf.d/$$NAME || true;\
[ -d "../$(AVOCADO_DIRNAME)/etc/avocado/conf.d" ] && ln -srf $(CURDIR)/avocado_vt/conf.d/$$NAME ../$(AVOCADO_DIRNAME)/avocado/etc/avocado/conf.d/$$NAME || true;\
done

unlink:
$(PYTHON) setup.py develop --uninstall $(PYTHON_DEVELOP_ARGS)
for CONF in etc/avocado/conf.d/*; do\
for NAME in $$(ls -1 avocado_vt/conf.d); do\
CONF="etc/avocado/conf.d/$$NAME";\
[ -L ../$(AVOCADO_DIRNAME)/avocado/$$CONF ] && rm -f ../$(AVOCADO_DIRNAME)/avocado/$$CONF || true;\
[ -L ../$(AVOCADO_DIRNAME)/$$CONF ] && rm -f ../$(AVOCADO_DIRNAME)/$$CONF || true;\
done
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions avocado_vt/plugins/vt_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2018
# Author: Lukas Doktor <[email protected]>

"""
Avocado plugin that extends the settings path of our config paths
"""

import os
from pkg_resources import resource_filename
from pkg_resources import resource_isdir
from pkg_resources import resource_listdir

from avocado.core.plugin_interfaces import Settings


class VTSettings(Settings):
def adjust_settings_paths(self, paths):
base = resource_filename('avocado_vt', 'conf.d')
paths.extend([os.path.join(base, conf)
for conf in resource_listdir('avocado_vt', 'conf.d')
if conf.endswith('.conf')])

7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ def pre_post_plugin_type():
if __name__ == "__main__":
requirements = ["netifaces", "aexpect", "netaddr", "simplejson"]
if sys.version_info[:2] >= (2, 7):
requirements.append("avocado-framework")
requirements.append("avocado-framework>=68.0")
else:
# Latest py2 supported stevedore is 1.10.0, need to limit it here
# as older avocado versions were not limiting it.
# Note: Avocado 70+ doesn't require stevedore and older Avocado
# can use whatever version of stevedore on py3
requirements.append("stevedore>=1.8.0,<=1.10.0")
requirements.append("avocado-framework<70.0")
requirements.append("avocado-framework>=68.0,<70.0")

setup(name='avocado-framework-plugins-vt',
version=VERSION,
Expand All @@ -100,6 +100,9 @@ def pre_post_plugin_type():
package_data={"virttest": ["*.*"]},
data_files=get_data_files(),
entry_points={
'avocado.plugins.settings': [
'vt-settings = avocado_vt.plugins.vt_settings:VTSettings',
],
'avocado.plugins.cli': [
'vt-list = avocado_vt.plugins.vt_list:VTLister',
'vt = avocado_vt.plugins.vt:VTRun',
Expand Down

0 comments on commit 850ec0a

Please sign in to comment.