%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/roster/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/roster/sshconfig.pyo

�
���^c@@s!dZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlm
Z
ddlZeje�Zejdddg�Zedd	d
d�eddd
d
�eddd
d�fZd�Zd�Zdd�Zdefd��YZdS(u�
Parses roster entries out of Host directives from SSH config

.. code-block:: bash

    salt-ssh --roster sshconfig '*' -r "echo hi"
i(tabsolute_importtprint_functiontunicode_literalsN(tsixu
_SSHConfRegexutarget_fieldupatternttarget_fielduusertpatternu\s+User (.*)uportu\s+Port (.*)uprivu\s+IdentityFile (.*)cC@sa|jd�}tjj|�s0td��ntj|tj�s]tdj|���n|S(uL
    :return: Path to the .ssh/config file - usually <home>/.ssh/config
    ussh_config_fileuCannot find SSH config fileu!Cannot access SSH config file: {}(tgettostpathtisfiletIOErrortaccesstR_OKtformat(toptstssh_config_file((s9/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyt_get_ssh_config_file!scC@s�g}xo|D]g}tjjj|�}|s
|jd�rDq
n|jd�rc|jg�n|dj|�q
Wtj�}x�|D]�}tj�}|dj�d}xW|dD]K}xBt	D]:}t
j|j|�}|r�|j
d�||j<q�q�Wq�Wx|D]}	|||	<qWq�Wg}
g}xI|j�D];}d|ksad|krq|
j|�qC|j|�qCWxP|
D]H}x8|D]0}
tj|
|�r�||
j||�q�q�W||=q�Wx|D]}|||d<q�W|S(	u�
    Parses lines from the SSH config to create roster targets.

    :param lines: Individual lines from the ssh config file
    :return: Dictionary of targets in similar style to the flat roster
    u#uHost i����iiu*u?uhost(tsalttutilststringutilst
to_unicodet
startswithtappendtcollectionstOrderedDicttsplitt_ROSTER_FIELDStretmatchRtgroupRtkeystfnmatchtupdate(tlinesthoststlinettargetst	host_datattargett	hostnamestfieldRthostnametwildcard_targetstnon_wildcard_targetsRt	candidate((s9/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pytparse_ssh_config-sB	


!



uglobc	K@sttt�}tjjj|d��,}tg|D]}|j�^q1�}WdQXt|||�}|j	�}|S(us
    Return the targets from the flat yaml file, checks opts for location but
    defaults to /etc/salt/roster
    urN(
Rt__opts__RRtfilestfopenR-trstript
RosterMatcherR$(	ttgtttgt_typetkwargsRtfpR#tall_minionstrmatchertmatched((s9/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyR$as+R2cB@s2eZdZd�Zd�Zd�Zd�ZRS(u/
    Matcher for the roster data structure
    cC@s||_||_||_dS(N(R3R4traw(tselfR:R3R4((s9/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyt__init__rs		cC@s9y t|dj|j���SWntk
r4iSXdS(uA
        Execute the correct tgt_type routine and return
        uret_{0}_minionsN(tgetattrR
R4tAttributeError(R;((s9/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyR$ws 
cC@sXi}xK|jD]@}tj||j�r|j|�}|rP|||<qPqqW|S(u4
        Return minions that match via glob
        (R:RR3tget_data(R;tminionstminiontdata((s9/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pytret_glob_minions�scC@sPt|j|tj�r+i|j|d6St|j|t�rL|j|StS(u*
        Return the configured ip
        uhost(t
isinstanceR:Rtstring_typestdicttFalse(R;RA((s9/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyR?�s
(t__name__t
__module__t__doc__R<R$RCR?(((s9/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyR2ns
				(RJt
__future__RRRRRRRtsalt.utils.filesRtsalt.utils.stringutilstsalt.extRtloggingt	getLoggerRHtlogt
namedtuplet
_SSHConfRegexRRR-R$tobjectR2(((s9/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyt<module>s$		4

Zerion Mini Shell 1.0