Fix fileserver backends __opts__ overwritten by _pillar

This commit is contained in:
Étienne BERSAC 2015-04-22 15:16:20 +02:00
parent 2e09789156
commit 5f451f63cf
2 changed files with 15 additions and 8 deletions

View File

@ -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

View File

@ -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):