Skip to content

Commit

Permalink
Merge pull request #33877 from rallytime/merge-2015.8
Browse files Browse the repository at this point in the history
[2015.8] Merge forward from 2015.5 to 2015.8
  • Loading branch information
Nicole Thomas committed Jun 9, 2016
2 parents ec09095 + 398534a commit ef6da0b
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 70 deletions.
183 changes: 135 additions & 48 deletions salt/modules/saltutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,22 @@ def update(version=None):

def sync_beacons(saltenv=None, refresh=True):
'''
Sync the beacons from the _beacons directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _beacons directory, base is the default
environment.
.. versionadded:: 2015.5.1
Sync the beacons from the ``salt://_beacons`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_beacons`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : True
Also refresh the beacons available to the minion.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_beacons
salt '*' saltutil.sync_beacons saltenv=dev
'''
ret = _sync('beacons', saltenv)
if refresh:
Expand All @@ -279,29 +283,37 @@ def sync_beacons(saltenv=None, refresh=True):

def sync_sdb(saltenv=None, refresh=False):
'''
Sync sdb modules from the _sdb directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _sdb directory, base is the default
environment.
.. versionadded:: 2015.5.7
Sync sdb modules from the ``salt://_sdb`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_sdb`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : False
This argument has no affect and is included for consistency with the
other sync functions.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_sdb
salt '*' saltutil.sync_sdb saltenv=dev
'''
ret = _sync('sdb', saltenv)
return ret


def sync_modules(saltenv=None, refresh=True):
'''
Sync the modules from the _modules directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _modules directory, base is the default
environment.
Sync the modules from the ``salt://_modules`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_modules`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : True
Also refresh the execution modules available to the minion.
.. important::
Expand All @@ -320,13 +332,12 @@ def sync_modules(saltenv=None, refresh=True):
See :ref:`here <reloading-modules>` for a more detailed explanation of
why this is necessary.
.. versionadded:: 2015.5.1
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_modules
salt '*' saltutil.sync_modules saltenv=dev
'''
ret = _sync('modules', saltenv)
if refresh:
Expand All @@ -336,16 +347,20 @@ def sync_modules(saltenv=None, refresh=True):

def sync_states(saltenv=None, refresh=True):
'''
Sync the states from the _states directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _states directory, base is the default
environment.
Sync the states from the ``salt://_states`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_states`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : True
Also refresh the execution modules available to the minion.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_states
salt '*' saltutil.sync_states saltenv=dev
'''
ret = _sync('states', saltenv)
if refresh:
Expand All @@ -355,16 +370,21 @@ def sync_states(saltenv=None, refresh=True):

def sync_grains(saltenv=None, refresh=True):
'''
Sync the grains from the _grains directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _grains directory, base is the default
environment.
Sync the grains from the ``salt://_grains`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_grains`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : True
Also refresh the execution modules available to the minion, and refresh
pillar data.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_grains
salt '*' saltutil.sync_grains saltenv=dev
'''
ret = _sync('grains', saltenv)
if refresh:
Expand All @@ -375,16 +395,20 @@ def sync_grains(saltenv=None, refresh=True):

def sync_renderers(saltenv=None, refresh=True):
'''
Sync the renderers from the _renderers directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _renderers directory, base is the default
environment.
Sync the renderers from the ``salt://_renderers`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_renderers`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : True
Also refresh the execution modules available to the minion.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_renderers
salt '*' saltutil.sync_renderers saltenv=dev
'''
ret = _sync('renderers', saltenv)
if refresh:
Expand All @@ -394,16 +418,20 @@ def sync_renderers(saltenv=None, refresh=True):

def sync_returners(saltenv=None, refresh=True):
'''
Sync the returners from the _returners directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _returners directory, base is the default
environment.
Sync the returners from the ``salt://_returners`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_returners`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : True
Also refresh the execution modules available to the minion.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_returners
salt '*' saltutil.sync_returners saltenv=dev
'''
ret = _sync('returners', saltenv)
if refresh:
Expand All @@ -413,16 +441,19 @@ def sync_returners(saltenv=None, refresh=True):

def sync_proxymodules(saltenv=None, refresh=False):
'''
Sync the proxy modules from the _proxy directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _returners directory, base is the default
environment.
.. versionadded:: 2015.8.2
Sync the proxy modules from the ``salt://_proxy`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_proxy`` directory from that
environment. The default environment, if none is specified, is ``base``.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_proxymodules
salt '*' saltutil.sync_proxymodules saltenv=dev
'''
ret = _sync('proxy', saltenv)
if refresh:
Expand All @@ -432,16 +463,20 @@ def sync_proxymodules(saltenv=None, refresh=False):

