Merge pull request #29578 from tbaker57/virtual_return_fixes

More detailed virtual returns for exec modules (ref Dec 2015 Salt Sprint)
This commit is contained in:
Justin Findlay 2015-12-10 09:08:57 -07:00
commit fb799ff77b
35 changed files with 41 additions and 40 deletions

View File

@ -77,7 +77,7 @@ def __virtual__():
'''
if HAS_KEYSTONE:
return 'keystone'
return False
return (False, 'keystone execution module cannot be loaded: keystoneclient python library not available.')
__opts__ = {}

View File

@ -25,7 +25,7 @@ def __virtual__():
'''
if __grains__['os'] == 'MacOS':
return __virtualname__
return False
return (False, 'launchctl execution module cannot be loaded: only available on MacOS.')
def _launchd_paths():

View File

@ -14,7 +14,7 @@ def __virtual__():
'''
if __grains__['os'] == 'Gentoo' and salt.utils.which('layman'):
return 'layman'
return False
return (False, 'layman execution module cannot be loaded: only available on Gentoo with layman installed.')
def _get_makeconf():

View File

@ -18,7 +18,7 @@ def __virtual__():
'''
if salt.utils.which('getfacl'):
return __virtualname__
return False
return (False, 'The linux_acl execution module cannot be loaded: the getfacl binary is not in the path.')
def version():

View File

@ -22,7 +22,7 @@ def __virtual__():
'''
if salt.utils.which('lvm'):
return __virtualname__
return False
return (False, 'The linux_lvm execution module cannot be loaded: the lvm binary is not in the path.')
def version():

View File

@ -31,7 +31,7 @@ def __virtual__():
Only run on Linux systems
'''
if __grains__['kernel'] != 'Linux':
return False
return (False, 'The linux_sysctl execution module cannot be loaded: only available on Linux systems.')
return __virtualname__

View File

@ -18,7 +18,7 @@ def __virtual__():
Only work on POSIX-like systems
'''
if salt.utils.is_windows():
return False
return (False, 'The locate execution module cannot be loaded: only available on non-Windows systems.')
return True

View File

@ -20,7 +20,7 @@ def __virtual__():
'''
if 'Solaris' in __grains__['os_family']:
return True
return False
return (False, 'The logadm execution module cannot be loaded: only available on Solaris.')
def _parse_conf(conf_file=default_conf):

View File

@ -26,7 +26,7 @@ def __virtual__():
Only work on POSIX-like systems
'''
if salt.utils.is_windows():
return False
return (False, 'The logrotate execution module cannot be loaded: only available on non-Windows systems.')
return True

View File

@ -28,7 +28,7 @@ def __virtual__():
Only load if ipvsadm command exists on the system.
'''
if not __detect_os():
return False
return (False, 'The lvs execution module cannot be loaded: the ipvsadm binary is not in the path.')
return 'lvs'

View File

