%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/client/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/client/api.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddl	Zddl
ZddlZddlZddl
ZddljZddlmZdd�Zdefd��YZdS(uF
This module provides the point of entry for client applications to interface to
salt. The purpose is to have a simplified consistent interface for various
client applications.

.. warning:: This API is not yet public or stable!

    This API exists in its current form as an entry point for Halite only. This
    interface is likely to change without warning. Long-term plans are to make
    this public as a unified interface to Salt's *Client() APIs. Until that
    time please use Salt's *Client() interfaces individually:

    http://docs.saltstack.com/ref/clients/index.html

i(tabsolute_importtprint_functiontunicode_literalsN(tEauthAuthenticationErrorcC@s|dk	r||d<n|S(u{
    If token is not None Then assign token to 'token' key of cmd dict
        and return cmd
    Otherwise return cmd
    utokenN(tNone(tcmdttoken((s3/usr/lib/python2.7/site-packages/salt/client/api.pyttokenify"s
t	APIClientcB@s�eZdZded�Zd�Zd�Zd�Zd�Z	e	Z
d�ZeZd�Z
d�Zd	�Zd
�Zdded
�Zd�ZRS(u�
    Provide a uniform method of accessing the various client interfaces in Salt
    in the form of low-data data structures. For example:
    cC@s�|s<tjjtjjdtjjtj	d���}n||_
tjj|j
d�|_
tjj|j
�|_tjj|j
�|_tjj|j
�|_tjjjd|j
d|j
dd|j
d|�|_dS(NuSALT_MASTER_CONFIGumasteru	conf_fileusock_diru	transporttoptstlisten(tsalttconfigt
client_configtostenvirontgettpathtjointsyspathst
CONFIG_DIRR	tclienttget_local_clienttlocalClienttrunnertRunnerClienttrunnerClienttwheeltWheeltwheelClienttauthtResolvertresolvertutilsteventt	get_event(tselfR	R
((s3/usr/lib/python2.7/site-packages/salt/client/api.pyt__init__2s 		!	

	c	C@s�t|�}d}|jdd�}|jdd�jd�}t|�dkr�|ddkr�|d}dj|d�|d<nd|kp�d
|ko�d|ko�d|ks�td��nt|dj||��}||�}|S(u�	
        Execute the salt command given by cmd dict.

        cmd is a dictionary of the following form:

        {
            'mode': 'modestring',
            'fun' : 'modulefunctionstring',
            'kwarg': functionkeywordargdictionary,
            'tgt' : 'targetpatternstring',
            'tgt_type' : 'targetpatterntype',
            'ret' : 'returner namestring',
            'timeout': 'functiontimeout',
            'arg' : 'functionpositionalarg sequence',
            'token': 'salttokenstring',
            'username': 'usernamestring',
            'password': 'passwordstring',
            'eauth': 'eauthtypestring',
        }

        Implied by the fun is which client is used to run the command, that is, either
        the master local minion client, the master runner client, or the master wheel client.

        The cmd dict items are as follows:

        mode: either 'sync' or 'asynchronous'. Defaults to 'asynchronous' if missing
        fun: required. If the function is to be run on the master using either
            a wheel or runner client then the fun: includes either
            'wheel.' or 'runner.' as a prefix and has three parts separated by '.'.
            Otherwise the fun: specifies a module to be run on a minion via the local
            minion client.
            Example:
                fun of 'wheel.config.values' run with master wheel client
                fun of 'runner.manage.status' run with master runner client
                fun of 'test.ping' run with local minion client
                fun of 'wheel.foobar' run with with local minion client not wheel
        kwarg: A dictionary of keyword function parameters to be passed to the eventual
               salt function specified by fun:
        tgt: Pattern string specifying the targeted minions when the implied client is local
        tgt_type: Optional target pattern type string when client is local minion.
            Defaults to 'glob' if missing
        ret: Optional name string of returner when local minion client.
        arg: Optional positional argument string when local minion client
        token: the salt token. Either token: is required or the set of username:,
            password: , and eauth:
        username: the salt username. Required if token is missing.
        password: the user's password. Required if token is missing.
        eauth: the authentication type such as 'pam' or 'ldap'. Required if token is missing

        uminionumodeuasyncufunuu.iiuwheelurunneriutokenueauthupassworduusernameu#No authentication credentials givenu{0}_{1}(uwheelurunner(tdictRtsplittlenRRtgetattrtformat(R$RRtmodetfunpartstexecutortresult((s3/usr/lib/python2.7/site-packages/salt/client/api.pytrunFs3"
$cK@s|jj|�S(u�
        Wrap LocalClient for running :ref:`execution modules <all-salt.modules>`
        and immediately return the job ID. The results of the job can then be
        retrieved at a later time.

        .. seealso:: :ref:`python-api`
        (Rtrun_job(R$tkwargs((s3/usr/lib/python2.7/site-packages/salt/client/api.pytminion_async�scK@s|jj|�S(u�
        Wrap LocalClient for running :ref:`execution modules <all-salt.modules>`

        .. seealso:: :ref:`python-api`
        (RR(R$R1((s3/usr/lib/python2.7/site-packages/salt/client/api.pytminion_sync�scK@s|jj|�S(u�
        Wrap RunnerClient for executing :ref:`runner modules <all-salt.runners>`
        Expects that one of the kwargs is key 'fun' whose value is the namestring
        of the function to call
        (Rtmaster_call(R$R1((s3/usr/lib/python2.7/site-packages/salt/client/api.pytrunner_async�scK@s|jj|�S(u�
        Wrap Wheel to enable executing :ref:`wheel modules <all-salt.wheel>`
        Expects that one of the kwargs is key 'fun' whose value is the namestring
        of the function to call
        (RR4(R$R1((s3/usr/lib/python2.7/site-packages/salt/client/api.pyt
wheel_sync�scC@s`d|d<t|djd��dkrS|djd�dd
krSd	|d<n|j|�S(u�
        Convenience function that returns dict of function signature(s) specified by cmd.

        cmd is dict of the form:
        {
            'module' : 'modulestring',
            'tgt' : 'targetpatternstring',
            'tgt_type' : 'targetpatterntype',
            'token': 'salttokenstring',
            'username': 'usernamestring',
            'password': 'passwordstring',
            'eauth': 'eauthtypestring',
        }

        The cmd dict items are as follows:

        module: required. This is either a module or module function name for
            the specified client.
        tgt: Optional pattern string specifying the targeted minions when client
          is 'minion'
        tgt_type: Optional target pattern type string when client is 'minion'.
            Example: 'glob' defaults to 'glob' if missing
        token: the salt token. Either token: is required or the set of username:,
            password: , and eauth:
        username: the salt username. Required if token is missing.
        password: the user's password. Required if token is missing.
        eauth: the authentication type such as 'pam' or 'ldap'. Required if token is missing

        Adds client per the command.
        uminionuclientumoduleu.iiurunneruwheelumaster(urunneruwheel(R(R't
_signature(R$R((s3/usr/lib/python2.7/site-packages/salt/client/api.pyt	signature�s
<
cC@s�i}|jdd�}|dkrWd|d<td|d�|d<|j|�}n�|dkr�|djd	�}|d
}d	j|d�}|dkr�|jj}n|d
kr�|jj}nitj	j
j||�d6}n|S(u�
        Expects everything that signature does and also a client type string.
        client can either be master or minion.
        uclientuminionusys.argspecufuntmoduleumoduleukwargumasteru.iiuwheelurunner(RR&R/R'RRt	functionsRRR!targstargspec_report(R$RR.RtpartsR9R:((s3/usr/lib/python2.7/site-packages/salt/client/api.pyR7�s 

"cC@s�y|jj|�}Wn.tk
rF}tdjt|����nXd|krbtd��n|jd|d}|d|kr�||d|d<n|d|d<|d|d	<|d|d
<|S(u*
        Create token with creds.
        Token authorizes salt access if successful authentication
        with the credentials in creds.
        creds format is as follows:

        {
            'username': 'namestring',
            'password': 'passwordstring',
            'eauth': 'eauthtypestring',
        }

        examples of valid eauth type strings: 'pam' or 'ldap'

        Returns dictionary of token information with the following format:

        {
            'token': 'tokenstring',
            'start': starttimeinfractionalseconds,
            'expire': expiretimeinfractionalseconds,
            'name': 'usernamestring',
            'user': 'usernamestring',
            'username': 'usernamestring',
            'eauth': 'eauthtypestring',
            'perms: permslistofstrings,
        }
        The perms list provides those parts of salt for which the user is authorised
        to execute.
        example perms list:
        [
            "grains.*",
            "status.*",
            "sys.*",
            "test.*"
        ]

        uAuthentication failed with {0}.utokenu0Authentication failed with provided credentials.u
external_authueauthunameupermsu*uuseruusername(R tmk_tokent	ExceptionRR*treprR	(R$tcredsttokenagetexttokenage_eauth((s3/usr/lib/python2.7/site-packages/salt/client/api.pytcreate_token�s&cC@sKy|jj|�}Wn.tk
rF}tdjt|����nX|S(ud
        If token is valid Then returns user name associated with token
        Else False.
        u!Token validation failed with {0}.(R t	get_tokenR?RR*R@(R$RR.RC((s3/usr/lib/python2.7/site-packages/salt/client/api.pytverify_token'sg�?uc	C@s%|jjd|d|d|dt�S(u(
        Get a single salt event.
        If no events are available, then block for up to ``wait`` seconds.
        Return the event if it matches the tag (or ``tag`` is empty)
        Otherwise return None

        If wait is 0 then block forever or until next event becomes available.
        twaitttagtfulltauto_reconnect(R"R#tTrue(R$RHRIRJ((s3/usr/lib/python2.7/site-packages/salt/client/api.pyR#4s	cC@s%|jj|tjjj|d��S(u�
        fires event with data and tag
        This only works if api is running with same user permissions as master
        Need to convert this to a master call with appropriate authentication

        uwui(R"t
fire_eventRR!ttagify(R$tdataRI((s3/usr/lib/python2.7/site-packages/salt/client/api.pyRM?sN(t__name__t
__module__t__doc__RRLR%R/R2R3R5trunner_syncR6twheel_asyncR8R7RERGtFalseR#RM(((s3/usr/lib/python2.7/site-packages/salt/client/api.pyR-s	E	
				$		;	
(RRt
__future__RRRRtsalt.configRt	salt.authtsalt.clienttsalt.runnert
salt.wheeltsalt.utils.argstsalt.utils.eventt
salt.syspathsRtsalt.exceptionsRRRtobjectR(((s3/usr/lib/python2.7/site-packages/salt/client/api.pyt<module>s

Zerion Mini Shell 1.0