def sync_output(saltenv=None, refresh=True):
'''
Sync the output modules from the _output directory on the salt master file
server. This function is environment aware. Pass the desired environment
to grab the contents of the _output directory. Base is the default
environment.
Sync the output modules from the ``salt://_output`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_output`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : True
Also refresh the execution modules available to the minion.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_output
salt '*' saltutil.sync_output saltenv=dev
'''
ret = _sync('output', saltenv)
if refresh:
Expand All @@ -453,16 +488,22 @@ def sync_output(saltenv=None, refresh=True):

def sync_utils(saltenv=None, refresh=True):
'''
Sync utility source files from the _utils directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _utils directory, base is the default
environment.
.. versionadded:: 2014.7.0
Sync utility source files from the ``salt://_utils`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_utils`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : True
Also refresh the execution modules available to the minion.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_utils
salt '*' saltutil.sync_utils saltenv=dev
'''
ret = _sync('utils', saltenv)
if refresh:
Expand All @@ -474,25 +515,66 @@ def sync_log_handlers(saltenv=None, refresh=True):
'''
.. versionadded:: 2015.8.0
Sync utility source files from the _log_handlers directory on the salt master file
server. This function is environment aware, pass the desired environment
to grab the contents of the _log_handlers directory, base is the default
environment.
Sync utility source files from the ``salt://_log_handlers`` directory on
the Salt fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_log_handlers`` directory from
that environment. The default environment, if none is specified, is
``base``.
CLI Example:
.. code-block:: bash
salt '*' saltutil.sync_log_handlers
salt '*' saltutil.sync_log_handlers saltenv=dev
'''
ret = _sync('log_handlers', saltenv)
if refresh:
refresh_modules()
return ret


def sync_pillar(saltenv=None, refresh=True):
'''
.. versionadded:: 2015.8.11,2016.3.2
Sync pillar modules from the ``salt://_pillar`` directory on the Salt
fileserver. This function is environment-aware, pass the desired
environment to grab the contents of the ``_pillar`` directory from that
environment. The default environment, if none is specified, is ``base``.
refresh : True
Also refresh the execution modules available to the minion, and refresh
pillar data.
.. note::
This function will raise an error if executed on a traditional (i.e.
not masterless) minion
CLI Examples:
.. code-block:: bash
salt '*' saltutil.sync_pillar
salt '*' saltutil.sync_pillar saltenv=dev
'''
if __opts__['file_client'] != 'local':
raise CommandExecutionError(
'Pillar modules can only be synced to masterless minions'
)
ret = _sync('pillar', saltenv)
if refresh:
refresh_modules()
refresh_pillar()
return ret


def sync_all(saltenv=None, refresh=True):
'''
.. versionchanged:: 2015.8.11,2016.3.2
On masterless minions, pillar modules are now synced, and refreshed
when ``refresh`` is set to ``True``.
Sync down all of the dynamic modules from the file server for a specific
environment. This function synchronizes custom modules, states, beacons,
grains, returners, output modules, renderers, and utils.
Expand Down Expand Up @@ -522,6 +604,7 @@ def sync_all(saltenv=None, refresh=True):
.. code-block:: bash
salt '*' saltutil.sync_all
salt '*' saltutil.sync_all saltenv=dev
'''
log.debug('Syncing all')
ret = {}
Expand All @@ -536,8 +619,12 @@ def sync_all(saltenv=None, refresh=True):
ret['utils'] = sync_utils(saltenv, False)
ret['log_handlers'] = sync_log_handlers(saltenv, False)
ret['proxymodules'] = sync_proxymodules(saltenv, False)
if __opts__['file_client'] == 'local':
ret['pillar'] = sync_pillar(saltenv, False)
if refresh:
refresh_modules()
if __opts__['file_client'] == 'local':
refresh_pillar()
return ret


Expand Down
2 changes: 1 addition & 1 deletion salt/returners/sqlite3_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def get_load(jid):
{'jid': jid})
data = cur.fetchone()
if data:
return json.loads(data)
return json.loads(data[0].encode())
_close_conn(conn)
return {}

Expand Down
Loading

0 comments on commit ef6da0b

Please sign in to comment.