%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sodZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl
Z
ddlZ
ddlZ
ddlmZddlmZedddd	d
ddg�Zd
gZeje�Zd�Zd�Zd�Zd�Zedd�Z d�Z!ded�Z"d�Z#d�Z$dded�Z%d�Z&dS(up
The function cache system allows for data to be stored on the master so it can be easily read by other minions
i(tabsolute_importtprint_functiontunicode_literalsN(tSaltClientError(tsixu
__pub_useru	__pub_argu	__pub_funu	__pub_jidu	__pub_tgtu__pub_tgt_typeu	__pub_retu*cC@sRdtkrJytjjt�td<WqJtk
rFtjd�qJXntdS(u 
    Return the auth object
    uauthuECould not authenticate with master.Mine data will not be transmitted.(t__context__tsalttcrypttSAutht__opts__Rtlogterror(((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pyt_auth(s
cC@s$|tkr tjd|�tStS(Nu+Function %s in mine_functions not available(t__salt__R
RtFalsetTrue(tfunc((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pyt_mine_function_available5scC@s>tjjj|dt�}|j|d�}tjd�|S(Ntlistenu_minion_mineg�?(RtutilsteventtMinionEventRt
fire_eventttimetsleep(tloadtoptsteventert	event_ret((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pyt
_mine_send<s
cC@s�|jdd�dkrWyt�jd�|d<WqWtk
rStjd�tSXntjj	j
j|�}z|j|�}Wd|j
�X|S(	Nu	transportuuzeromqutcpRutokuEMine could not authenticate with master. Mine could not be retrieved.(uzeromqutcp(tgetRt	gen_tokentAttributeErrorR
RRRt	transporttclientt
ReqChanneltfactorytsendtclose(RRtchanneltret((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pyt	_mine_getEs

c		C@s�i}|s,tddi�}|s|dSnP|rZt|t�rZtd�|D��}n"|rxt|t�rx|}ndSi}xy|D]q}y(||r�t||t�r�||jd|�}t|�s�w�nt|||�||<n�||r�t||t�r�|}t||dt�rfd||dkrf||dd}||jd�nt|�sxw�nt|||�||<n#t|�s�w�nt|�||<Wq�tk
r�tj�}t	j
d|�t	jd|�q�q�Xq�Wtd	d
kr]|sLtdd�}t|t�rL|j
|�|}qLntd
d|�Sidd6|d6tdd6|d6}t|t�S(u
    Execute the configured functions and send the data back up to the master.
    The functions to be executed are merged from the master config, pillar and
    minion config under the option `mine_functions`:

    .. code-block:: yaml

        mine_functions:
          network.ip_addrs:
            - eth0
          disk.usage: []

    This function accepts the following arguments:

    clear: False
        Boolean flag specifying whether updating will clear the existing
        mines, or will update. Default: `False` (update).

    mine_functions
        Update the mine data on certain functions only.
        This feature can be used when updating the mine for functions
        that require refresh at different intervals than the rest of
        the functions specified under `mine_functions` in the
        minion/master config or pillar.
        A potential use would be together with the `scheduler`, for example:

        .. code-block:: yaml

            schedule:
              lldp_mine_update:
                function: mine.update
                kwargs:
                    mine_functions:
                      net.lldp: []
                hours: 12

        In the example above, the mine for `net.lldp` would be refreshed
        every 12 hours, while  `network.ip_addrs` would continue to be updated
        as specified in `mine_interval`.

    The function cache will be populated with information from executing these
    functions

    CLI Example:

    .. code-block:: bash

        salt '*' mine.update
    uconfig.mergeumine_functionsNcs@s|]}|ifVqdS(N((t.0tfun((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pys	<genexpr>�su
mine_functioniu/Function %s in mine_functions failed to executeu	Error: %sufile_clientulocaludata.getu
mine_cacheudata.updateu_mineucmdudatauiduclear(R
t
isinstancetlisttdicttpopRt	Exceptiont	tracebackt
format_excR
RtdebugR	tupdateR(	tcleartmine_functionstm_datatdataRt	mine_functtracetoldR((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pyR4Vs^2	
+


cO@s	tjjj|�}|jd|�}|tkr7tSi}tjjjt|�}tj	|�}xTt
|jdg��D]:\}}y||||d|<Wq~tk
r�q~Xq~Wtjjj
t||dt�}	x2|D]*}
|
|	dkr�|	dj|
�q�q�WyJd|	krDt||	d|	d�||<nt||	d�||<Wn'tk
r�}tjd||�tSXtddkr�tdd	�}t|t�r�|j|�|}ntd
d	|�Sidd6|d
6tdd6}
t|
t�S(u�
    Send a specific function to the mine.

    CLI Example:

    .. code-block:: bash

        salt '*' mine.send network.ip_addrs eth0
        salt '*' mine.send eth0_ip_addrs mine_function=network.ip_addrs eth0
    u
mine_functionuargstexpected_extra_kwsukwargsu.Function %s in mine.send failed to execute: %sufile_clientulocaludata.getu
mine_cacheudata.updateu_mineucmdudatauid(RRtargstclean_kwargsR/R
Rt
arg_lookuptcopytdeepcopyt	enumerateRt
IndexErrortformat_calltMINE_INTERNAL_KEYWORDStappendR0R
RR	R,R.R4R(RR=tkwargsR9R8targ_datat	func_datatindt_tf_calltargtexcR;R((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pyR%�sL%
	
"	

	uglobcC@s=tddkr�i}i	tdd6tdd6tdd6td	d
6tdd6td
d6tdd6tdd6tdd6||�}|r�tdd�}t|t�r�||kr�|||td<q�n|Sidd6tdd6|d6|d6|d6}t|t�}|r9td|kr9|td=q9n|S(u�
    Get data from the mine based on the target, function and tgt_type

    Targets can be matched based on any standard matching system that can be
    matched on the master via these keywords:

    - glob
    - pcre
    - grain
    - grain_pcre
    - compound
    - pillar
    - pillar_pcre

    Note that all pillar matches, whether using the compound matching system or
    the pillar matching system, will be exact matches, with globbing disabled.

    exclude_minion
        Excludes the current minion from the result set

    CLI Example:

    .. code-block:: bash

        salt '*' mine.get '*' network.interfaces
        salt '*' mine.get 'os:Fedora' network.interfaces grain
        salt '*' mine.get 'G@os:Fedora and S@192.168.5.0/24' network.ipaddrs compound

    .. seealso:: Retrieving Mine data from Pillar and Orchestrate

        This execution module is intended to be executed on minions.
        Master-side operations such as Pillar or Orchestrate that require Mine
        data should use the :py:mod:`Mine Runner module <salt.runners.mine>`
        instead; it can be invoked from a Pillar SLS file using the
        :py:func:`saltutil.runner <salt.modules.saltutil.runner>` module. For
        example:

        .. code-block:: jinja

            {% set minion_ips = salt.saltutil.runner('mine.get',
                tgt='*',
                fun='network.ip_addrs',
                tgt_type='glob') %}
    ufile_clientulocalu
match.globuglobu
match.pcreupcreu
match.listulistumatch.grainugrainumatch.grain_pcreu
grain_pcreumatch.ipcidruipcidrumatch.compounducompoundumatch.pillarupillarumatch.pillar_pcreupillar_pcreudata.getu
mine_cacheuidu	_mine_getucmdutgtufunutgt_type(R	R
R,R.R)(ttgtR+ttgt_typetexclude_minionR(t	is_targetR8R((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pyR�s80

cC@s�tddkrVtdd�}t|t�rE||krE||=ntdd|�Sidd6tdd6|d	6}t|t�S(
u�
    Remove specific function contents of minion. Returns True on success.

    CLI Example:

    .. code-block:: bash

        salt '*' mine.delete 'network.interfaces'
    ufile_clientulocaludata.getu
mine_cacheudata.updateu_mine_deleteucmduidufun(R	R
R,R.R(R+R8R((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pytdeleteDs


cC@sFtddkr!tddi�Sidd6tdd6}t|t�S(u�
    Remove all mine contents of minion. Returns True on success.

    CLI Example:

    .. code-block:: bash

        salt '*' mine.flush
    ufile_clientulocaludata.updateu
mine_cacheu_mine_flushucmduid(R	R
R(R((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pytflush[s
cC@s�|r:g}|jt|t�r'|n|g�|}n|rtg}|jt|t�ra|n|g�|}nd}td|�}i}x�tj|�D]�}|jd�}	g}
|sx�tj|	d�D];}d|kr�x&|dD]}|
j|d�q�Wq�q�Wnixf|D]^}
|
|	dkrd|	d|
kr{x.|	d|
dD]}|
j|d�qZWq{qqWtt|
��}
|r�g}xJ|D]B}x9|
D]1}t	j
jj||g�r�|j|�q�q�Wq�Wtt|��}
nx�tj|�D]t}|dd}|d	|krDi||d	<nx<|d
D]0}|jd�}|dkr�x|
D]}}||d	j
d
i�j
|dg�}dj||d�}|r�||f}n|}||krw|j|�qwqwWqO|rO||d	j
d
i�j
|dg�}dj|d|d�}|rZ||f}n|}||kr|j|�qqOqOWqWq�W|S(u�
    .. versionchanged:: 2017.7.8,2018.3.3
        When :conf_minion:`docker.update_mine` is set to ``False`` for a given
        minion, no mine data will be populated for that minion, and thus none
        will be returned for it.
    .. versionchanged:: 2019.2.0
        :conf_minion:`docker.update_mine` now defaults to ``False``

    Get all mine data for :py:func:`docker.ps <salt.modules.dockermod.ps_>` and
    run an aggregation routine. The ``interfaces`` parameter allows for
    specifying the network interfaces from which to select IP addresses. The
    ``cidrs`` parameter allows for specifying a list of subnets which the IP
    address must match.

    with_container_id
        Boolean, to expose container_id in the list of results

        .. versionadded:: 2015.8.2


    CLI Example:

    .. code-block:: bash

        salt '*' mine.get_docker
        salt '*' mine.get_docker interfaces='eth0'
        salt '*' mine.get_docker interfaces='["eth0", "eth1"]'
        salt '*' mine.get_docker cidrs='107.170.147.0/24'
        salt '*' mine.get_docker cidrs='["107.170.147.0/24", "172.17.42.0/24"]'
        salt '*' mine.get_docker interfaces='["eth0", "eth1"]' cidrs='["107.170.147.0/24", "172.17.42.0/24"]'
    u	docker.psu*uhostu
interfacesuinetuaddressuInfouIduImageuPortsuIPu0.0.0.0uipv4uPrivatePortu{0}:{1}u
PublicPort(textendR,R-RRt
itervaluesR/RFtsetRRtnetworkt	in_subnett
setdefaulttformat(t
interfacestcidrstwith_container_idt
interface_tcidr_tcmdtdocker_hoststproxy_listst
containersthostthost_ipstinfotip_t	interfacetitemtgood_ipstcidrt	containertcontainer_idt	dock_portt
ip_addresstcontainer_network_footprinttvalue((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pyt
get_dockernsp!%	%	



**cC@sStddi�}|sdSi}x)|D]!}||r�t||t�r�||jd|�}t|�suq*ni|||6||<q*||r+t||t�r+|}t||dt�rd||dkr||dd}||jd�nt|�sq*ni|||6||<q*t|�s=q*n||||<q*W|S(u|
    List valid entries in mine configuration.

    CLI Example:

    .. code-block:: bash

        salt '*' mine.valid
    uconfig.mergeumine_functionsNu
mine_functioni(R
R,R.R/RR-(R7R8RR9((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pytvalid�s,

+('t__doc__t
__future__RRRR@tloggingRR1t
salt.cryptRtsalt.payloadtsalt.utils.argstsalt.utils.eventtsalt.utils.networktsalt.transport.clienttsalt.exceptionsRtsalt.extRt	frozensetREt__proxyenabled__t	getLoggert__name__R
RRRR)RtNoneR4R%RRSRTRsRt(((s5/usr/lib/python2.7/site-packages/salt/modules/mine.pyt<module>sF		
				i	8L		l

Zerion Mini Shell 1.0