/usr/lib/python2.6/site-packages/salt/modules/test.py
test模块用于测试Master与各个minion之间通信情况
# -*- coding: utf-8 -*- ''' Module for running arbitrary tests ''' # Import Python libs import os import sys import time import random # Import Salt libs import salt import salt.version import salt.loader __proxyenabled__ = ['*']
导入各个模块
def echo(text): ''' Return a string - used for testing the connection CLI Example: .. code-block:: bash salt '*' test.echo 'foo bar baz quo qux' ''' return text
返回指定的字符串,用于测试minion的连接情况
$ sudo salt '*' test.echo "this is a test" jidong-fileserver: this is a test localhost.localdomain: this is a test gintama-qa-server: this is a test jialebi-qa-server: this is a test
def ping(): ''' Just used to make sure the minion is up and responding Return True CLI Example: .. code-block:: bash salt '*' test.ping ''' if 'proxyobject' in __opts__: return __opts__['proxyobject'].ping() else: return True
def sleep(length): ''' Instruct the minion to initiate a process that will sleep for a given period of time. CLI Example: .. code-block:: bash salt '*' test.sleep 20 ''' time.sleep(int(length)) return True
def rand_sleep(max=60): ''' Sleep for a random number of seconds, used to test long-running commands and minions returning at differing intervals CLI Example: .. code-block:: bash salt '*' test.rand_sleep 60 ''' time.sleep(random.randint(0, max)) return True