@ -24,7 +24,7 @@ def __virtual__():
global _dscl, _flush_dscl_cache
if (__grains__.get('kernel') != 'Darwin' or
__grains__['osrelease_info'] < (10, 7)):
return False
return (False, 'The mac_group execution module cannot be loaded: only available on Darwin-based systems >= 10.7')
_dscl = salt.utils.namespaced_function(_dscl, globals())
_flush_dscl_cache = salt.utils.namespaced_function(
_flush_dscl_cache, globals()

View File

@ -58,7 +58,7 @@ def __virtual__():
if salt.utils.which('port') and __grains__['os'] == 'MacOS':
return __virtualname__
return False
return (False, 'The macports execution module cannot be loaded: only available on MacOS with the port binary in the path.')
def _list(query=''):

View File

@ -16,7 +16,7 @@ def __virtual__():
'''
if __grains__['os'] == 'Gentoo':
return 'makeconf'
return False
return (False, 'The makeconf execution module cannot be loaded: only available on Gentoo systems.')
def _get_makeconf():

View File

@ -31,9 +31,9 @@ def __virtual__():
mdadm provides raid functions for Linux
'''
if __grains__['kernel'] != 'Linux':
return False
return (False, 'The mdadm execution module cannot be loaded: only available on Linux.')
if not salt.utils.which('mdadm'):
return False
return (False, 'The mdadm execution module cannot be loaded: the mdadm binary is not in the path.')
return __virtualname__

View File

@ -41,7 +41,7 @@ def __virtual__():
if HAS_MONGODB:
return 'mongodb'
else:
return False
return (False, 'The mongodb execution module cannot be loaded: the pymongo library is not available.')
def _connect(user=None, password=None, host=None, port=None, database='admin'):

View File

@ -22,7 +22,7 @@ def __virtual__():
if salt.utils.which('monit') is not None:
# The monit binary exists, let the module load
return True
return False
return (False, 'The monit execution module cannot be loaded: the monit binary is not in the path.')
def start(name):

View File

@ -14,7 +14,7 @@ def __virtual__():
'''
if salt.utils.which('mfsgetgoal'):
return 'moosefs'
return False
return (False, 'The moosefs execution module cannot be loaded: the mfsgetgoal binary is not in the path.')
def dirinfo(path, opts=None):

View File

@ -48,7 +48,7 @@ def __virtual__():
'''
if HAS_ALL_IMPORTS:
return True
return False
return (False, 'The mssql execution module cannot be loaded: the pymssql python library is not available.')
def _get_connection(**kwargs):

View File

@ -21,7 +21,7 @@ def __virtual__():
'''
if os.path.exists('/etc/munin/munin-node.conf'):
return 'munin'
return False
return (False, 'The munin execution module cannot be loaded: munin-node is not installed.')
def _get_conf(fname='/etc/munin/munin-node.cfg'):

View File

@ -196,7 +196,7 @@ def __virtual__():
'''
if HAS_MYSQLDB:
return True
return False
return (False, 'The mysql execution module cannot be loaded: neither MySQLdb nor PyMySQL is available.')
def __check_table(name, table, **connection_args):

View File

@ -23,7 +23,7 @@ def __virtual__():
'''
if os.path.isdir(PLUGINDIR):
return 'nagios'
return False
return (False, 'The nagios execution module cannot be loaded: nagios-plugins are not installed.')
def _execute_cmd(plugin, args='', run_type='cmd.retcode'):

View File

@ -22,7 +22,7 @@ def __virtual__():
'''
if __grains__['os'] == 'NetBSD' and os.path.exists('/etc/rc.subr'):
return __virtualname__
return False
return (False, 'The netbsdservice execution module failed to load: only available on NetBSD.')
def start(name):

View File

@ -26,10 +26,10 @@ def __virtual__():
Only load this module if the nsnitro library is installed
'''
if salt.utils.is_windows():
return False
return (False, 'The netscaler execution module failed to load: not available on Windows.')
if HAS_NSNITRO:
return 'netscaler'
return False
return (False, 'The netscaler execution module failed to load: the nsnitro python library is not available.')
def _connect(**kwargs):

View File

@ -37,7 +37,7 @@ def __virtual__():
'''
# Disable on Windows, a specific file module exists:
if salt.utils.is_windows():
return False
return (False, 'The network execution module cannot be loaded on Windows: use win_network instead.')
return True

View File

@ -18,7 +18,7 @@ def __virtual__():
Only work on POSIX-like systems
'''
if not salt.utils.which('showmount'):
return False
return (False, 'The nfs3 execution module failed to load: the showmount binary is not in the path.')
return True

View File

@ -36,7 +36,7 @@ def __virtual__():
'''
if salt.utils.which('nft'):
return 'nftables'
return False
return (False, 'The nftables execution module failed to load: nftables is not installed.')
def _nftables_cmd():

View File

@ -28,7 +28,7 @@ def __virtual__():
'''
if __detect_os():
return True
return False
return (False, 'The nginx execution module cannot be loaded: nginx is not installed.')
def version():

View File

@ -70,7 +70,8 @@ def __virtual__():
'''
if all((salt.utils.which('psql'), HAS_CSV)):
return True
return False
return (False, 'The postgres execution module failed to load: '
'either the psql binary is not in the path or the csv library is not available')
def _run_psql(cmd, runas=None, password=None, host=None, port=None, user=None):

View File

@ -21,7 +21,7 @@ def __virtual__():
if __grains__['os'] == 'FreeBSD' and salt.utils.which('poudriere'):
return 'poudriere'
else:
return False
return (False, 'The poudriere execution module failed to load: only available on FreeBSD with the poudriere binary in the path.')
def _config_file():

View File

@ -40,15 +40,15 @@ def __virtual__():
try:
kernel_grain = __grains__['kernel']
except Exception:
return False
return (False, 'The powerpath execution module cannot be loaded: unable to detect kernel grain.')
if not has_powerpath():
return False
return (False, 'The powerpath execution module cannot be loaded: the emcpreg binary is not available.')
if kernel_grain == 'Linux':
return 'powerpath'
return False
return (False, 'The powerpath execution module cannot be loaded: only available on Linux.')
def list_licenses():

View File

@ -22,7 +22,7 @@ def __virtual__():
'''
if salt.utils.which('qemu-img'):
return 'qemu_img'
return False
return (False, 'The qemu_img execution module cannot be loaded: the qemu-img binary is not in the path.')
def make_image(location, size, fmt):

View File

@ -31,7 +31,7 @@ def __virtual__():
'''
if salt.utils.which('qemu-nbd'):
return 'qemu_nbd'
return False
return (False, 'The qemu_nbd execution module cannot be loaded: the qemu-nbd binary is not in the path.')
def connect(image):

View File

@ -30,9 +30,9 @@ def __virtual__():
Only load the module if apache is installed
'''
if not __opts__.get('rallydev', {}).get('username', None):
return False
return (False, 'The rallydev execution module failed to load: rallydev:username not defined in config.')
if not __opts__.get('rallydev', {}).get('password', None):
return False
return (False, 'The rallydev execution module failed to load: rallydev:password not defined in config.')
return True

View File

@ -41,7 +41,7 @@ def __virtual__():
Only work on POSIX-like systems
'''
if salt.utils.is_windows():
return False
return (False, 'The rbenv execution module failed to load: only available on non-Windows systems.')
return True

View File

@ -36,7 +36,7 @@ def __virtual__():
if HAS_REDIS:
return __virtualname__
else:
return False
return (False, 'The redis execution module failed to load: the redis python library is not available.')
def _connect(host=None, port=None, db=None, password=None):