您的位置:首页 > 其它

SaltStack源码分析之saltutil模块

2015-05-27 18:06 295 查看
saltutil模块用于管理minion的状态

/usr/lib/python2.6/site-packages/salt/modules/saltutil.py
# -*- coding: utf-8 -*-
'''
The Saltutil module is used to manage the state of the salt minion itself. It
is used to manage minion modules as well as automate updates to the salt
minion.

:depends:   - esky Python module for update functionality
'''


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.

CLI Example:

.. code-block:: bash

salt '*' saltutil.sync_grains
'''
ret = _sync('grains', saltenv)
if refresh:
refresh_modules()
refresh_pillar()
return ret


def sync_all(saltenv=None, refresh=True):
'''
Sync down all of the dynamic modules from the file server for a specific
environment

CLI Example:

.. code-block:: bash

salt '*' saltutil.sync_all
'''
log.debug('Syncing all')
ret = {}
ret['modules'] = sync_modules(saltenv, False)
ret['states'] = sync_states(saltenv, False)
ret['grains'] = sync_grains(saltenv, False)
ret['renderers'] = sync_renderers(saltenv, False)
ret['returners'] = sync_returners(saltenv, False)
ret['outputters'] = sync_outputters(saltenv, False)
ret['utils'] = sync_utils(saltenv, False)
if refresh:
refresh_modules()
return ret


本文出自 “Linux SA John” 博客,请务必保留此出处http://john88wang.blog.51cto.com/2165294/1655744
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: