%PDF- %PDF-
| Direktori : /proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/roster/ |
| Current File : //proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyo |
�
���^c @@ s! d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l Z d d l Z
d d l Z
d d l m
Z
d d l Z e j e � Z e j d d d g � Z e d d d
d � e d d d
d
� e d d d
d � f Z d � Z d � Z d d � Z d e f d � � YZ d S( u�
Parses roster entries out of Host directives from SSH config
.. code-block:: bash
salt-ssh --roster sshconfig '*' -r "echo hi"
i ( t absolute_importt print_functiont unicode_literalsN( t sixu
_SSHConfRegexu target_fieldu patternt target_fieldu usert patternu \s+User (.*)u portu \s+Port (.*)u privu \s+IdentityFile (.*)c C@ sa | j d � } t j j | � s0 t d � � n t j | t j � s] t d j | � � � n | S( uL
:return: Path to the .ssh/config file - usually <home>/.ssh/config
u ssh_config_fileu Cannot find SSH config fileu! Cannot access SSH config file: {}( t gett ost patht isfilet IOErrort accesst R_OKt format( t optst ssh_config_file( ( s9 /usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyt _get_ssh_config_file! s c C@ s� g } xo | D]g } t j j j | � } | s
| j d � rD q
n | j d � rc | j g � n | d j | � q
Wt j � } x� | D]� } t j � } | d j � d } xW | d D]K } xB t D]: } t
j | j | � } | r� | j
d � | | j <q� q� Wq� Wx | D] } | | | <qWq� Wg }
g } xI | j � D]; } d | k sad | k rq|
j | � qC| j | � qCWxP |
D]H } x8 | D]0 }
t j |
| � 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 #u Host i����i i u *u ?u host( t saltt utilst stringutilst
to_unicodet
startswitht appendt collectionst OrderedDictt splitt _ROSTER_FIELDSt ret matchR t groupR t keyst fnmatcht update( t linest hostst linet targetst host_datat targett hostnamest fieldR t hostnamet wildcard_targetst non_wildcard_targetsR t candidate( ( s9 /usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyt parse_ssh_config- sB
!
u globc K@ st t t � } t j j j | d � �, } t g | D] } | j � ^ q1 � } Wd QXt | | | � } | j � } | S( us
Return the targets from the flat yaml file, checks opts for location but
defaults to /etc/salt/roster
u rN(
R t __opts__R R t filest fopenR- t rstript
RosterMatcherR$ ( t tgtt tgt_typet kwargsR t fpR# t all_minionst rmatchert matched( ( s9 /usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyR$ a s +R2 c B@ s2 e Z d Z d � Z d � Z d � Z d � Z RS( u/
Matcher for the roster data structure
c C@ s | | _ | | _ | | _ d S( N( R3 R4 t raw( t selfR: R3 R4 ( ( s9 /usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyt __init__r s c C@ s9 y t | d j | j � � � SWn t k
r4 i SXd S( uA
Execute the correct tgt_type routine and return
u ret_{0}_minionsN( t getattrR
R4 t AttributeError( R; ( ( s9 /usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyR$ w s
c C@ sX i } xK | j D]@ } t j | | j � r | j | � } | rP | | | <qP q q W| S( u4
Return minions that match via glob
( R: R R3 t get_data( R; t minionst miniont data( ( s9 /usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyt ret_glob_minions� s c C@ sP t | j | t j � r+ i | j | d 6St | j | t � rL | j | St S( u*
Return the configured ip
u host( t
isinstanceR: R t string_typest dictt False( R; RA ( ( s9 /usr/lib/python2.7/site-packages/salt/roster/sshconfig.pyR? � s
( t __name__t
__module__t __doc__R<