mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #37519 from rallytime/returner-load-errors
Update returner __virtual__() return messages for loader
This commit is contained in:
commit
19475aada6
23 changed files with 42 additions and 30 deletions
|
@ -175,7 +175,8 @@ __virtualname__ = 'cassandra_cql'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_CASSANDRA_DRIVER:
|
||||
return False
|
||||
return False, 'Could not import cassandra_cql returner; ' \
|
||||
'cassandra-driver is not installed.'
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ __virtualname__ = 'cassandra'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_PYCASSA:
|
||||
return False
|
||||
return False, 'Could not import cassandra returner; pycassa is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ VERIFIED_VIEWS = False
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_DEPS:
|
||||
return False
|
||||
return False, 'Could not import couchbase returner; couchbase is not installed.'
|
||||
|
||||
# try to load some faster json libraries. In order of fastest to slowest
|
||||
json = salt.utils.import_json()
|
||||
|
|
|
@ -50,7 +50,7 @@ __virtualname__ = 'django'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_DJANGO:
|
||||
return False
|
||||
return False, 'Could not import django returner; django is not installed.'
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def __virtual__():
|
||||
return __virtualname__
|
||||
return 'elasticsearch.alias_exists' in __salt__
|
||||
|
||||
|
||||
def returner(ret):
|
||||
|
|
|
@ -90,7 +90,10 @@ def __virtual__():
|
|||
'''
|
||||
Only return if python-etcd is installed
|
||||
'''
|
||||
return __virtualname__ if HAS_LIBS else False
|
||||
if HAS_LIBS:
|
||||
return __virtualname__
|
||||
|
||||
return False, 'Could not import etcd returner; python-etcd is not installed.'
|
||||
|
||||
|
||||
def _get_conn(opts, profile=None):
|
||||
|
|
|
@ -75,7 +75,8 @@ __virtualname__ = 'influxdb'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_INFLUXDB:
|
||||
return False
|
||||
return False, 'Could not import influxdb returner; ' \
|
||||
'influxdb python client is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -24,28 +24,26 @@ To use the kafka returner, append '--return kafka' to the Salt command, eg;
|
|||
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
import json
|
||||
import logging
|
||||
|
||||
|
||||
# Import third-party libs
|
||||
try:
|
||||
from kafka import KafkaClient, SimpleProducer
|
||||
HAS_KAFKA = True
|
||||
except ImportError:
|
||||
HAS_KAFKA = False
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
__virtualname__ = 'kafka'
|
||||
|
||||
|
||||
def __virtual__():
|
||||
if not HAS_KAFKA:
|
||||
return False
|
||||
return False, 'Could not import kafka returner; kafka-python is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -70,7 +70,8 @@ __virtualname__ = 'memcache'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_MEMCACHE:
|
||||
return False
|
||||
return False, 'Could not import memcache returner; ' \
|
||||
'memcache python client is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ import salt.utils.jid
|
|||
import salt.returners
|
||||
import salt.ext.six as six
|
||||
|
||||
|
||||
# Import third party libs
|
||||
try:
|
||||
import pymongo
|
||||
|
@ -91,7 +90,7 @@ __virtualname__ = 'mongo'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_PYMONGO:
|
||||
return False
|
||||
return False, 'Could not import mongo returner; pymongo is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ __virtualname__ = 'mongo'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_PYMONGO:
|
||||
return False
|
||||
return False, 'Could not import mongo returner; pymongo is not installed.'
|
||||
return 'mongo_return'
|
||||
|
||||
|
||||
|
|
|
@ -154,7 +154,8 @@ __virtualname__ = 'mysql'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_MYSQL:
|
||||
return False
|
||||
return False, 'Could not import mysql returner; ' \
|
||||
'mysql python client is not installed.'
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ def __virtual__():
|
|||
'''
|
||||
Return virtualname
|
||||
'''
|
||||
return __virtualname__
|
||||
return 'nagios.list_plugins' in __salt__
|
||||
|
||||
|
||||
def returner(ret):
|
||||
|
|
|
@ -149,7 +149,7 @@ __virtualname__ = 'odbc'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_ODBC:
|
||||
return False
|
||||
return False, 'Could not import odbc returner; pyodbc is not installed.'
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ __virtualname__ = 'pgjsonb'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_PG:
|
||||
return False
|
||||
return False, 'Could not import pgjsonb returner; python-psycopg2 is not installed.'
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ __virtualname__ = 'postgres'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_POSTGRES:
|
||||
return False
|
||||
return False, 'Could not import postgres returner; psycopg2 is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -67,7 +67,8 @@ __virtualname__ = 'redis'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_REDIS:
|
||||
return False
|
||||
return False, 'Could not import redis returner; ' \
|
||||
'redis python client is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ __virtualname__ = 'sentry'
|
|||
|
||||
def __virtual__():
|
||||
if not has_raven:
|
||||
return False
|
||||
return False, 'Could not import sentry returner; ' \
|
||||
'raven python client is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ __virtualname__ = 'sms'
|
|||
def __virtual__():
|
||||
if HAS_TWILIO:
|
||||
return __virtualname__
|
||||
else:
|
||||
return False
|
||||
|
||||
return False, 'Could not import sms returner; twilio is not installed.'
|
||||
|
||||
|
||||
def _get_options(ret=None):
|
||||
|
|
|
@ -102,7 +102,9 @@ __virtualname__ = 'smtp'
|
|||
|
||||
|
||||
def __virtual__():
|
||||
return __virtualname__
|
||||
if HAS_GNUPG:
|
||||
return __virtualname__
|
||||
return False, 'Could not import smtp returner; gnupg is not installed.'
|
||||
|
||||
|
||||
def _get_options(ret=None):
|
||||
|
|
|
@ -106,7 +106,7 @@ __virtualname__ = 'sqlite3'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_SQLITE3:
|
||||
return False
|
||||
return False, 'Could not import sqlite3 returner; sqlite3 is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ __virtualname__ = 'syslog'
|
|||
|
||||
def __virtual__():
|
||||
if not HAS_SYSLOG:
|
||||
return False
|
||||
return False, 'Could not import syslog returner; syslog is not installed.'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
'''
|
||||
Return salt data via xmpp
|
||||
|
||||
:depends: sleekxmpp >= 1.3.1
|
||||
|
||||
The following fields can be set in the minion conf file::
|
||||
|
||||
xmpp.jid (required)
|
||||
|
@ -117,14 +119,16 @@ def __virtual__():
|
|||
'''
|
||||
Only load this module if right version of sleekxmpp is installed on this minion.
|
||||
'''
|
||||
min_version = '1.3.1'
|
||||
if HAS_LIBS:
|
||||
import sleekxmpp
|
||||
# Certain XMPP functionaility we're using doesn't work with versions under 1.3.1
|
||||
sleekxmpp_version = distutils.version.LooseVersion(sleekxmpp.__version__)
|
||||
valid_version = distutils.version.LooseVersion('1.3.1')
|
||||
valid_version = distutils.version.LooseVersion(min_version)
|
||||
if sleekxmpp_version >= valid_version:
|
||||
return __virtualname__
|
||||
return False
|
||||
return False, 'Could not import xmpp returner; sleekxmpp python client is not ' \
|
||||
'installed or is older than version \'{0}\'.'.format(min_version)
|
||||
|
||||
|
||||
class SendMsgBot(_ClientXMPP):
|
||||
|
|
Loading…
Add table
Reference in a new issue