Add a backend argument for salt.runners.fileserver.{file,symlink}_list

This allows for backends to be excluded when executing these runners.
This commit is contained in:
Erik Johnson 2015-02-22 16:44:02 -06:00 committed by C. R. Oldham
parent 5ae5c0bb07
commit 1c55cf92e1

View File

@ -34,6 +34,20 @@ def envs(backend=None, sources=False, outputter='nested'):
Return the available fileserver environments. If no backend is provided,
then the environments for all configured backends will be returned.
backend
Narrow fileserver backends to a subset of the enabled ones.
.. versionchanged:: 2015.2.0::
If all passed backends start with a minus sign (``-``), then these
backends will be excluded from the enabled backends. However, if
there is a mix of backends with and without a minus sign (ex:
``backend=-roots,git``) then the ones starting with a minus
sign will be disregarded.
Additionally, fileserver backends can now be passed as a
comma-separated list. In earlier versions, they needed to be passed
as a python list (ex: ``backend="['roots', 'git']"``)
CLI Example:
.. code-block:: bash
@ -41,6 +55,7 @@ def envs(backend=None, sources=False, outputter='nested'):
salt-run fileserver.envs
salt-run fileserver.envs outputter=nested
salt-run fileserver.envs backend=roots,git
salt-run fileserver.envs git
'''
fileserver = salt.fileserver.Fileserver(__opts__)
output = fileserver.envs(back=backend, sources=sources)
@ -51,19 +66,35 @@ def envs(backend=None, sources=False, outputter='nested'):
return output
def file_list(saltenv='base', outputter='nested'):
def file_list(saltenv='base', backend=None, outputter='nested'):
'''
Return a list of files from the dominant environment
Return a list of files from the salt fileserver
CLI Example:
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``), then these backends
will be excluded from the enabled backends. However, if there is a mix
of backends with and without a minus sign (ex:
``backend=-roots,git``) then the ones starting with a minus sign will
be disregarded.
.. versionadded:: 2015.2.0
CLI Examples:
.. code-block:: bash
salt-run fileserver.file_list
salt-run fileserver.file_list saltenv=prod
salt-run fileserver.file_list saltenv=dev backend=git
salt-run fileserver.file_list base hg,roots
salt-run fileserver.file_list -git
'''
fileserver = salt.fileserver.Fileserver(__opts__)
load = {'saltenv': saltenv}
load = {'saltenv': saltenv, 'fsbackend': backend}
output = fileserver.file_list(load=load)
if outputter:
@ -72,19 +103,35 @@ def file_list(saltenv='base', outputter='nested'):
return output
def symlink_list(saltenv='base', outputter='nested'):
def symlink_list(saltenv='base', backend=None, outputter='nested'):
'''
Return a list of symlinked files and dirs
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``), then these backends
will be excluded from the enabled backends. However, if there is a mix
of backends with and without a minus sign (ex:
``backend=-roots,git``) then the ones starting with a minus sign will
be disregarded.
.. versionadded:: 2015.2.0
CLI Example:
.. code-block:: bash
salt-run fileserver.symlink_list
salt-run fileserver.symlink_list saltenv=prod
salt-run fileserver.symlink_list saltenv=dev backend=git
salt-run fileserver.symlink_list base hg,roots
salt-run fileserver.symlink_list -git
'''
fileserver = salt.fileserver.Fileserver(__opts__)
load = {'saltenv': saltenv}
load = {'saltenv': saltenv, 'fsbackend': backend}
output = fileserver.symlink_list(load=load)
if outputter:
@ -98,6 +145,20 @@ def update(backend=None):
Update the fileserver cache. If no backend is provided, then the cache for
all configured backends will be updated.
backend
Narrow fileserver backends to a subset of the enabled ones.
.. versionchanged:: 2015.2.0
If all passed backends start with a minus sign (``-``), then these
backends will be excluded from the enabled backends. However, if
there is a mix of backends with and without a minus sign (ex:
``backend=-roots,git``) then the ones starting with a minus
sign will be disregarded.
Additionally, fileserver backends can now be passed as a
comma-separated list. In earlier versions, they needed to be passed
as a python list (ex: ``backend="['roots', 'git']"``)
CLI Example:
.. code-block:: bash
@ -107,7 +168,6 @@ def update(backend=None):
'''
fileserver = salt.fileserver.Fileserver(__opts__)
fileserver.update(back=backend)
return True
@ -122,7 +182,11 @@ def clear_cache(backend=None):
can be narrowed using the ``backend`` argument.
backend
Only clear the update lock for the specified backend(s).
Only clear the update lock for the specified backend(s). If all passed
backends start with a minus sign (``-``), then these backends will be
excluded from the enabled backends. However, if there is a mix of
backends with and without a minus sign (ex: ``backend=-roots,git``)
then the ones starting with a minus sign will be disregarded.
CLI Example:
@ -130,7 +194,8 @@ def clear_cache(backend=None):
salt-run fileserver.update
salt-run fileserver.update backend=git,hg
salt-run fileserver.update backend=hg
salt-run fileserver.update hg
salt-run fileserver.update -roots
'''
fileserver = salt.fileserver.Fileserver(__opts__)
cleared, errors = fileserver.clear_cache(back=backend)
@ -183,3 +248,4 @@ def clear_lock(backend=None, remote=None):
if not ret:
ret = 'No locks were removed'
salt.output.display_output(ret, 'nested', opts=__opts__)