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 17, 2018
1 parent 759d77a commit 52c4aff
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
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')])

3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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 52c4aff

Please sign in to comment.