003 File Manager
Current Path:
/usr/local/lib/python3.8/site-packages/salt/returners
usr
/
local
/
lib
/
python3.8
/
site-packages
/
salt
/
returners
/
📁
..
📄
__init__.py
(5.98 KB)
📁
__pycache__
📄
appoptics_return.py
(6.11 KB)
📄
carbon_return.py
(8.24 KB)
📄
cassandra_cql_return.py
(15.17 KB)
📄
cassandra_return.py
(2.07 KB)
📄
couchbase_return.py
(8.91 KB)
📄
couchdb_return.py
(10.35 KB)
📄
django_return.py
(2.27 KB)
📄
elasticsearch_return.py
(12.18 KB)
📄
etcd_return.py
(6.32 KB)
📄
highstate_return.py
(15.59 KB)
📄
influxdb_return.py
(8.03 KB)
📄
kafka_return.py
(2.12 KB)
📄
librato_return.py
(4.29 KB)
📄
local.py
(541 B)
📄
local_cache.py
(17.1 KB)
📄
mattermost_returner.py
(4.08 KB)
📄
memcache_return.py
(5.72 KB)
📄
mongo_future_return.py
(10.08 KB)
📄
mongo_return.py
(6.11 KB)
📄
multi_returner.py
(2.82 KB)
📄
mysql.py
(18.61 KB)
📄
nagios_nrdp_return.py
(4.92 KB)
📄
odbc.py
(7.77 KB)
📄
pgjsonb.py
(17.18 KB)
📄
postgres.py
(10.2 KB)
📄
postgres_local_cache.py
(10.73 KB)
📄
pushover_returner.py
(6.55 KB)
📄
rawfile_json.py
(2.23 KB)
📄
redis_return.py
(8.52 KB)
📄
sentry_return.py
(5.3 KB)
📄
slack_returner.py
(6.02 KB)
📄
slack_webhook_return.py
(11.22 KB)
📄
sms_return.py
(2.64 KB)
📄
smtp_return.py
(8.2 KB)
📄
splunk.py
(6.69 KB)
📄
sqlite3_return.py
(7.73 KB)
📄
syslog_return.py
(5.26 KB)
📄
telegram_return.py
(1.92 KB)
📄
xmpp_return.py
(4.85 KB)
📄
zabbix_return.py
(2.45 KB)
Editing: sms_return.py
""" Return data by SMS. .. versionadded:: 2015.5.0 :maintainer: Damian Myerscough :maturity: new :depends: twilio :platform: all To enable this returner the minion will need the python twilio library installed and the following values configured in the minion or master config: .. code-block:: yaml twilio.sid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' twilio.token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' twilio.to: '+1415XXXXXXX' twilio.from: '+1650XXXXXXX' To use the sms returner, append '--return sms' to the salt command. .. code-block:: bash salt '*' test.ping --return sms """ import logging import salt.returners log = logging.getLogger(__name__) try: import twilio # Grab version, ensure elements are ints twilio_version = tuple([int(x) for x in twilio.__version_info__]) if twilio_version > (5,): TWILIO_5 = False from twilio.rest import Client as TwilioRestClient from twilio.rest import TwilioException as TwilioRestException else: TWILIO_5 = True from twilio.rest import TwilioRestClient from twilio import TwilioRestException # pylint: disable=no-name-in-module HAS_TWILIO = True except ImportError: HAS_TWILIO = False __virtualname__ = "sms" def __virtual__(): if HAS_TWILIO: return __virtualname__ return False, "Could not import sms returner; twilio is not installed." def _get_options(ret=None): """ Get the Twilio options from salt. """ attrs = {"sid": "sid", "token": "token", "to": "to", "from": "from"} _options = salt.returners.get_returner_options( __virtualname__, ret, attrs, __salt__=__salt__, __opts__=__opts__ ) return _options def returner(ret): """ Return a response in an SMS message """ _options = _get_options(ret) sid = _options.get("sid", None) token = _options.get("token", None) sender = _options.get("from", None) receiver = _options.get("to", None) if sid is None or token is None: log.error("Twilio sid/authentication token missing") return None if sender is None or receiver is None: log.error("Twilio to/from fields are missing") return None client = TwilioRestClient(sid, token) try: message = client.messages.create( body="Minion: {}\nCmd: {}\nSuccess: {}\n\nJid: {}".format( ret["id"], ret["fun"], ret["success"], ret["jid"] ), to=receiver, from_=sender, ) except TwilioRestException as e: log.error("Twilio [https://www.twilio.com/docs/errors/%s]", e.code) return False return True
Upload File
Create Folder