mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Fix removed else clause. Tom saw no reason to have it
<<<<<<< HEAD ======= else: self.fire_event(load, load['fun']) # old dup event self.fire_event(load, tagify([load['jid'], 'sub', load['id'], 'ret', load['fun']], 'job')) >>>>>>> upstream/develop Merge remote-tracking branch 'upstream/develop' into develop Conflicts: salt/utils/event.py
This commit is contained in:
commit
eee4077344
@ -7,14 +7,26 @@ Dependency Installation
|
||||
|
||||
ZeroMQ and swig need to be installed first.
|
||||
|
||||
Using homebrew:
|
||||
For installs using `python installed via homebrew`_, sudo should be unnecessary:
|
||||
|
||||
.. _`python installed via homebrew`: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
|
||||
|
||||
Using homebrew with
|
||||
`XCode Command Line Tool (XCode: Preferences: Downloads: Command Line Tools: Install)`_ pre-installed:
|
||||
|
||||
.. _`XCode Command Line Tool (XCode: Preferences: Downloads: Command Line Tools: Install)`: https://developer.apple.com/xcode/
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
brew install python
|
||||
brew install swig
|
||||
brew install zmq
|
||||
pip install salt
|
||||
|
||||
Using macports, zmq, swig, and pip may need to be installed this way:
|
||||
This should pip install salt and its dependencies, such as:
|
||||
Jinja2 M2Crypto msgpack-python pycrypto PyYAML pyzmq markupsafe
|
||||
|
||||
Whereas when using macports, zmq, swig, and pip may need to be installed this way:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
@ -25,40 +37,32 @@ Using macports, zmq, swig, and pip may need to be installed this way:
|
||||
sudo port install swig-python
|
||||
sudo port install py-pip
|
||||
|
||||
For installs using the OSX system python, pip install needs to use 'sudo':
|
||||
For installs using the OS X system python, pip install needs to use 'sudo':
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo pip install salt
|
||||
|
||||
For installs using `python installed via homebrew`_, sudo should be unnecessary:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install salt
|
||||
|
||||
.. _`python installed via homebrew`: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
|
||||
|
||||
Salt-Master Customizations
|
||||
--------------------------
|
||||
|
||||
To run salt-master on OSX, the root user maxfiles limit must be increased:
|
||||
To run salt-master on OS X, the root user maxfiles limit must be increased:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo launchctl limit maxfiles 10000
|
||||
sudo launchctl limit maxfiles 4096 8192
|
||||
|
||||
And add this configuration option to the /etc/salt/master file:
|
||||
And sudo add this configuration option to the /etc/salt/master file:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
max_open_files: 10000
|
||||
max_open_files: 8192
|
||||
|
||||
Now the salt-master should run without errors:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo salt-master --log-level=all
|
||||
sudo /usr/local/share/python/salt-master --log-level=all
|
||||
|
||||
Post-installation tasks
|
||||
=======================
|
||||
|
@ -132,7 +132,7 @@ With correctly setup grains on the Minion, the Top file used in Pillar or during
|
||||
- match: grain
|
||||
- lb
|
||||
|
||||
For this example to work, you would need the grain ``node_type`` and the correct value to match on. This simple example is nice, but too much of the code is similar. To go one step further, we can place in some JINJA into the Top file.
|
||||
For this example to work, you would need the grain ``node_type`` and the correct value to match on. This simple example is nice, but too much of the code is similar. To go one step further, we can place some Jinja template code into the Top file.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
@ -142,7 +142,7 @@ For this example to work, you would need the grain ``node_type`` and the correct
|
||||
- match: grain
|
||||
- {{ self }}
|
||||
|
||||
With the JINJA, we simplified the Top file, and allowed SaltStack to work it's magic.
|
||||
The Jinja code simplified the Top file, and allowed SaltStack to work its magic.
|
||||
|
||||
.. _writing-grains:
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
Using cron with Salt
|
||||
===============================================
|
||||
|
||||
The Salt Minion can initiate its own highstate using the `salt-call` command.
|
||||
The Salt Minion can initiate its own highstate using the ``salt-call`` command.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
@ -17,7 +17,7 @@ Use cron to initiate a highstate
|
||||
================================
|
||||
|
||||
If you would like the Salt Minion to regularly check in with the master you can
|
||||
use the venerable cron to run the `salt-call` command.
|
||||
use the venerable cron to run the ``salt-call`` command.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
|
@ -9,8 +9,8 @@ rules for allowing these incoming connections to the master.
|
||||
|
||||
.. note::
|
||||
|
||||
**No firewall configuration needs to be done on Salt minions. These changes
|
||||
refer to the master only.**
|
||||
No firewall configuration needs to be done on Salt minions. These changes
|
||||
refer to the master only.
|
||||
|
||||
RHEL 6 / CENTOS 6
|
||||
=================
|
||||
|
@ -172,4 +172,4 @@ for the user running the salt-master.
|
||||
|
||||
.. note::
|
||||
|
||||
GitFS requires library ``gitpython`` > 0.3.0.
|
||||
GitFS requires the Python module ``GitPython``, version 0.3.0 or newer.
|
||||
|
@ -1002,7 +1002,7 @@ class AESFuncs(object):
|
||||
self.event.fire_event(event, tagify(event['tag'], base=load['pretag']))
|
||||
else:
|
||||
tag = load['tag']
|
||||
self.event.fire_event(load, tag)
|
||||
self.event.fire_event(load, tag)
|
||||
return True
|
||||
|
||||
def _return(self, load):
|
||||
|
@ -1035,7 +1035,7 @@ class Minion(object):
|
||||
),
|
||||
tagify([self.opts['id'], 'start'], 'minion'),
|
||||
)
|
||||
|
||||
|
||||
# Make sure to gracefully handle SIGUSR1
|
||||
enable_sigusr1_handler()
|
||||
|
||||
@ -1139,7 +1139,7 @@ class Minion(object):
|
||||
time.asctime()
|
||||
),
|
||||
tagify([self.opts['id'], 'start'], 'minion'),
|
||||
)
|
||||
)
|
||||
loop_interval = int(self.opts['loop_interval'])
|
||||
while True:
|
||||
try:
|
||||
@ -1306,7 +1306,7 @@ class Syndic(Minion):
|
||||
time.asctime()
|
||||
),
|
||||
tagify([self.opts['id'], 'start'], 'syndic'),
|
||||
)
|
||||
)
|
||||
|
||||
# Make sure to gracefully handle SIGUSR1
|
||||
enable_sigusr1_handler()
|
||||
|
@ -138,6 +138,8 @@ def install(pkgs=None,
|
||||
(/home/code/path/to/virtualenv/)
|
||||
env
|
||||
deprecated, use bin_env now
|
||||
use_wheel
|
||||
Prefer wheel archives (requires pip>=1.4)
|
||||
log
|
||||
Log file where a complete (maximum verbosity) record will be kept
|
||||
proxy
|
||||
|
@ -13,6 +13,7 @@ import os
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Only load if qemu-img is installed
|
||||
@ -27,7 +28,9 @@ def make_image(location, size, fmt):
|
||||
Create a blank virtual machine image file of the specified size in
|
||||
megabytes. The image can be created in any format supported by qemu
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' qemu_img.make_image /tmp/image.qcow 2048 qcow2
|
||||
salt '*' qemu_img.make_image /tmp/image.raw 10240 raw
|
||||
|
@ -38,7 +38,9 @@ def connect(image):
|
||||
'''
|
||||
Activate nbd for an image file.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' qemu_nbd.connect /tmp/image.raw
|
||||
'''
|
||||
@ -72,7 +74,9 @@ def mount(nbd):
|
||||
Pass in the nbd connection device location, mount all partitions and return
|
||||
a dict of mount points
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' qemu_nbd.mount /dev/nbd0
|
||||
'''
|
||||
@ -98,7 +102,9 @@ def init(image):
|
||||
'''
|
||||
Mount the named image via qemu-nbd and return the mounted roots
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' qemu_nbd.init /srv/image.qcow2
|
||||
'''
|
||||
@ -115,9 +121,11 @@ def clear(mnt):
|
||||
empty dict, otherwise return a dict containing the still mounted
|
||||
partitions
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
salt '*' qemu_nbd.clear '{/mnt/foo: /dev/nbd0p1}'
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' qemu_nbd.clear '{"/mnt/foo": "/dev/nbd0p1"}'
|
||||
'''
|
||||
if isinstance(mnt, str):
|
||||
mnt = yaml.load(mnt)
|
||||
|
@ -30,7 +30,9 @@ def report(mount):
|
||||
'''
|
||||
Report on quotas for a specific volume
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' quota.report /media/data
|
||||
'''
|
||||
@ -89,7 +91,9 @@ def set_(device, **kwargs):
|
||||
'''
|
||||
Calls out to setquota, for a specific user or group
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' quota.set /media/data user=larry block-soft-limit=1048576
|
||||
salt '*' quota.set /media/data group=painters file-hard-limit=1000
|
||||
@ -143,7 +147,9 @@ def warn():
|
||||
Runs the warnquota command, to send warning emails to users who
|
||||
are over their quota limit.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' quota.warn
|
||||
'''
|
||||
@ -154,7 +160,9 @@ def stats():
|
||||
'''
|
||||
Runs the quotastats command, and returns the parsed output
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' quota.stats
|
||||
'''
|
||||
@ -173,7 +181,9 @@ def on(device):
|
||||
'''
|
||||
Turns on the quota system
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' quota.on
|
||||
'''
|
||||
@ -186,7 +196,9 @@ def off(device):
|
||||
'''
|
||||
Turns off the quota system
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' quota.off
|
||||
'''
|
||||
@ -199,7 +211,9 @@ def get_mode(device):
|
||||
'''
|
||||
Report whether the quota system for this device is on or off
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' quota.get_mode
|
||||
'''
|
||||
|
@ -37,7 +37,9 @@ def list_users(runas=None):
|
||||
'''
|
||||
Return a list of users based off of rabbitmqctl user_list.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.list_users
|
||||
'''
|
||||
@ -58,7 +60,9 @@ def list_vhosts(runas=None):
|
||||
'''
|
||||
Return a list of vhost based on rabbitmqctl list_vhosts.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.list_vhosts
|
||||
'''
|
||||
@ -73,7 +77,9 @@ def user_exists(name, runas=None):
|
||||
'''
|
||||
Return whether the user exists based on rabbitmqctl list_users.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.user_exists rabbit_user
|
||||
'''
|
||||
@ -87,7 +93,9 @@ def vhost_exists(name, runas=None):
|
||||
'''
|
||||
Return whether the vhost exists based on rabbitmqctl list_vhosts.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.vhost_exists rabbit_host
|
||||
'''
|
||||
@ -98,7 +106,9 @@ def add_user(name, password, runas=None):
|
||||
'''
|
||||
Add a rabbitMQ user via rabbitmqctl user_add <user> <password>
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.add_user rabbit_user password
|
||||
'''
|
||||
@ -114,7 +124,9 @@ def delete_user(name, runas=None):
|
||||
'''
|
||||
Deletes a user via rabbitmqctl delete_user.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.delete_user rabbit_user
|
||||
'''
|
||||
@ -129,7 +141,9 @@ def change_password(name, password, runas=None):
|
||||
'''
|
||||
Changes a user's password.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.change_password rabbit_user password
|
||||
'''
|
||||
@ -145,7 +159,9 @@ def clear_password(name, runas=None):
|
||||
'''
|
||||
Removes a user's password.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.clear_password rabbit_user
|
||||
'''
|
||||
@ -160,7 +176,9 @@ def add_vhost(vhost, runas=None):
|
||||
'''
|
||||
Adds a vhost via rabbitmqctl add_vhost.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq add_vhost '<vhost_name>'
|
||||
'''
|
||||
@ -175,7 +193,9 @@ def delete_vhost(vhost, runas=None):
|
||||
'''
|
||||
Deletes a vhost rabbitmqctl delete_vhost.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.delete_vhost '<vhost_name>'
|
||||
'''
|
||||
@ -190,7 +210,9 @@ def set_permissions(vhost, user, conf='.*', write='.*', read='.*',
|
||||
'''
|
||||
Sets permissions for vhost via rabbitmqctl set_permissions
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.set_permissions 'myvhost' 'myuser'
|
||||
'''
|
||||
@ -206,7 +228,9 @@ def list_user_permissions(name, user=None):
|
||||
'''
|
||||
List permissions for a user via rabbitmqctl list_user_permissions
|
||||
|
||||
Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.list_user_permissions 'user'.
|
||||
'''
|
||||
@ -220,7 +244,9 @@ def status(user=None):
|
||||
'''
|
||||
return rabbitmq status
|
||||
|
||||
Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.status
|
||||
'''
|
||||
@ -235,7 +261,9 @@ def cluster_status(user=None):
|
||||
'''
|
||||
return rabbitmq cluster_status
|
||||
|
||||
Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.cluster_status
|
||||
'''
|
||||
@ -251,7 +279,9 @@ def stop_app(runas=None):
|
||||
'''
|
||||
Stops the RabbitMQ application, leaving the Erlang node running.
|
||||
|
||||
Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.stop_app
|
||||
'''
|
||||
@ -266,7 +296,9 @@ def start_app(runas=None):
|
||||
'''
|
||||
Start the RabbitMQ application.
|
||||
|
||||
Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.start_app
|
||||
'''
|
||||
@ -281,7 +313,9 @@ def reset(runas=None):
|
||||
'''
|
||||
Return a RabbitMQ node to its virgin state
|
||||
|
||||
Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.reset
|
||||
'''
|
||||
@ -296,7 +330,9 @@ def force_reset(runas=None):
|
||||
'''
|
||||
Forcefully Return a RabbitMQ node to its virgin state
|
||||
|
||||
Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.force_reset
|
||||
'''
|
||||
@ -306,11 +342,14 @@ def force_reset(runas=None):
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def list_queues(*kwargs):
|
||||
'''
|
||||
Returns queue details of the / virtual host
|
||||
|
||||
Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.list_queues messages consumers
|
||||
'''
|
||||
@ -318,14 +357,17 @@ def list_queues(*kwargs):
|
||||
'rabbitmqctl list_queues {0}'.format(' '.join(list(kwargs))))
|
||||
return res
|
||||
|
||||
|
||||
def list_queues_vhost(vhost, *kwargs):
|
||||
'''
|
||||
Returns queue details of specified virtual host.
|
||||
This command will consider first parameter as the vhost name and rest will be treated as queueinfoitem.
|
||||
Also rabbitmqctl's -p parameter will be passed by salt, it should not be provided by salt command
|
||||
For getting details on vhost '/', use list_queues instead).
|
||||
Returns queue details of specified virtual host. This command will consider
|
||||
first parameter as the vhost name and rest will be treated as
|
||||
queueinfoitem. For getting details on vhost ``/``, use :mod:`list_queues
|
||||
<salt.modules.rabbitmq.list_queues>` instead).
|
||||
|
||||
Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rabbitmq.list_queues messages consumers
|
||||
'''
|
||||
|
@ -102,7 +102,9 @@ def install(runas=None, path=None):
|
||||
'''
|
||||
Install Rbenv systemwide
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rbenv.install
|
||||
'''
|
||||
@ -116,7 +118,9 @@ def update(runas=None, path=None):
|
||||
'''
|
||||
Updates the current versions of Rbenv and Ruby-Build
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rbenv.update
|
||||
'''
|
||||
@ -131,7 +135,9 @@ def is_installed(runas=None):
|
||||
'''
|
||||
Check if Rbenv is installed.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rbenv.is_installed
|
||||
'''
|
||||
@ -146,7 +152,9 @@ def install_ruby(ruby, runas=None):
|
||||
The version of Ruby to install, should match one of the
|
||||
versions listed by rbenv.list
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rbenv.install_ruby 2.0.0-p0
|
||||
'''
|
||||
@ -172,10 +180,12 @@ def uninstall_ruby(ruby, runas=None):
|
||||
Uninstall a ruby implementation.
|
||||
|
||||
ruby
|
||||
The version of ruby to uninstall. Should match one of
|
||||
the versions listed by rbenv.versions
|
||||
The version of ruby to uninstall. Should match one of the versions
|
||||
listed by :mod:`rbenv.versions <salt.modules.rbenv.versions>`
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rbenv.uninstall_ruby 2.0.0-p0
|
||||
'''
|
||||
@ -191,7 +201,9 @@ def versions(runas=None):
|
||||
'''
|
||||
List the installed versions of ruby.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rbenv.versions
|
||||
'''
|
||||
@ -205,15 +217,15 @@ def default(ruby=None, runas=None):
|
||||
Returns or sets the currently defined default ruby.
|
||||
|
||||
ruby=None
|
||||
The version to set as the default. Should match one of
|
||||
the versions listed by rbenv.versions.
|
||||
Leave blank to return the current default.
|
||||
The version to set as the default. Should match one of the versions
|
||||
listed by :mod:`rbenv.versions <salt.modules.rbenv.versions>`. Leave
|
||||
blank to return the current default.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rbenv.default
|
||||
# 2.0.0-p0
|
||||
|
||||
salt '*' rbenv.default 2.0.0-p0
|
||||
'''
|
||||
|
||||
@ -229,7 +241,9 @@ def list_(runas=None):
|
||||
'''
|
||||
List the installable versions of ruby.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rbenv.list
|
||||
'''
|
||||
|
@ -32,7 +32,9 @@ def enable():
|
||||
'''
|
||||
Enable RDP the service on the server
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rdp.enable
|
||||
'''
|
||||
@ -44,7 +46,9 @@ def disable():
|
||||
'''
|
||||
Disable RDP the service on the server
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rdp.disable
|
||||
'''
|
||||
@ -56,7 +60,9 @@ def status():
|
||||
'''
|
||||
Show if rdp is enabled on the server
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rdp.status
|
||||
'''
|
||||
|
@ -38,6 +38,7 @@ class Registry(object):
|
||||
"HKEY_CURRENT_USER": _winreg.HKEY_CURRENT_USER,
|
||||
"HKEY_LOCAL_MACHINE": _winreg.HKEY_LOCAL_MACHINE,
|
||||
}
|
||||
|
||||
def __getattr__(self, k):
|
||||
try:
|
||||
return self.hkeys[k]
|
||||
@ -46,6 +47,7 @@ class Registry(object):
|
||||
hkeys = ', '.join(self.hkeys)
|
||||
raise CommandExecutionError(msg.format(k, hkeys))
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Only works on Windows systems
|
||||
@ -58,11 +60,14 @@ def __virtual__():
|
||||
log.warn(salt.utils.required_modules_error(__file__, __doc__))
|
||||
return False
|
||||
|
||||
|
||||
def read_key(hkey, path, key):
|
||||
'''
|
||||
Read registry key value
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' reg.read_key HKEY_LOCAL_MACHINE 'SOFTWARE\\Salt' 'version'
|
||||
'''
|
||||
@ -84,7 +89,9 @@ def set_key(hkey, path, key, value, vtype='REG_DWORD'):
|
||||
Set a registry key
|
||||
vtype: http://docs.python.org/2/library/_winreg.html#value-types
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' reg.set_key HKEY_CURRENT_USER 'SOFTWARE\\Salt' 'version' '0.97' REG_DWORD
|
||||
'''
|
||||
@ -114,7 +121,9 @@ def create_key(hkey, path, key, value=None):
|
||||
'''
|
||||
Create a registry key
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' reg.create_key HKEY_CURRENT_USER 'SOFTWARE\\Salt' 'version' '0.97'
|
||||
'''
|
||||
@ -140,7 +149,9 @@ def delete_key(hkey, path, key):
|
||||
|
||||
Note: This cannot delete a key with subkeys
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' reg.delete_key HKEY_CURRENT_USER 'SOFTWARE\\Salt' 'version'
|
||||
'''
|
||||
|
@ -11,7 +11,9 @@ def get_jid(returner, jid):
|
||||
'''
|
||||
Return the information for a specified job id
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ret.get_jid redis 20421104181954700505
|
||||
'''
|
||||
@ -23,7 +25,9 @@ def get_fun(returner, fun):
|
||||
'''
|
||||
Return info about last time fun was called on each minion
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ret.get_fun mysql network.interfaces
|
||||
'''
|
||||
@ -35,7 +39,9 @@ def get_jids(returner):
|
||||
'''
|
||||
Return a list of all job ids
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ret.get_jids mysql
|
||||
'''
|
||||
@ -47,7 +53,9 @@ def get_minions(returner):
|
||||
'''
|
||||
Return a list of all minions
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ret.get_minions mysql
|
||||
'''
|
||||
|
@ -792,7 +792,9 @@ def build_bond(iface, **settings):
|
||||
Create a bond script in /etc/modprobe.d with the passed settings
|
||||
and load the bonding kernel module.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.build_bond bond0 mode=balance-alb
|
||||
'''
|
||||
@ -827,7 +829,9 @@ def build_interface(iface, iface_type, enabled, **settings):
|
||||
'''
|
||||
Build an interface script for a network interface.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.build_interface eth0 eth <settings>
|
||||
'''
|
||||
@ -881,7 +885,9 @@ def build_routes(iface, **settings):
|
||||
'''
|
||||
Build a route script for a network interface.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.build_routes eth0 <settings>
|
||||
'''
|
||||
@ -910,7 +916,9 @@ def down(iface, iface_type):
|
||||
'''
|
||||
Shutdown a network interface
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.down eth0
|
||||
'''
|
||||
@ -924,7 +932,9 @@ def get_bond(iface):
|
||||
'''
|
||||
Return the content of a bond script
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.get_bond bond0
|
||||
'''
|
||||
@ -936,7 +946,9 @@ def get_interface(iface):
|
||||
'''
|
||||
Return the contents of an interface script
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.get_interface eth0
|
||||
'''
|
||||
@ -948,7 +960,9 @@ def up(iface, iface_type): # pylint: disable=C0103
|
||||
'''
|
||||
Start up a network interface
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.up eth0
|
||||
'''
|
||||
@ -962,7 +976,9 @@ def get_routes(iface):
|
||||
'''
|
||||
Return the contents of the interface routes script.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.get_routes eth0
|
||||
'''
|
||||
@ -974,7 +990,9 @@ def get_network_settings():
|
||||
'''
|
||||
Return the contents of the global network script.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.get_network_settings
|
||||
'''
|
||||
@ -985,7 +1003,9 @@ def apply_network_settings(**settings):
|
||||
'''
|
||||
Apply global network configuration.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.apply_network_settings
|
||||
'''
|
||||
@ -1006,7 +1026,9 @@ def build_network_settings(**settings):
|
||||
'''
|
||||
Build the global network script.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' ip.build_network_settings <settings>
|
||||
'''
|
||||
|
@ -205,7 +205,9 @@ def get_enabled(limit=''):
|
||||
Return the enabled services. Use the ``limit`` param to restrict results
|
||||
to services of that type.
|
||||
|
||||
CLI Examples::
|
||||
CLI Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.get_enabled
|
||||
salt '*' service.get_enabled limit=upstart
|
||||
@ -233,7 +235,9 @@ def get_disabled(limit=''):
|
||||
Return the disabled services. Use the ``limit`` param to restrict results
|
||||
to services of that type.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.get_disabled
|
||||
salt '*' service.get_disabled limit=upstart
|
||||
@ -261,7 +265,9 @@ def get_all(limit=''):
|
||||
Return all installed services. Use the ``limit`` param to restrict results
|
||||
to services of that type.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.get_all
|
||||
salt '*' service.get_all limit=upstart
|
||||
@ -281,7 +287,9 @@ def available(name, limit=''):
|
||||
Return True is the named service is available. Use the ``limit`` param to
|
||||
restrict results to services of that type.
|
||||
|
||||
CLI Examples::
|
||||
CLI Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.get_enabled
|
||||
salt '*' service.get_enabled limit=upstart
|
||||
@ -299,7 +307,9 @@ def start(name):
|
||||
'''
|
||||
Start the specified service
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.start <service name>
|
||||
'''
|
||||
@ -314,7 +324,9 @@ def stop(name):
|
||||
'''
|
||||
Stop the specified service
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.stop <service name>
|
||||
'''
|
||||
@ -329,7 +341,9 @@ def restart(name, **kwargs):
|
||||
'''
|
||||
Restart the named service
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.restart <service name>
|
||||
'''
|
||||
@ -344,7 +358,9 @@ def reload_(name, **kwargs):
|
||||
'''
|
||||
Reload the named service
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.reload <service name>
|
||||
'''
|
||||
@ -360,7 +376,9 @@ def status(name, sig=None):
|
||||
Return the status for a service, returns a bool whether the service is
|
||||
running.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.status <service name>
|
||||
'''
|
||||
@ -377,7 +395,9 @@ def enable(name, **kwargs):
|
||||
'''
|
||||
Enable the named service to start at boot
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.enable <service name>
|
||||
'''
|
||||
@ -391,7 +411,9 @@ def disable(name, **kwargs):
|
||||
'''
|
||||
Disable the named service to start at boot
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.disable <service name>
|
||||
'''
|
||||
@ -405,7 +427,9 @@ def enabled(name):
|
||||
'''
|
||||
Check to see if the named service is enabled to start on boot
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.enabled <service name>
|
||||
'''
|
||||
@ -419,7 +443,9 @@ def disabled(name):
|
||||
'''
|
||||
Check to see if the named service is disabled to start on boot
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.disabled <service name>
|
||||
'''
|
||||
|
@ -9,6 +9,7 @@ Author: David Boucha <boucha@gmail.com>
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Only available on systems with Riak installed.
|
||||
@ -22,7 +23,9 @@ def start():
|
||||
'''
|
||||
Start Riak
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' riak.start
|
||||
'''
|
||||
@ -33,7 +36,9 @@ def stop():
|
||||
'''
|
||||
Stop Riak
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' riak.stop
|
||||
'''
|
||||
@ -44,7 +49,9 @@ def cluster_join(riak_user=None, riak_host=None):
|
||||
'''
|
||||
Join a Riak cluster
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' riak.cluster_join <user> <host>
|
||||
'''
|
||||
@ -59,7 +66,9 @@ def cluster_plan():
|
||||
'''
|
||||
Review Cluster Plan
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' riak.cluster_plan
|
||||
'''
|
||||
@ -70,7 +79,9 @@ def cluster_commit():
|
||||
'''
|
||||
Commit Cluster Changes
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' riak.cluster_commit
|
||||
'''
|
||||
@ -81,7 +92,9 @@ def member_status():
|
||||
'''
|
||||
Get cluster member status
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' riak.member_status
|
||||
'''
|
||||
|
@ -44,7 +44,9 @@ def list_pkgs(*packages):
|
||||
|
||||
{'<package_name>': '<version>'}
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' lowpkg.list_pkgs
|
||||
'''
|
||||
@ -69,7 +71,9 @@ def verify(*package):
|
||||
'''
|
||||
Runs an rpm -Va on a system, and returns the results in a dict
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' lowpkg.verify
|
||||
'''
|
||||
@ -121,7 +125,9 @@ def file_list(*packages):
|
||||
return a list of _every_ file on the system's rpm database (not generally
|
||||
recommended).
|
||||
|
||||
CLI Examples::
|
||||
CLI Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' lowpkg.file_list httpd
|
||||
salt '*' lowpkg.file_list httpd postfix
|
||||
@ -141,7 +147,9 @@ def file_dict(*packages):
|
||||
any packages will return a list of _every_ file on the system's rpm
|
||||
database (not generally recommended).
|
||||
|
||||
CLI Examples::
|
||||
CLI Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' lowpkg.file_list httpd
|
||||
salt '*' lowpkg.file_list httpd postfix
|
||||
|
@ -53,7 +53,9 @@ def is_installed(runas=None):
|
||||
'''
|
||||
Check if RVM is installed.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.is_installed
|
||||
'''
|
||||
@ -64,7 +66,9 @@ def install(runas=None):
|
||||
'''
|
||||
Install RVM system wide.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.install
|
||||
'''
|
||||
@ -95,7 +99,9 @@ def install_ruby(ruby, runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.install_ruby 1.9.3-p385
|
||||
'''
|
||||
@ -116,7 +122,9 @@ def reinstall_ruby(ruby, runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.reinstall_ruby 1.9.3-p385
|
||||
'''
|
||||
@ -130,7 +138,9 @@ def list_(runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.list
|
||||
'''
|
||||
@ -156,7 +166,9 @@ def set_default(ruby, runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.set_default 2.0.0
|
||||
'''
|
||||
@ -173,7 +185,9 @@ def get(version='stable', runas=None):
|
||||
ruby
|
||||
The version of ruby to reinstall.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.get
|
||||
'''
|
||||
@ -195,7 +209,9 @@ def wrapper(ruby_string, wrapper_prefix, runas=None, *binaries):
|
||||
given, wrappers for ruby, gem, rake, irb, rdoc, ri and testrb are
|
||||
generated.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.wrapper <ruby_string> <wrapper_prefix>
|
||||
'''
|
||||
@ -220,7 +236,9 @@ def rubygems(ruby, version, runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.rubygems 2.0.0 1.8.24
|
||||
'''
|
||||
@ -238,7 +256,9 @@ def gemset_create(ruby, gemset, runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.gemset_create 2.0.0 foobar
|
||||
'''
|
||||
@ -256,7 +276,9 @@ def gemset_list(ruby='default', runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.gemset_list
|
||||
'''
|
||||
@ -282,7 +304,9 @@ def gemset_delete(ruby, gemset, runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.gemset_delete 2.0.0 foobar
|
||||
'''
|
||||
@ -302,7 +326,9 @@ def gemset_empty(ruby, gemset, runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.gemset_empty 2.0.0 foobar
|
||||
'''
|
||||
@ -322,7 +348,9 @@ def gemset_copy(source, destination, runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.gemset_copy foobar bazquo
|
||||
'''
|
||||
@ -338,7 +366,9 @@ def gemset_list_all(runas=None):
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.gemset_list_all
|
||||
'''
|
||||
@ -370,7 +400,9 @@ def do(ruby, command, runas=None): # pylint: disable=C0103
|
||||
runas : None
|
||||
The user to run rvm as.
|
||||
|
||||
CLI Example::
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' rvm.do 2.0.0 <command>
|
||||
'''
|
||||
|
@ -391,8 +391,6 @@ def show_lowstate():
|
||||
ret = st_.compile_low_chunks()
|
||||
finally:
|
||||
st_.pop_active()
|
||||
if isinstance(ret, list):
|
||||
__context__['retcode'] = 1
|
||||
return ret
|
||||
|
||||
|
||||
|
@ -112,7 +112,7 @@ def installed(name,
|
||||
pip_bin : None
|
||||
Deprecated, use bin_env
|
||||
use_wheel : False
|
||||
Prefer wheel archives (requires pip>1.4)
|
||||
Prefer wheel archives (requires pip>=1.4)
|
||||
env : None
|
||||
Deprecated, use bin_env
|
||||
bin_env : None
|
||||
|
@ -418,26 +418,31 @@ def mod_watch(name, sig=None, reload=False, full_restart=False):
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': ''}
|
||||
action = ''
|
||||
|
||||
if __salt__['service.status'](name, sig):
|
||||
if 'service.reload' in __salt__ and reload:
|
||||
restart_func = __salt__['service.reload']
|
||||
action = 'reload'
|
||||
elif 'service.full_restart' in __salt__ and full_restart:
|
||||
restart_func = __salt__['service.full_restart']
|
||||
action = 'fully restart'
|
||||
else:
|
||||
restart_func = __salt__['service.restart']
|
||||
action = 'restart'
|
||||
else:
|
||||
restart_func = __salt__['service.start']
|
||||
action = 'start'
|
||||
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = 'Service is set to be restarted'
|
||||
ret['comment'] = 'Service is set to be {0}ed'.format(action)
|
||||
return ret
|
||||
|
||||
result = restart_func(name)
|
||||
|
||||
ret['changes'] = {name: result}
|
||||
ret['result'] = result
|
||||
ret['comment'] = 'Service restarted' if result else \
|
||||
'Failed to restart the service'
|
||||
ret['comment'] = 'Service {0}ed'.format(action) if result else \
|
||||
'Failed to {0} the service'.format(action)
|
||||
return ret
|
||||
|
@ -81,20 +81,20 @@ SUB_EVENT = set([
|
||||
'state.sls',
|
||||
])
|
||||
|
||||
TAGEND = '\n\n' # long tag delimeter
|
||||
TAGPARTER = '.' # name spaced tag delimeter
|
||||
SALT = 'salt' #base prefix for all salt. events
|
||||
TAGEND = '\n\n' # long tag delimeter
|
||||
TAGPARTER = '.' # name spaced tag delimeter
|
||||
SALT = 'salt' # base prefix for all salt. events
|
||||
# dict map of namespaced base tag prefixes for salt events
|
||||
TAGS = \
|
||||
{
|
||||
'auth': 'auth', # prefix for all .auth events
|
||||
'job': 'job', # prefix for all .job events (minion jobs)
|
||||
'key': 'key', # prefix for all .key events
|
||||
'minion': 'minion', # prefix for all .minion events (minion sourced events)
|
||||
'syndic': 'syndic', # prefix for all .syndic events (syndic minion sourced events)
|
||||
'run': 'run', #prefis for all .run events (salt runners)
|
||||
TAGS = {
|
||||
'auth': 'auth', # prefix for all .auth events
|
||||
'job': 'job', # prefix for all .job events (minion jobs)
|
||||
'key': 'key', # prefix for all .key events
|
||||
'minion': 'minion', # prefix for all .minion events (minion sourced events)
|
||||
'syndic': 'syndic', # prefix for all .syndic events (syndic minion sourced events)
|
||||
'run': 'run', # prefix for all .run events (salt runners)
|
||||
}
|
||||
|
||||
|
||||
def tagify(suffix='', prefix='', base=SALT):
|
||||
'''
|
||||
convenience function to build a namespaced event tag string
|
||||
@ -108,12 +108,13 @@ def tagify(suffix='', prefix='', base=SALT):
|
||||
|
||||
'''
|
||||
parts = [base, TAGS.get(prefix, prefix)]
|
||||
if hasattr(suffix, 'append'): # list so extend parts
|
||||
if hasattr(suffix, 'append'): # list so extend parts
|
||||
parts.extend(suffix)
|
||||
else: # string so append
|
||||
else: # string so append
|
||||
parts.append(suffix)
|
||||
return (TAGPARTER.join([part for part in parts if part]))
|
||||
|
||||
|
||||
class SaltEvent(object):
|
||||
'''
|
||||
The base class used to manage salt events
|
||||
@ -216,15 +217,15 @@ class SaltEvent(object):
|
||||
socks = dict(self.poller.poll(wait * 1000)) # convert to milliseconds
|
||||
if self.sub in socks and socks[self.sub] == zmq.POLLIN:
|
||||
raw = self.sub.recv()
|
||||
if ord(raw[20]) >= 0x80: #old style
|
||||
if ord(raw[20]) >= 0x80: # old style
|
||||
mtag = raw[0:20].rstrip('|')
|
||||
mdata = raw[20:]
|
||||
else: #new style
|
||||
mtag, sep, mdata = raw.partition(TAGEND) #split tag from data
|
||||
else: # new style
|
||||
mtag, sep, mdata = raw.partition(TAGEND) # split tag from data
|
||||
|
||||
data = self.serial.loads(mdata)
|
||||
|
||||
if not mtag.startswith(tag): #tag not match
|
||||
if not mtag.startswith(tag): # tag not match
|
||||
return None
|
||||
|
||||
if full:
|
||||
@ -251,19 +252,19 @@ class SaltEvent(object):
|
||||
|
||||
Supports new style long tags.
|
||||
'''
|
||||
if not str(tag): #no empty tags allowed
|
||||
if not str(tag): # no empty tags allowed
|
||||
raise ValueError('Empty tag.')
|
||||
|
||||
if not isinstance(data, MutableMapping): #data must be dict
|
||||
if not isinstance(data, MutableMapping): # data must be dict
|
||||
raise ValueError('Dict object expected, not "{0!r}".'.format(data))
|
||||
|
||||
if not self.cpush:
|
||||
self.connect_pull()
|
||||
|
||||
tagend = ""
|
||||
if len(tag) <= 20: #old style compatible tag
|
||||
tag = '{0:|<20}'.format(tag) #pad with pipes '|' to 20 character length
|
||||
else: #new style longer than 20 chars
|
||||
if len(tag) <= 20: # old style compatible tag
|
||||
tag = '{0:|<20}'.format(tag) # pad with pipes '|' to 20 character length
|
||||
else: # new style longer than 20 chars
|
||||
tagend = TAGEND
|
||||
|
||||
event = '{0}{1}{2}'.format(tag, tagend, self.serial.dumps(data))
|
||||
@ -306,10 +307,10 @@ class SaltEvent(object):
|
||||
if data.get('result') is False:
|
||||
self.fire_event(
|
||||
data,
|
||||
'{0}.{1}'.format(tags[0], tags[-1])) # old dup event
|
||||
'{0}.{1}'.format(tags[0], tags[-1])) # old dup event
|
||||
data['jid'] = load['jid']
|
||||
data['id'] = load['id']
|
||||
data['success'] = false
|
||||
data['success'] = False
|
||||
data['return'] = 'Error: {0}.{1}'.format(tags[0], tags[-1])
|
||||
data['fun'] = load['fun']
|
||||
self.fire_event(
|
||||
@ -317,8 +318,8 @@ class SaltEvent(object):
|
||||
tagify([load['jid'],
|
||||
'sub',
|
||||
load['id'],
|
||||
'error',
|
||||
load['fun']],
|
||||
'error',
|
||||
load['fun']],
|
||||
'job'))
|
||||
except Exception:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user