From 5f451f63cfce1cd3950259da14fdf245d42ad5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20BERSAC?= Date: Wed, 22 Apr 2015 15:16:20 +0200 Subject: [PATCH] Fix fileserver backends __opts__ overwritten by _pillar --- salt/fileserver/__init__.py | 6 ++++++ salt/master.py | 17 +++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/salt/fileserver/__init__.py b/salt/fileserver/__init__.py index 51944fb8fa..a6f82c886e 100644 --- a/salt/fileserver/__init__.py +++ b/salt/fileserver/__init__.py @@ -306,6 +306,12 @@ class Fileserver(object): ''' return self.opts + def update_opts(self): + # This fix func monkey patching by pillar + for name, func in self.servers.items(): + if '__opts__' in func.func_globals: + func.func_globals['__opts__'].update(self.opts) + def clear_cache(self, back=None): ''' Clear the cache of all of the fileserver backends that support the diff --git a/salt/master.py b/salt/master.py index c3fa5d99ed..815ed6eace 100644 --- a/salt/master.py +++ b/salt/master.py @@ -768,14 +768,14 @@ class AESFuncs(object): ''' Set the local file objects from the file server interface ''' - fs_ = salt.fileserver.Fileserver(self.opts) - self._serve_file = fs_.serve_file - self._file_hash = fs_.file_hash - self._file_list = fs_.file_list - self._file_list_emptydirs = fs_.file_list_emptydirs - self._dir_list = fs_.dir_list - self._symlink_list = fs_.symlink_list - self._file_envs = fs_.envs + self.fs_ = salt.fileserver.Fileserver(self.opts) + self._serve_file = self.fs_.serve_file + self._file_hash = self.fs_.file_hash + self._file_list = self.fs_.file_list + self._file_list_emptydirs = self.fs_.file_list_emptydirs + self._dir_list = self.fs_.dir_list + self._symlink_list = self.fs_.symlink_list + self._file_envs = self.fs_.envs def __verify_minion(self, id_, token): ''' @@ -1104,6 +1104,7 @@ class AESFuncs(object): load.get('ext'), self.mminion.functions) data = pillar.compile_pillar(pillar_dirs=pillar_dirs) + self.fs_.update_opts() if self.opts.get('minion_data_cache', False): cdir = os.path.join(self.opts['cachedir'], 'minions', load['id']) if not os.path.isdir(cdir):