%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sFdZddlmZmZmZddlZddlZddlZddlZddl	m	Z	ddl
ZddlZddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddljZddlmZmZm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&e'Z(yddl)Z*e+Z(Wne,k
r�nXddl-Z.ej/e0�Z1ej2j3ej4d�e5e'e5e'd�Z6d	e7fd
��YZ8de9fd��YZ:d
e7fd��YZ;de7fd��YZ<dS(u'
The client module is used to create a client connection to the publisher
The data structure needs to be:
    {'enc': 'clear',
     'load': {'fun': '<mod.callable>',
              'arg':, ('arg1', 'arg2', ...),
              'tgt': '<glob or id>',
              'key': '<read in the key file>'}
i(tabsolute_importtprint_functiontunicode_literalsN(tdatetime(tAuthenticationErrortAuthorizationErrortEauthAuthenticationErrortPublishErrortSaltInvocationErrortSaltReqTimeoutErrortSaltClientError(tsixumasterc	C@s�|r|}nddl}|jj|�}|ddkr_ddl}|jjjd|�S|ddkr�td|d|d	|d
|�SdS(u�
    .. versionadded:: 2014.7.0

    Read in the config and return the correct LocalClient object based on
    the configured transport

    :param IOLoop io_loop: io_loop used for events.
                           Pass in an io_loop if you want asynchronous
                           operation for obtaining events. Eg use of
                           set_event_handler() API. Otherwise, operation
                           will be synchronous.
    iNu	transporturaettmoptsuzeromqutcptskip_perm_errorstio_looptauto_reconnect(uzeromqutcp(tsalt.configtconfigt
client_configtsalt.client.raettclienttraettLocalClient(tc_pathRR
RRtoptstsalt((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytget_local_clientLs	Rc
B@s�eZdZejjejd�d'e	d'e	e	d�Z
d�Zd�Zd�Z
ed�Zed�Zd(dd	d'd	d'e	d
�Zd�Zejjd)dd	d'd	d'ed'd��Zd*dd	d	d'd
�Zd+dd	d'de	e	e	d�Zd,dd	d'dd�Zd-d'dd	d	e	d'd�Zd.d'dd	e	d'e	d�Zd/d'dd	d'd�Zd0d'dd	d'e	e	d�Zd1d'dd	e	d'd�Zd'dde	e	d�Zd'd�Z d'dde	ed�Z!d'd�Z"d'd�Z#d�Z$d'dde	e	e	d�Z%d'dde	e	e	e	d�Z&d'd �Z'd!�Z(d2dd	d	d"e	d#�Z)ejjd3dd	d	d"d'ed$��Z*d%�Z+d&�Z,RS(4u=
    The interface used by the :command:`salt` CLI tool on the Salt Master

    ``LocalClient`` is used to send a command to Salt minions to execute
    :ref:`execution modules <all-salt.modules>` and return the results to the
    Salt Master.

    Importing and using ``LocalClient`` must be done on the same machine as the
    Salt Master and it must be done using the same user that the Salt Master is
    running as. (Unless :conf_master:`external_auth` is configured and
    authentication credentials are included in the execution).

    .. note::
        The LocalClient uses a Tornado IOLoop, this can create issues when
        using the LocalClient inside an existing IOLoop. If creating the
        LocalClient in partnership with another IOLoop either create the
        IOLoop before creating the LocalClient, or when creating the IOLoop
        use ioloop.current() which will return the ioloop created by
        LocalClient.

    .. code-block:: python

        import salt.client

        local = salt.client.LocalClient()
        local.cmd('*', 'test.fib', [10])
    umastercC@sE|r||_nCtjj|�r@tjd|jj|�ntj	j
|�|_tjj|j�|_
tjjj�|_||_|j�|_||_tjjjd|jd|jdd|jdtd|d|�|_tjj|j�|_tjj|jd	|j�|_tjj|j|j�|_d
S(uV
        :param IOLoop io_loop: io_loop used for events.
                               Pass in an io_loop if you want asynchronous
                               operation for obtaining events. Eg use of
                               set_event_handler() API. Otherwise,
                               operation will be synchronous.
        uP%s expects a file path not a directory path(%s) to its 'c_path' keyword argumentumasterusock_diru	transportRtlistenRt	keep_looptutilsN(Rtostpathtisdirtlogtwarningt	__class__t__name__RRRtpayloadtSerialtserialRtusertget_specific_usert	salt_userR
t_LocalClient__read_master_keytkeyRteventt	get_eventtFalsetloadertminion_modst	functionst	returners(tselfRRR
RRR((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt__init__�s.		

	!cC@sA|j}|dkrK|jjdd�dkrK|jjdd�}qKn|jd�rr|jjdd�}ntjjj�r�|jdd�}nt	j
j|jddj|��}yatjj
j|jd||j�tjjj|d�� }tjjj|j��SWd	QXWntttfk
r<d
SXd	S(u@
        Read in the rotating master authentication key
        urootuuserusudo_u\u_ucachediru.{0}_keyurNu(R*Rtgett
startswithRRtplatformt
is_windowstreplaceRRtjointformattverifytcheck_path_traversalR
tfilestfopentstringutilst
to_unicodetreadtOSErrortIOErrorR
(R4tkey_usertkeyfileR,((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt__read_master_key�s$	
#cC@s^tjj|jd�}y|j|�SWn-tjjk
rY}tdj|��gSXdS(u?
        convert a seco.range range into a list target
        urange_serveruRange server exception: {0}N(tsecotrangetRangeRtexpandtRangeExceptiontprintR<(R4ttgttrange_terr((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt_convert_range_to_list�scC@st|dkr|jdSt|t�r*|St|tj�riyt|�SWqitk
re|jdSXn|jdS(u+
        Return the timeout to use
        utimeoutN(tNoneRt
isinstancetintRtstring_typest
ValueError(R4ttimeout((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt_get_timeout�s
cK@s�tjd|�t|jd|jd��}|j|dd|gd|d|d||�}d|kr�|jj|d�n|S(	u:
        Return the information about a given job
        u(Checking whether jid %s is still runningugather_job_timeoutusaltutil.find_jobtargttgt_typeRXRujid(R!tdebugRUR6Rtrun_jobR-t	subscribe(R4tjidROR[RtkwargsRXtpub_data((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytgather_job_info�s			cC@s|dkrtd��nd|krMt|d�tjd|d�iSd|kr]iS|ddkr{td�iS|jjd�s�|d	s�td
�iSn|s�|S|jjd�r�|jjdj|d�d�n|jjd
j|d��|S(uX
        Common checks on the pub_data data structure returned from running pub
        uu�Failed to authenticate! This is most likely because this user is not permitted to execute commands, but there is a small possibility that a disk error occurred (check disk/inode usage).uerroru_check_pub_data() error: %sujidu0u<Failed to connect to the Master, is the Salt Master running?u
order_mastersuminionsuHNo minions matched the target. No command was sent, no jid was assigned.u
syndic/.*/{0}uregexusalt/job/{0}(	RRNR!R\RR6R-R^R<(R4RaR((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt_check_pub_data�s,


#uglobuc

K@s�tjjj||�}y=|j|||||d|d|j|�d|	|
�}Wnwtk
rttd��n[tk
r�}t|��n=tk
r�}t|��nt	k
r�}
t|
��nX|j
|d|	�S(u
        Asynchronously send a command to connected minions

        Prep the job directory and publish a command to any targeted minions.

        :return: A dictionary of (validated) ``pub_data`` or an empty
            dictionary on failure. The ``pub_data`` contains the job ID and a
            list of all minions that are expected to return data.

        .. code-block:: python

            >>> local.run_job('*', 'test.sleep', [300])
            {'jid': '20131219215650131543', 'minions': ['jerry']}
        R_RXRu:The salt master could not be contacted. Is master running?(RRtargstcondition_inputtpubRYR
RRt	ExceptionRc(R4ROtfunRZR[tretRXR_tkwargRR`RaRQtgeneral_exception((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR]+s,

cC@s/tjjj|j�j|d|�}|dS(NR[uminions(RRtminionst	CkMinionsRt
check_minions(R4ROt	expr_formt_res((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytgather_minionsas'ck@s�tjjj||�}yD|j|||||d|d|j|�d|
d|	|�V}Wnwtk
r{td��n[tk
r�}
t|
��n=tk
r�}
t|
��nt	k
r�}t|��nXt
jj|j
|d|	���dS(u
        Asynchronously send a command to connected minions

        Prep the job directory and publish a command to any targeted minions.

        :return: A dictionary of (validated) ``pub_data`` or an empty
            dictionary on failure. The ``pub_data`` contains the job ID and a
            list of all minions that are expected to return data.

        .. code-block:: python

            >>> local.run_job_async('*', 'test.sleep', [300])
            {'jid': '20131219215650131543', 'minions': ['jerry']}
        R_RXRRu:The salt master could not be contacted. Is master running?N(RRRdRet	pub_asyncRYR
RRRgttornadotgentReturnRc(R4RORhRZR[RiRXR_RjRRR`RaRQRk((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt
run_job_asynces.
c
K@sgtjjj||�}|j|||||d|dt|�}	y|	dSWntk
rbdSXdS(uT
        Asynchronously send a command to connected minions

        The function signature is the same as :py:meth:`cmd` with the
        following exceptions.

        :returns: A job ID or 0 on failure.

        .. code-block:: python

            >>> local.cmd_async('*', 'test.sleep', [300])
            '20131219215921857715'
        R_RujidiN(RRRdReR]R/tKeyError(
R4RORhRZR[RiR_RjR`Ra((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt	cmd_async�s		
icK@s�|j|dd||�}t|�}
tj|
�g}xD|
D]<}|||krg|j|�nt|�|krAPqAqAW|j}|r�|j}n||||ddd|d|d|	d|
|�S(u�
        Execute a command on a random subset of the targeted systems

        The function signature is the same as :py:meth:`cmd` with the
        following exceptions.

        :param sub: The number of systems to execute on
        :param cli: When this is set to True, a generator is returned,
                    otherwise a dictionary of the minion returns is returned

        .. code-block:: python

            >>> SLC.cmd_subset('*', 'test.ping', sub=1)
            {'jerry': True}
        usys.list_functionsR[ulistRiRjtprogresstfull_return(tcmdtlisttrandomtshuffletappendtlentcmd_cli(R4RORhRZR[RiRjtsubtcliRyRzR`t
minion_retRltf_tgttminiontfunc((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt
cmd_subset�s2		

	u10%ck@s�ddl}	ddl}	|	jjj||�}i|d6|d6|d6|d6|d6|d6|jd	|jjd	t��d	6|jd
t�d
6}
d|kr�|d|
d<nd|kr�|d|
d<nd
|kr�t|d
�|
d
<ni}d|kr|j	d�|d<nd|kr<|j	d�|d<nd|kr^|j	d�|d<nd|kr�|j	d�|d<nx9t
j|j�D]%\}}
||
kr�|
|
|<q�q�W|	jj
j|
d|dt�}x|j�D]}|Vq�WdS(u5
        Iteratively execute a command on subsets of minions at a time

        The function signature is the same as :py:meth:`cmd` with the
        following exceptions.

        :param batch: The batch identifier of systems to execute on

        :returns: A generator of minion returns

        .. code-block:: python

            >>> returns = local.cmd_batch('*', 'state.highstate', batch='10%')
            >>> for ret in returns:
            ...     print(ret)
            {'jerry': {...}}
            {'dave': {...}}
            {'stewart': {...}}
        iNutgtufunuargutgt_typeuretubatchufailhardurawutimeoutugather_job_timeoutu
batch_waitueauthuusernameupasswordutokenteauthtquiet(tsalt.utils.argstsalt.cli.batchRRdReR6RR/RUtpopRt	iteritemsR�tbatchtBatchtTruetrun(R4RORhRZR[RiRjR�R`RRR�R,tval((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt	cmd_batch�s@!
"!c
K@s>tjjj||	�}|jj}z�|j|||||||dt|
�}|s[|Si}x�|j|d|d|j	|�|||
�D]Q}
|
r�xBt
j|
�D].\}}|r�|n|jdi�||<q�Wq�q�Wx2t
t|d�t|��D]}t||<qW|SWd|s9|jj�nXdS(u�
        Synchronously execute a command on targeted minions

        The cmd method will execute and wait for the timeout period for all
        minions to reply, then it will return all minion data at once.

        .. code-block:: python

            >>> import salt.client
            >>> local = salt.client.LocalClient()
            >>> local.cmd('*', 'cmd.run', ['whoami'])
            {'jerry': 'root'}

        With extra keyword arguments for the command function to be run:

        .. code-block:: python

            local.cmd('*', 'test.arg', ['arg1', 'arg2'], kwarg={'foo': 'bar'})

        Compound commands can be used for multiple executions in a single
        publish. Function names and function arguments are provided in separate
        lists but the index values must correlate and an empty list must be
        used if no arguments are required.

        .. code-block:: python

            >>> local.cmd('*', [
                    'grains.items',
                    'sys.doc',
                    'cmd.run',
                ],
                [
                    [],
                    [],
                    ['uptime'],
                ])

        :param tgt: Which minions to target for the execution. Default is shell
            glob. Modified by the ``tgt_type`` option.
        :type tgt: string or list

        :param fun: The module and function to call on the specified minions of
            the form ``module.function``. For example ``test.ping`` or
            ``grains.items``.

            Compound commands
                Multiple functions may be called in a single publish by
                passing a list of commands. This can dramatically lower
                overhead and speed up the application communicating with Salt.

                This requires that the ``arg`` param is a list of lists. The
                ``fun`` list and the ``arg`` list must correlate by index
                meaning a function that does not take arguments must still have
                a corresponding empty list at the expected index.
        :type fun: string or list of strings

        :param arg: A list of arguments to pass to the remote function. If the
            function takes no arguments ``arg`` may be omitted except when
            executing a compound command.
        :type arg: list or list-of-lists

        :param timeout: Seconds to wait after the last minion returns but
            before all minions return.

        :param tgt_type: The type of ``tgt``. Allowed values:

            * ``glob`` - Bash glob completion - Default
            * ``pcre`` - Perl style regular expression
            * ``list`` - Python list of hosts
            * ``grain`` - Match based on a grain comparison
            * ``grain_pcre`` - Grain comparison with a regex
            * ``pillar`` - Pillar data comparison
            * ``pillar_pcre`` - Pillar data comparison with a regex
            * ``nodegroup`` - Match on nodegroup
            * ``range`` - Use a Range server for matching
            * ``compound`` - Pass a compound match string
            * ``ipcidr`` - Match based on Subnet (CIDR notation) or IPv4 address.

            .. versionchanged:: 2017.7.0
                Renamed from ``expr_form`` to ``tgt_type``

        :param ret: The returner to use. The value passed can be single
            returner, or a comma delimited list of returners to call in order
            on the minions

        :param kwarg: A dictionary with keyword arguments for the function.

        :param full_return: Output the job return only (default) or the full
            return including exit code and other job metadata.

        :param kwargs: Optional keyword arguments.
            Authentication credentials may be passed when using
            :conf_master:`external_auth`.

            For example: ``local.cmd('*', 'test.ping', username='saltdev',
            password='saltdev', eauth='pam')``.
            Or: ``local.cmd('*', 'test.ping',
            token='5871821ea51754fdcea8153c1c745433')``

        :returns: A dictionary with the result of the execution, keyed by
            minion ID. A compound command will return a sub-dictionary keyed by
            function name.
        RujiduminionsuretN(RRRdReR-tcpubR]R�tget_cli_event_returnsRYRR�R6R|tsetR/t	close_pub(R4RORhRZRXR[RiR_RzRjR`t
was_listeningRatfn_rettmidtdatatfailed((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR{As>r			
!'c


k@stjjj||�}|jj}z�|j||||||dt|
�|_|jse|jVn�y[xT|j	|jd|jd|j
|�||||	|
�D]}|s�q�n|Vq�WWn-tk
r�tdj
|jd���nXWd|s
|jj�nXdS(um
        Used by the :command:`salt` CLI. This method returns minion returns as
        they come back and attempts to block until all minions return.

        The function signature is the same as :py:meth:`cmd` with the
        following exceptions.

        :param verbose: Print extra information about the running command
        :returns: A generator
        Rujiduminionsu
This job's jid is: {0}
Exiting gracefully on Ctrl-c
The minions may not have all finished running and any remaining minions will return upon completion. To look up the return data for this job later, run the following command:

salt-run jobs.lookup_jid {0}N(RRRdReR-R�R]R�RaR�RYtKeyboardInterruptt
SystemExitR<R�(
R4RORhRZRXR[RitverboseRjRyR`R�R�((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR��sB		




c
k@s�tjjj||�}|jj}	z�|j||||||dt|�}
|
s\|
Vn||jd�rs|
VnxQ|j	|
d|
dd|j
|�d|d||�D]}|s�q�n|Vq�W|j|
d�Wd|	s�|jj�nXdS(	u�
        Yields the individual minion returns as they come in

        The function signature is the same as :py:meth:`cmd` with the
        following exceptions.

        Normally :py:meth:`cmd_iter` does not yield results for minions that
        are not connected. If you want it to return results for disconnected
        minions set `expect_minions=True` in `kwargs`.

        :return: A generator yielding the individual minion returns

        .. code-block:: python

            >>> ret = local.cmd_iter('*', 'test.ping')
            >>> for i in ret:
            ...     print(i)
            {'jerry': {'ret': True}}
            {'dave': {'ret': True}}
            {'stewart': {'ret': True}}
        Ruyield_pub_dataujiduminionsRXROR[N(
RRRdReR-R�R]R�R6tget_iter_returnsRYt_clean_up_subscriptionsR�(R4RORhRZRXR[RiRjR`R�RaR�((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytcmd_iters8	

	c
k@stjjj||�}|jj}z�|j||||||dt|
�}|s\|Vn�x�|j|d|dd|d|d|dt	|
�D]I}
|
r�t
||	g�r�x#|
D]}|d|
|d<q�Wn|
Vq�W|j|d�Wd|s
|jj�nXdS(	u�
        Yields the individual minion returns as they come in, or None
            when no returns are available.

        The function signature is the same as :py:meth:`cmd` with the
        following exceptions.

        :returns: A generator yielding the individual minion returns, or None
            when no returns are available. This allows for actions to be
            injected in between minion returns.

        .. code-block:: python

            >>> ret = local.cmd_iter_no_block('*', 'test.ping')
            >>> for i in ret:
            ...     print(i)
            None
            {'jerry': {'ret': True}}
            {'dave': {'ret': True}}
            None
            {'stewart': {'ret': True}}
        RujiduminionsRXROR[tblockN(
RRRdReR-R�R]R�R�R/tanyR�R�(R4RORhRZRXR[RiRjtshow_jidR�R`R�RaR�R�((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytcmd_iter_no_block^s8"	


	c	
K@s�tjjj||�}|jj}
zY|j||||||dt|	�}|sX|S|j|d|d||||�SWd|
s�|jj	�nXdS(u3
        Execute a salt command and return
        RujiduminionsN(
RRRdReR-R�R]R�tget_cli_static_event_returnsR�(R4RORhRZRXR[RiR�RjR`R�Ra((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytcmd_full_return�s,	
u*ck@s~|r:dj|�}	t|	�tdt|	�d�n|rVtdj|��n|dkrr|jd}ni}
t|�}t�}|j||d|�}|j|�}
|
ikr�|jt|
��|
Vnt|j	|��t|�krt
��nxo|D]g}|ikr<|jt|��|Vnt|j	|��t|�kr|j|�t
��qqWdS(u�
        Starts a watcher looking at the return data for a specified JID

        :returns: all of the information for the JID
        uExecuting job with jid {0}u-u
ujid: {0}utimeoutRXN(R<RNR�RSRR�tget_event_iter_returnstget_cache_returnstupdatetintersectiont
StopIterationR�(R4R_RlRXROR[R�R�R`tmsgtfrettfoundt
event_iterRiR-((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytget_cli_returns�s2
	!
!
c
c@sLxEtrG|jjddd|d|dtdtd|j�}|VqWdS(	u4
        Raw function to just return events of jid excluding timeout logic

        Yield either the raw event data or None

        Pass a list of additional regular expressions as `tags_regex` to search
        the event bus for non-return data, such as minion lists returned from
        syndics.
        twaitg{�G�z�?ttagt
match_typetfulltno_blockRN(R�R-R.R(R4R�R�traw((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytget_returns_no_block�s	$ck@s�t|t�s`t|tj�r3t|g�}q`t|ttf�r`tt|��}q`n|d%kr||jd}nt|j	d|jd��}	tt
j
��}
i}t�}t�}
yK|jdj|jd�|�ikrt
jd�iVt��nWn,tk
r>}t
jd|dtj�nXt}|jdrp|jd	j|�d
�}n|jdj|��}g}t�}t
j
�|}t
j
�|jd}t}t
jd
||tj|�j
��x%trx�|D]�}|d%krPnd|j	di�krr|j|dd�d|j	di�kr�|
j|dd�q�q�nd|dkr�q�n|j	dt�r�|j|dd�|Vq�|j|dd�ii|ddd6|dd6}d|dkr!|dd||ddd<nd|dkrR|dd||ddd<nd|dkr�|dd||ddd<n|j	dt�r�||ddj|d�nt
jd||dd�|Vq�Wt|j|��t|�kr|jdrt
jd||�Pnqt|j|��t|�kr�|jdr�t|�t|�kr�t|�dkr�t
j
�|kr�Pq�nx5||D])}||kr�t
j
�|||<q�q�Wt
j
�|kru|ru|j|t||�d|�}t}d|krg}n|jdj|d��}t
j
�|	}|jdru||jj	dd�7}qunx|D]}|d%kr�PnyI|dddkr�t
jd|dd�|j|dd�PnWnTt k
r1}|j!�j"d�}|dkrt
jd �q2t
jd!|�nX|j|d�d|j	di�krv|j|dd�q|nd"|j	di�kr�|j|d"�q|nd|j	di�kr�q|n|ddikr�q|nt|ddtj�r
t
jd#|�q|nd|ddkr?|dddikr?q|n|dd|krk|j|dd�nt
j
�|||dd<t}q|Wt
j
�}||ko�|}|r�x/||D] }|||kr�t}Pq�q�Wn|r�Pn|rt
j#d$�q�d%Vq�W|r;x!|D]}|j$j%|�qWn|rrx.t||�D]}iitd&6|6VqRWn|
|8}
|
r�x$|
D]}iitd&6|6Vq�Wnd%S('u�
        Watch the event system and return job data as it comes in

        :returns: all of the information for the JID
        utimeoutugather_job_timeoutu{0}.get_loadumaster_job_cacheujid does not existuReturner unavailable: %stexc_info_on_loglevelu
order_mastersu(salt/job|syndic/.*)/{0}uregexusalt/job/{0}usyndic_waitu9get_iter_returns for jid %s sent to %s will timeout at %suminionsudataumissingureturnurawuiduretuouturetcodeujidu	_cmd_metaujid %s return from %sujid %s found all minions %siulistiu&saltutil returning errors on minion %su'"u"retcode missing from client returnucPassing on saltutil error. Key '%s' missing from client return. This may be an error in the client.usyndicu!unexpected return from minion: %sg{�G�z�?Nufailed(&RTR�RRVR|ttupleRSRRUR6ttimeR3R<R!R"R�RgtloggingtDEBUGR/R�R�R\Rt
fromtimestampR�taddR�R�RbterrortremoveRwt__str__tstriptsleepR-tunsubscribe(R4R_RlRXROR[texpect_minionsR�R`tgather_job_timeouttstarttminion_timeoutsR�tmissingtexct	last_timetret_itert
jinfo_itert	open_jidst
timeout_attgather_syndic_waittminions_runningR�Ritid_tjinfotmissing_keytnowtdoneR�((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR�s
		)

		
$!!! 	/.<"	


	


cC@s*t|�}|dkr(|jd}nttj��}||}tjd||tj|�j��t�}i}y>|j	dj
|jd�|�ikr�tjd�|SWn2tk
r�}t
dj
|jd|���nXx8tr%|ttj��}	td|	�}
|jj|
|d|j�}|dk	r�d	|kr�|j|d
�|d	||d
<t|j|��t|�kr�tjd|�Pq�q�nt|j|��t|�kr�tjd|�Pnttj��|krtjd|||�Pntjd
�q�W|S(uU
        Get the returns for the command line interface via the event system
        utimeoutu4get_returns for jid %s sent to %s will timeout at %su{0}.get_loadumaster_job_cacheujid does not existuLMaster job cache returner [{0}] failed to verify jid. Exception details: {1}iRureturnuidujid %s found all minionsu(jid %s minions %s did not return in timeg{�G�z�?N(R�RSRRUR�R!R\RR�R3R<R"RgR
R�tmaxR-R.RR�R�R�tinfoR�(R4R_RlRXR�R�R�RiR�t	time_leftR�R�((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytget_returns�sL
	)
		!!cC@s�i}|j||d|�}y'|jdj|jd�|�}Wn2tk
ry}tdj|jd|���nXx�|D]�}i}	d||kr�||jd�|	d<n||jd�|	d<d||kr�||d|	d<n||kr||j|	�q�|	||<q�Wtt	|�j
|��t|�krL|Sx�|D]�}
|
ikrxtjd�qSnxGt
j|
�D]6\}}	||kr�||j|	�q�|	||<q�Wtt	|�j
|��t|�krS|SqSW|S(	u�
        This method starts off a watcher looking at the return data for
        a specified jid, it returns all of the information for the jid
        RXu{0}.get_jidumaster_job_cacheu=Returner {0} could not fetch jid data. Exception details: {1}ureturnuretuoutg{�G�z�?(R�R3R<RRgR
R6R�R�R�R�R�R�RR�(R4R_RlRXRiR�R�R�R�tm_datat	event_ret((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytget_full_returns.s>'	

'

'cC@s
i}y'|jdj|jd�|�}Wn2tk
ra}tdj|jd|���nXx�|D]�}i}d||kr�||jd�|d<n||jd�|d<d||kr�||d|d<n||kr�||j|�qi|||<qiW|S(uO
        Execute a single pass to gather the contents of the job cache
        u{0}.get_jidumaster_job_cacheuZCould not examine master job cache. Error occurred in {0} returner. Exception details: {1}ureturnuretuout(R3R<RRgR
R6R�(R4R_RiR�R�R�R�((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR�es$'	

c	C@s\tjd�t|�}|rSdj|�}	t|	�tdt|	�d�n|rotdj|��n|dkr�|jd}ntt	j	��}
|
|}t�}i}
y>|j
dj|jd�|�ikr�tjd	�|
SWn2tk
r(}t
d
j|jd|���nXxtrJ|tt	j	��}td|�}dj|�}|jj||d
|j�}|dk	rgd|krgd|jdi�kr�|j|dd�q,n|j|d�i|dd6|
|d<|jdt�|
|dd<d|kr<|d|
|dd<nt|j|��t|�kr,Pq,q,nt|j|��t|�kr�Pntt	j	��|kr:|s�|r6|jjdt�s�|dkr6t|�t|�kr3tt|j|���}x)|D]}idd6dd6|
|<qWq3q6nPnt	jd�q,W|j|�|
S(uU
        Get the returns for the command line interface via the event system
        u1entered - function get_cli_static_event_returns()uExecuting job with jid {0}u-u
ujid: {0}utimeoutu{0}.get_loadumaster_job_cacheujid does not existuELoad could not be retrieved from returner {0}. Exception details: {1}iusalt/job/{0}Rureturnuminionsudatauiduretusuccessuoutuminion_data_cacheuglobupcreulistu	no_returnuMinion did not returng{�G�z�?N(uglobupcreulist(R!ttraceR�R<RNR�RSRRUR�R3R"RgR
R�R�R-R.RR6R�R�R/R�tsortedR|t
differenceR�R�(R4R_RlRXROR[R�tshow_timeoutR�R�R�R�R�RiR�R�R�tjid_tagR�tfailR�((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR��sn



	)
	
	!!

c
k@s�tjd�|rGdj|�}t|�tdt|�d�n|	rctdj|��nd}d}
x�|j||d|d|d	|d
|
jdt�p�|p�||
�D]�}tj	d|�|
d
}
|r/xQt
j|�D]=\}}|jd�t
k	r�it|�d6|
d6Vq�q�Wnx9t
j|�D](\}}|jd�t
kr[|dkr�tjjj|j�j�}n|jdrtjj|j�jdj|�d�r|r||kriidd6dd6tjjjd6|6Vqgtjjtjj|jd|��sgiidd6dd6tjjjd6|6Vqgq?i||6Vq?Wq�W|j|�dS(uU
        Get the returns for the command line interface via the event system
        ufunc get_cli_event_returns()uExecuting job with jid {0}u-u
ujid: {0}iRXROR[R�uexpect_minionsureturn event: %siufaileduminion_countureturn_countuminion_data_cacheuminions/{0}udatau	no_returnuoutu&Minion did not return. [Not connected]ureturetcodeu
syndic_diru$Minion did not return. [No response]N(R!R�R<RNR�RSR�R�R/R\RR�R6R�RRRlRmRt
connected_idstcachetfactorytcontainstdefaultst	exitcodest
EX_GENERICRRtexistsR;R�(R4R_RlRXROR[R�RyR�R�R`R�tconnected_minionstreturn_countRiR�tmin_ret((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR��sV



#!
*(cc@sttjd�|dkr)|jd}ntj�|}t�}|jdj|jd�|�ikr�tjd�iVt	��nx�t
ro|jj|d|j
�}|dks�tj�|kr�Pnd|jdi�kr�q�ny1|j|d	�ii|d
d6|d	6}Wntk
r4q�nXd|krZ|d||d	d<n|Vtjd
�q�WdS(uk
        Gather the return data from the event system, break hard when timeout
        is reached.
        u+entered - function get_event_iter_returns()utimeoutu{0}.get_loadumaster_job_cacheujid does not existRuminionsudatauidureturnuretuoutg{�G�z�?N(R!R�RSRR�R�R3R<R"R�R�R-R.RR6R�RwR�(R4R_RlRXR�R�R�Ri((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR�s0
	)
	 
cK@s�|dkrw||jdkrO|jjdd�}	tdj||	���ntjjj||jd�}d}n|dkr�tr�|j	|�}d}n|jjd	�r�|r�|d
j|jd	�7}q�|jd	}nidd6|d
6|d6|d6|j
d6|d6|d6|d6}
|r:||
d<n|jdrdd|krd|d|
d<n|jr}|j|
d<n|jdr�||
d<n|
S(uI
        Set up the payload_kwargs to be sent down to the master
        u	nodegroupu
nodegroupsu	conf_fileuthe master config fileu!Node group {0} unavailable in {1}ucompoundurangeulistu
ext_job_cacheu,{0}upublishucmdutgtufunuargukeyutgt_typeuretujidukwargsu
syndic_masteruuseru
order_mastersuto(RR6RR<RRRltnodegroup_compt	HAS_RANGERRR,R*(R4RORhRZR[RiR_RXR`t	conf_filetpayload_kwargs((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt	_prep_pubDsD			



	

ic	
K@sd|jjdd�dkrdtjjtjj|jdd��rdtjd|jd�t�n|j	||||||||	�}
dt
jjj
|jd�d	tj|jd
�}t
jjjj|jddd
|�}yA|r|jjd|�rt��n|j|
d|�}
Wntk
rGtd��nX|
s�|j�}||jkrm|
S||_|j|
d<|j|
�}
n|
jdd�}|dk	r.t|t�r|jdd�}|jdd�}|dkrt|��q|dkrt|��qnt |��n|
s8|
S|j!�i|
ddd6|
ddd6S(u�
        Take the required arguments and publish the given command.
        Arguments:
            tgt:
                The tgt is a regex or a glob used to match up the ids on
                the minions. Salt works by always publishing every command
                to all of the minions and then the minions determine if
                the command is for them based on the tgt value.
            fun:
                The function name to be called on the remote host(s), this
                must be a string in the format "<modulename>.<function name>"
            arg:
                The arg option needs to be a tuple of arguments to pass
                to the calling function, if left blank
        Returns:
            jid:
                A string, as returned by the publisher, which is the job
                id, this will inform the client where to get the job results
            minions:
                A set, the targets that the tgt passed should match.
        uipc_modeuutcpusock_dirupublish_pull.ipcu4Unable to connect to the salt master publisher at %sutcp://u	interfaceu:uret_porttcryptucleart
master_uriRXufSalt request timed out. The master is not responding. You may need to run your command with `--async` in order to bypass the congested event bus. With `--async`, the CLI tool will print the job id (jid) and exit immediately without listening for responses. You can then use `salt-run jobs.lookup_jid` to look up the results of the job in the job cache later.ukeyuerrorunameumessageuAuthenticationErroruAuthorizationErroruloadujiduminionsN("RR6RRR�R;R!R�R
R�RRtzeromqt
ip_bracketRt	text_typet	transportRt
ReqChannelR�R-tconnect_pubR	tsendR+R,R�RSRTtdictRRRtclose(R4RORhRZR[RiR_RXRR`R�R�tchannelR%R,R�terr_nameterr_msg((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyRf�sb 
		8	

		

c

k@s�|jjdd�dkrdtjjtjj|jdd��rdtjd|jd�t�n|j	||||||||
�}dt
jjj
|jd�d	tj|jd
�}t
jjjj|jd|dd
d|�}
yB|	r|jjd|�rt��n|
j|d|�V}Wntk
rNtd��nX|s�|j�}||jkr�tjj|��n||_|j|d<|
j|�V}n|jdd�}|dk	rGt|t �r8|jdd�}|jdd�}|dkrt!|��q8|dkr8t"|��q8nt#|��n|sbtjj|��n|
j$�tjji|ddd6|ddd6��dS(u�
        Take the required arguments and publish the given command.
        Arguments:
            tgt:
                The tgt is a regex or a glob used to match up the ids on
                the minions. Salt works by always publishing every command
                to all of the minions and then the minions determine if
                the command is for them based on the tgt value.
            fun:
                The function name to be called on the remote host(s), this
                must be a string in the format "<modulename>.<function name>"
            arg:
                The arg option needs to be a tuple of arguments to pass
                to the calling function, if left blank
        Returns:
            jid:
                A string, as returned by the publisher, which is the job
                id, this will inform the client where to get the job results
            minions:
                A set, the targets that the tgt passed should match.
        uipc_modeuutcpusock_dirupublish_pull.ipcu4Unable to connect to the salt master publisher at %sutcp://u	interfaceu:uret_portRR�uclearR�RXufSalt request timed out. The master is not responding. You may need to run your command with `--async` in order to bypass the congested event bus. With `--async`, the CLI tool will print the job id (jid) and exit immediately without listening for responses. You can then use `salt-run jobs.lookup_jid` to look up the results of the job in the job cache later.ukeyuerrorunameumessageuAuthenticationErroruAuthorizationErroruloadujiduminionsN(%RR6RRR�R;R!R�R
R�RRR�R�RR�R�RtAsyncReqChannelR�R-R�R	R�R+R,RsRtRuR�RSRTRRRRR(R4RORhRZR[RiR_RXRRR`R�R�RR%R,R�RR((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyRr�sd"
		8	

		

cC@st|d�r|`ndS(Nuevent(thasattrR-(R4((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt__del__]scC@sN|jjd�r1|jjdj|�d�n|jjdj|��dS(Nu
order_mastersu
syndic/.*/{0}uregexusalt/job/{0}(RR6R-R�R<(R4tjob_id((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR�esN(((((((((((((-R$t
__module__t__doc__RRR;tsyspathst
CONFIG_DIRRSR/R5R+RRRYR�RbRcR]RqRsRtt	coroutineRvRxR�R�R{R�R�R�R�R�R�R�R�R�R�R�R�R�R�RfRrRR�(((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyRps�#			2,		1!/C�?<>$.�47	 LC%	Ga	b	tFunctionWrappercB@s2eZdZd�Zd�Zd�Zd�ZRS(u
    Create a function wrapper that looks like the functions dict on the minion
    but invoked commands on the minion via a LocalClient.

    This allows SLS files to be loaded with an object that calls down to the
    minion when the salt functions dict is referenced.
    cC@sNtt|�j�||_||_t|jd�|_|j�|_dS(Nu	conf_file(	tsuperRR5RR�Rtlocalt _FunctionWrapper__load_functionsR2(R4RR�((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR5ss
		cC@s%||jkrt�n|j|�S(u�
        Since the function key is missing, wrap this call to a command to the
        minion of said key if it is available in the self.functions set
        (R2Rwtrun_key(R4R,((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt__missing__zs	cC@s+t|jj|jd�j|jg��S(uE
        Find out what functions are available on the minion
        usys.list_functions(R�RR{R�R6(R4((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt__load_functions�sc@s��fd�}|S(uc
        Return a function that executes the arguments passed via the local
        client
        c@sUt|�}x-|D]%\}}|jdj||��qW�jj�j�|�S(u+
            Run a remote call
            u{0}={1}(R|RR<RR{R�(RdR`t_keyt_val(R,R4(s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR��s((R4R,R�((R,R4s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR�s(R$R	R
R5RRR(((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyRks
				tCallercB@sAeZdZejjejd�dd�Z	d�Z
d�ZRS(u�
    ``Caller`` is the same interface used by the :command:`salt-call`
    command-line tool on the Salt Minion.

    .. versionchanged:: 2015.8.0
        Added the ``cmd`` method for consistency with the other Salt clients.
        The existing ``function`` and ``sminion.functions`` interfaces still
        exist but have been removed from the docs.

    Importing and using ``Caller`` must be done on the same machine as a
    Salt Minion and it must be done using the same user that the Salt Minion is
    running as.

    Usage:

    .. code-block:: python

        import salt.client
        caller = salt.client.Caller()
        caller.cmd('test.ping')

    Note, a running master or minion daemon is not required to use this class.
    Running ``salt-call --local`` simply sets :conf_minion:`file_client` to
    ``'local'``. The same can be achieved at the Python level by including that
    setting in a minion config file.

    .. versionadded:: 2014.7.0
        Pass the minion config as the ``mopts`` dictionary.

    .. code-block:: python

        import salt.client
        import salt.config
        __opts__ = salt.config.minion_config('/etc/salt/minion')
        __opts__['file_client'] = 'local'
        caller = salt.client.Caller(mopts=__opts__)
    uminioncC@sOddl}|r||_n|jj|�|_|jj|j�|_dS(Ni(tsalt.minionRRt
minion_configR�tSMiniontsminion(R4RRR((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR5�s
cO@s|jj|||�S(uF
        Call an execution module with the given arguments and keyword arguments

        .. versionchanged:: 2015.8.0
            Added the ``cmd`` method for consistency with the other Salt clients.
            The existing ``function`` and ``sminion.functions`` interfaces still
            exist but have been removed from the docs.

        .. code-block:: python

            caller.cmd('test.arg', 'Foo', 'Bar', baz='Baz')

            caller.cmd('event.send', 'myco/myevent/something',
                data={'foo': 'Foo'}, with_env=['GIT_COMMIT'], with_grains=True)
        (RR2(R4RhRdR`((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR{�scO@sJ|jj|}tjj|tjjj|�|�\}}|||�S(u-
        Call a single salt function
        (RR2RR�tload_args_and_kwargsRRdtparse_input(R4RhRdR`R�((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pytfunction�s	N(R$R	R
RRR;RRRSR5R{R(((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR�s
%		tProxyCallercB@s8eZdZejjejd�dd�Z	d�Z
RS(u/
    ``ProxyCaller`` is the same interface used by the :command:`salt-call`
    with the args ``--proxyid <proxyid>`` command-line tool on the Salt Proxy
    Minion.

    Importing and using ``ProxyCaller`` must be done on the same machine as a
    Salt Minion and it must be done using the same user that the Salt Minion is
    running as.

    Usage:

    .. code-block:: python

        import salt.client
        caller = salt.client.Caller()
        caller.cmd('test.ping')

    Note, a running master or minion daemon is not required to use this class.
    Running ``salt-call --local`` simply sets :conf_minion:`file_client` to
    ``'local'``. The same can be achieved at the Python level by including that
    setting in a minion config file.

    .. code-block:: python

        import salt.client
        import salt.config
        __opts__ = salt.config.proxy_config('/etc/salt/proxy', minion_id='quirky_edison')
        __opts__['file_client'] = 'local'
        caller = salt.client.ProxyCaller(mopts=__opts__)

    .. note::

        To use this for calling proxies, the :py:func:`is_proxy functions
        <salt.utils.platform.is_proxy>` requires that ``--proxyid`` be an
        argument on the commandline for the script this is used in, or that the
        string ``proxy`` is in the name of the script.
    uproxycC@sCddl}|p!|jj|�|_|jj|j�|_dS(Ni(RRtproxy_configRR�tSProxyMinionR(R4RRR((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR5sc
O@s�|jj|}i|d6|d6}|j|�t|jdg�p[|jjddg�}t|tj�r||g}nx||D]t}dj	|�}||jj
kr�tdj	|���n|jj
||j||||�}	|	dk	r�Pq�q�W|	S(uF
        Call an execution module with the given arguments and keyword arguments

        .. code-block:: python

            caller.cmd('test.arg', 'Foo', 'Bar', baz='Baz')

            caller.cmd('event.send', 'myco/myevent/something',
                data={'foo': 'Foo'}, with_env=['GIT_COMMIT'], with_grains=True)
        uargufunumodule_executorsudirect_callu{0}.executeuExecutor '{0}' is not availableN(
RR2R�tgetattrRR6RTRRVR<t	executorsRRS(
R4RhRdR`R�R�R#tnametfnametreturn_data((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR{s"


%N(R$R	R
RRR;RRRSR5R{(((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyR�s%!(=R
t
__future__RRRRR�R}R�RRRt
salt.cachetsalt.defaults.exitcodestsalt.payloadtsalt.transport.clienttsalt.loaderR�tsalt.utils.eventtsalt.utils.filestsalt.utils.jidtsalt.utils.minionstsalt.utils.platformtsalt.utils.stringutilstsalt.utils.usertsalt.utils.verifytsalt.utils.zeromqt
salt.syspathsRtsalt.exceptionsRRRRRR	R
tsalt.extRR/R�t
seco.rangeRIR�tImportErrorttornado.genRst	getLoggerR$R!RR;RRSRtobjectRRRRR(((s8/usr/lib/python2.7/site-packages/salt/client/__init__.pyt<module>
sb4

�������/N

Zerion Mini Shell 1.0