Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/inventory/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/inventory/manager.pyc

�
�Udac@`s	ddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZmZmZddlmZddlmZdd	lmZmZdd
lmZddl m!Z!ddl"m#Z#dd
l$m%Z%ddl&m'Z'e'�Z(ddddgZ)gej*D]Z+ee+�^qaZ,gej-D]Z+dee	j.e+��^q�Z/e	j0dj1e)e,e/��Z2e	j0de	j3�Z4d�Z5d�Z6de7fd��YZ8dS(i(tabsolute_importtdivisiontprint_functionN(t
attrgetter(tshuffle(t	constants(tAnsibleErrortAnsibleOptionsErrortAnsibleParserError(t
InventoryData(tstring_types(tto_bytestto_text(t
parse_address(tinventory_loader(tdeduplicate_list(tunfrackpath(tDisplays^\.s^host_vars$s^group_vars$s^vars_plugins$s%s$t|s>^
        (.+)                    # A pattern expression ending with...
        \[(?:                   # A [subscript] expression comprising:
            (-?[0-9]+)|         # A single positive or negative number
            ([0-9]+)([:-])      # Or an x:y or x: range.
            ([0-9]*)
        )\]
        $
    cC`s�g}g}g}xg|D]_}|s+qn|ddkrK|j|�q|ddkrk|j|�q|j|�qW|gkr�dg}n|||S(sS takes a list of patterns and reorders them by modifier to apply them consistently it!t&tall(tappend(tpatternstpattern_regulartpattern_intersectiontpattern_excludetp((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pytorder_patterns@s
cC`s�t|t�r+ttjtt|���St|t�sOt|dd�}nd|krm|jd�}nWy%t	|dt
�\}}|g}Wn/tk
r�tj
td�|tj�}nXg|D]}|j�r�|j�^q�S(s�
    Takes a string containing host patterns separated by commas (or a list
    thereof) and returns a list of single patterns (which may not contain
    commas). Whitespace is ignored.

    Also accepts ':' as a separator for backwards compatibility, but it is
    not recommended due to the conflict with IPv6 addresses and host ranges.

    Example: 'a,b[1], c[2:3] , d' -> ['a', 'b[1]', 'c[2:3]', 'd']
    terrorstsurrogate_or_strictu,tallow_rangessJ(?:     # We want to match something comprising:
                        [^\s:\[\]]  # (anything other than whitespace or ':[]'
                        |           # ...or...
                        \[[^\]]*\]  # a single complete bracketed expression)
                    )+              # occurring once or more
                (t
isinstancetlistt	itertoolstchaintmaptsplit_host_patternR
RtsplitR
tTruet	ExceptiontretfindalltXtstrip(tpatternRtbasetportR((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR%\s

tInventoryManagercB`s1eZdZdd�Zed��Zed��Zed��Zddd�Z	d�Z
d�Zd�Zd	�Z
d
�Zed�Zed�Zd
�Zd�Zd�Zdeedd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Z RS(s Creates and manages inventory cC`s�||_t�|_d|_d|_i|_i|_|dkrQg|_n't	|t
�ro|g|_n	||_|jdt�dS(Ntcache(
t_loaderR	t
_inventorytNonet_restrictiont_subsett_hosts_patterns_cachet_pattern_cachet_sourcesR R
t
parse_sourcesR'(tselftloadertsources((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyt__init__�s						cC`s
|jjS(N(R3t	localhost(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR?�scC`s
|jjS(N(R3tgroups(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR@�scC`s
|jjS(N(R3thosts(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyRA�scC`s|jj|||�S(N(R3tadd_host(R;thosttgroupR/((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyRB�scC`s|jj|�S(N(R3t	add_group(R;RD((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyRE�scC`s
|jj�S(N(R3tget_groups_dict(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyRF�scC`s|j�|jj�S(N(tclear_cachesR3treconcile_inventory(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyRH�s
cC`s|jj|�S(N(R3tget_host(R;thostname((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyRI�scC`svtjd�g}xGtjD]<}tj|�}|rH|j|�qtjd|�qW|srtd��n|S(s, sets up loaded inventory plugins for usage ssetting up inventory pluginss,Failed to load inventory plugin, skipping %ssbNo inventory plugins available to generate inventory, make sure you have at least one whitelisted.(	tdisplaytvvvvtCtINVENTORY_ENABLEDRtgetRtwarningR(R;tpluginstnametplugin((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyt_fetch_inventory_plugins�s
cC`s�t}xf|jD][}|rd|kr=t|dt�}n|j|d|�}|rk|rkt}qkqqW|r�|jj�n%tjr�t	d��n
t
jd�dS(sA iterate over inventory sources and parse each one to populate itt,tfollowR1sENo inventory was parsed, please check your configuration and options.s=No inventory was parsed, only implicit localhost is availableN(tFalseR9Rtparse_sourceR'R3RHRMtINVENTORY_UNPARSED_IS_FAILEDRRKRP(R;R1tparsedtsourcetparse((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR:�s
	c	C`s�t}tjd|�t|�}tjj|�r�tjd|�xFttj|��D]�}tjd|�t	j
|�r�q\nttjj||�dd�}|j
|d|�}tjd||f�|s\|}q\q\Wn�||j_g}x�|j�D]�}	tt|	dt|	d	d
���}
tjd|
|	jf�yt|	j|��}Wntk
r�t}nX|r�yc|	j|j|j|d|�y|	j�Wntk
r�nXt}tjd||
f�PWq�tk
ra}tjd
||
f�d
jtjtj �d��}
|j!i|d6|
d6|d6|
d6�q�tk
r�}tjd|
|f�d
jtjtj �d��}
|j!i|d6|
d6t"|�d6|
d6�q�Xq
tjd|
|f�q
W|r�|r�xf|D]^}tj#dt|d�|dt|d�f�d|krtjt|d��qqWt$j%r�t"d|��q�n|s�|dks�tjj&|�r�tj#d|�q�nd|j_|S(s6 Generate or update inventory for the source provided u'Examining possible inventory source: %su.Searching for inventory files in directory: %suConsidering %sRRR1uparsed %s as %st
_load_namet_original_pathtu Attempting to use plugin %s (%s)s)Parsed %s inventory source with %s plugins%s was not parsable by %sitsrcRStexcttbs&%s failed while attempting to parse %ssB%s declined parsing %s as it did not pass its verify_file() methodu(
* Failed to parse %s with %s plugin: %su.Completely failed to parse inventory source %ss/etc/ansible/hostss)Unable to parse %s as an inventory sourceN((RWRKtdebugRtostpathtisdirtsortedtlistdirtIGNOREDtsearchRtjoinRXR3tcurrent_sourceRTtgetattrR^tbooltverify_fileR(R\R2tupdate_cache_if_changedtAttributeErrorR'tvvvRt	tracebackt	format_tbtsystexc_infoRRRPRMt INVENTORY_ANY_UNPARSED_IS_FAILEDtexistsR4(R;R[R1RZtb_sourcetitfullpathtparsed_this_onetfailuresRStplugin_nametplugin_wantsteRbtfail((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyRX�sl!$


","6

2	cC`si|_i|_dS(s clear all caches N(R7R8(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyRG>s	cC`s*|j�t�|_|jdt�dS(s recalculate inventory R1N(RGR	R3R:RW(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pytrefresh_inventoryDs
cC`s�yB|ddks.tjtj|��}ntj|d�}Wn!tk
retd|��nXg}x-|D]%}|j|�rs|j|�qsqsW|S(Nit~isInvalid host list pattern: %s(R)tcompiletfnmatcht	translateR(RtmatchR(R;titemstpattern_strR-tresultstitem((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyt_match_listKs

RcC`sg}t|t�r|}n	|g}|r|rQ|jrQ|j|j�n|rt|jrt|j|j�nt|�}||jkr^t|�}|j|�|(|r	|jr	t	d�|j|j�D��}	g|D]}
|
j
|	kr�|
^q�|(n|rH|jrHg|D]}
|
j|jkr |
^q |(nt|�|j|<n|d
kr�t
|j|dtd�d|dk�|(q|dkr�|j|ddd	�|(q|j||(|d
kr�t|�q|dkrtd|��qn|S(s�
        Takes a pattern or list of patterns and returns a list of matching
        inventory host names, taking into account any active restrictions
        or applied subsets
        cs`s|]}|jVqdS(N(t_uuid(t.0ts((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pys	<genexpr>~sRgtreverse_sortedtkeyRRtreversetreverse_inventoryNi����Rt	inventorys1Invalid 'order' specified for inventory hosts: %s(ssortedR�(NR�(R R!R6textendR5ttupleR7R%t_evaluate_patternstsetR�RRRRgRRR4R(R;R-t
ignore_limitstignore_restrictionstorderRAtpattern_listtpattern_hashRtsubset_uuidsth((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyt	get_hosts\s:
	",/0
cC`s1t|�}g}x|D]}||jjkrM|j|jj|��q|j|�}|ddkr�t|�}g|D]}||kr|^q}q|ddkr�t|�}g|D]}||kr�|^q�}qtd�|D��}|jg|D]}|j|kr|^q�qW|S(s�
        Takes a list of patterns and returns a list of matching host names,
        taking into account any negative and intersection patterns.
        iRRcs`s|]}|jVqdS(N(RR(R�ty((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pys	<genexpr>�s(	RR3RARRIt_match_one_patternR�R�RR(R;RRARtthatR�texisting_hosts((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR��s
((3cC`s�|ddkr|d}n||jkr�|j|�\}}|j|�}y|j||�}Wn!tk
r�td|��nX||j|<n|j|S(s�
        Takes a single pattern and returns a list of matching host names.
        Ignores intersection (&) and exclusion (!) specifiers.

        The pattern may be:

            1. A regex starting with ~, e.g. '~[abc]*'
            2. A shell glob pattern with ?/*/[chars]/[!chars], e.g. 'foo*'
            3. An ordinary word that matches itself only, e.g. 'foo'

        The pattern is matched using the following rules:

            1. If it's 'all', it matches all hosts in all groups.
            2. Otherwise, for each known group name:
                (a) if it matches the group name, the results include all hosts
                    in the group or any of its children.
                (b) otherwise, if it matches any hosts in the group, the results
                    include the matching hosts.

        This means that 'foo*' may match one or more groups (thus including all
        hosts therein) but also hosts in other groups.

        The built-in groups 'all' and 'ungrouped' are special. No pattern can
        match these group names (though 'all' behaves as though it matches, as
        described above). The word 'ungrouped' can match a host of that name,
        and patterns like 'ungr*' and 'al*' can match either hosts or groups
        other than all and ungrouped.

        If the pattern matches one or more group names according to these rules,
        it may have an optional range suffix to select a subset of the results.
        This is allowed only if the pattern is not a regex, i.e. '~foo[1]' does
        not work (the [1] is interpreted as part of the regex), but 'foo*[1]'
        would work if 'foo*' matched the name of one or more groups.

        Duplicate matches are always eliminated from the results.
        iRRis-No hosts matched the subscripted pattern '%s'(RR(R8t_split_subscriptt_enumerate_matchest_apply_subscriptt
IndexErrorR(R;R-texprtsliceRA((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR��s&

cC`s�|ddkr|dfSd}tj|�}|r�|j�\}}}}}|rkt|�df}q�|szd}nt|�t|�f}|dkr�tjd�q�n||fS(sa
        Takes a pattern, checks if it has a subscript, and returns the pattern
        without the subscript and a (start,end) tuple representing the given
        subscript (or None if there is no subscript).

        Validates that the subscript is in the right syntax, but doesn't make
        sure the actual indices make sense in context.
        iR�i����t-sFUse [x:y] inclusive subscripts instead of [x-y] which has been removedN(R4tPATTERN_WITH_SUBSCRIPTR�R@tintRKRP(R;R-t	subscripttmtidxtstarttseptend((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR��s
	cC`sa|s|r|S|\}}|rR|dkrCt|�d}n|||d!S||gSdS(s�
        Takes a list of hosts and a (start,end) tuple and returns the subset of
        hosts based on the subscript (which may be None to return all hosts).
        i����iN(tlen(R;RAR�R�R�((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR�sc	`s�g}|j|jj��}|rUx.|D]#}|j|jj|j��q+Wn|s��ddks�t�fd�dD��r�|j|jj��}|r�x(|D]}|j|jj|�q�Wq�n|r�tj	kr|jj
��}|r|j|�qn|r�|r��dkr�d	�}tj|�tj
d
kretj|�q�tj
dkr�t|��q�n|S(
s�
        Returns a list of host names matching the given pattern according to the
        rules explained above in _match_one_pattern.
        iR�c3`s|]}|�kVqdS(N((R�tspecial(R-(s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pys	<genexpr>$st.t?t*t[Rs3Could not match supplied host pattern, ignoring: %sRPterror(R�R�R�R�(R�R3R@R�R�tanyRARRMt	LOCALHOSTRIRKRctHOST_PATTERN_MISMATCHRPR(	R;R-R�tmatching_groupst	groupnametmatching_hostsRJtimplicittmsg((R-s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR�s,
$3
!

cC`sSg|j|�D]}|^q}t|�dkrO|tjkrO|g}n|S(s* return a list of hostnames for a pattern i(R�R�RMR�(R;R-R�tresult((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyt
list_hosts=s"!cC`st|jjj�dd��S(NR�cS`s|S(N((tx((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyt<lambda>Js(RgR3R@tkeys(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pytlist_groupsHscC`sH|dkrdSt|t�s+|g}ntd�|D��|_dS(s�
        Restrict list operations to the hosts given in restriction.  This is used
        to batch serial operations in main playbook code, don't use this for other
        reasons.
        Ncs`s|]}t|j�VqdS(N(RRR(R�R�((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pys	<genexpr>Vs(R4R R!R�R5(R;trestriction((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pytrestrict_to_hostsLs
cC`s�|dkrd|_n�t|�}g}x�|D]�}|ddkr�t|d�}|jg|j�jd�D]}t|j��^qs�|j	�q1|j
t|��q1W||_dS(s0
        Limits inventory results to a subset of inventory that matches a given
        pattern, such as to select a given geographic of numeric slice amongst
        a previous 'hosts' selection that only select roles, or vice versa.
        Corresponds to --limit parameter to ansible-playbook
        it@is
N(R4R6R%topenR�treadR&RR,tcloseR(R;tsubset_patterntsubset_patternsR�R�tfdtl((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pytsubsetXs
;
cC`s
d|_dS(s! Do not restrict list operations N(R4R5(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pytremove_restrictionnscC`s
i|_dS(N(R8(R;((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pytclear_pattern_cachersN(!t__name__t
__module__t__doc__R4R>tpropertyR?R@RARBRERFRHRIRTRWR:RXRGR�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyR0�s8					U			9		4	!		'				(9t
__future__RRRttypet
__metaclass__R�RdRuR)R"RstoperatorRtrandomRtansibleRRMtansible.errorsRRRtansible.inventory.dataR	tansible.module_utils.sixR
tansible.module_utils._textRRtansible.parsing.utils.addressesR
tansible.plugins.loaderRtansible.utils.helpersRtansible.utils.pathRtansible.utils.displayRRKtIGNORED_ALWAYStINVENTORY_IGNORE_PATTERNSR�tIGNORED_PATTERNStINVENTORY_IGNORE_EXTStescapetIGNORED_EXTSR�RkRiR+R�RR%tobjectR0(((s=/usr/lib/python2.7/site-packages/ansible/inventory/manager.pyt<module>s:	"/ 			,

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]