Merge pull request #49389 from gtmanfred/2017.7

make file envs compatible with fileclient formats
This commit is contained in:
Daniel Wallace 2018-08-29 18:49:23 -05:00 committed by GitHub
commit 7099164fa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 1 deletions

View file

@ -490,6 +490,15 @@ class Fileserver(object):
return ret
return list(ret)
def file_envs(self, load=None):
'''
Return environments for all backends for requests from fileclient
'''
if load is None:
load = {}
load.pop('cmd', None)
return self.envs(**load)
def init(self, back=None):
'''
Initialize the backend, only do so if the fs supports an init function

View file

@ -963,7 +963,7 @@ class AESFuncs(object):
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
self._file_envs = self.fs_.file_envs
def __verify_minion(self, id_, token):
'''

View file

@ -296,6 +296,19 @@ def get_file(path,
gzip)
def envs():
'''
List available environments for fileserver
CLI Example
.. code-block:: bash
salt '*' cp.envs
'''
return _client().envs()
def get_template(path,
dest,
template='jinja',

View file

@ -614,3 +614,6 @@ class CPModuleTest(ModuleCase):
self.assertTrue(os.path.isfile(tgt_cache_file), 'File was not cached on the master')
finally:
os.unlink(tgt_cache_file)
def test_envs(self):
self.assertEqual(self.run_function('cp.envs'), ['base', 'prod'])