%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/beacons.pyc

�
���^c@@s1dZddlmZmZmZddlZddlZddlZddlj	j
Z
ddlZddl
ZddlZddlmZeje�ZdZidd6dd	6Zeeed
�Zed�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"dS(uO
Module for managing the Salt beacons on a minion

.. versionadded:: 2015.8.0

i(tabsolute_importtprint_functiontunicode_literalsN(tmapi<ulistulist_ureloadureload_c
K@s$d}y�tjjjddtdt�}tdidd6|d6|d6d	�}|r�|jd
dd|jd
t	��}t
jd|�|r�|dr�|d}q�nWn,tk
r�i}t
|d<d|d<|SX|r|ri|d6}	tjjj|	dt
�S|Sniid6SdS(uF
    List the beacons currently configured on the minion

    :param return_yaml:    Whether to return YAML formatted output,
                           default ``True``

    :param include_pillar: Whether to include beacons that are
                           configured in pillar, default is ``True``.

    :param include_opts:   Whether to include beacons that are
                           configured in opts, default is ``True``.

    :return:               List of currently configured Beacons.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.list

    uminiontoptstlistenu
event.fireulistufuncuinclude_pillaruinclude_optsumanage_beaconsttagu)/salt/minion/minion_beacons_list_completetwaitutimeoutuevent_ret %sucompleteubeaconsuresultu.Event module not available. Beacon add failed.ucommenttdefault_flow_styleN(tNonetsalttutilsteventt	get_eventt__opts__tTruet__salt__tgettdefault_event_waittlogtdebugtKeyErrortFalsetyamlt	safe_dump(
treturn_yamltinclude_pillartinclude_optstkwargstbeaconsteventertrest	event_rettretttmp((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytlist_ s2!		



cK@sd}y�tjjjddtdt�}tdidd6d�}|r�|jdd	d
|jdt	��}|r�|dr�|d
}q�nWn,t
k
r�i}t|d<d|d<|SX|r�|r�i|d
6}tjjj
|dt�S|Sniid
6SdS(uG
    List the beacons currently available on the minion

    :param return_yaml:     Whether to return YAML formatted output, default
                            ``True``
    :return:                List of currently configured Beacons.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.list_available

    uminionRRu
event.fireulist_availableufuncumanage_beaconsRu3/salt/minion/minion_beacons_list_available_completeRutimeoutucompleteubeaconsuresultu.Event module not available. Beacon add failed.ucommentRN(R	R
RRR
RRRRRRRRR(RRRRRR R!R"((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytlist_availableYs*!	



c
K@stidj|�d6td6}|tdt|�krLdj|�|d<|S|tdt|�kr{dj|�|d<|Sd|kr�|dr�t|d<dj|�|d<n�y�tjjjd	d
t	dt�}t
di|d
6|d6dd6d�}|r>|jddd|jdt��}|d}|d}n|sht|d<dj||�|d<|SWnt
k
r�d|d<nXy�t
di|d
6|d6dd6d�}|rQ|jddd|jdt��}|r5|dr5|d}	||	krM|	||krMt|d<dj|�|d<qMnt|d<|d|d<|SWnt
k
rod|d<nX|S(u�
    Add a beacon on the minion

    :param name:            Name of the beacon to configure
    :param beacon_data:     Dictionary or list containing configuration for beacon.
    :return:                Boolean and status message on success or failure of add.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.add ps "[{'processes': {'salt-master': 'stopped', 'apache2': 'stopped'}}]"

    uFailed to add beacon {0}.ucommenturesultRu!Beacon {0} is already configured.uBeacon "{0}" is not available.utestuBeacon: {0} would be added.uminionRRu
event.fireunameubeacon_datauvalidate_beaconufuncumanage_beaconsRu./salt/minion/minion_beacon_validation_completeRutimeoutuvaliduvcommentu1Beacon {0} configuration invalid, not adding.
{1}u.Event module not available. Beacon add failed.uaddu'/salt/minion/minion_beacon_add_completeucompleteubeaconsuAdded beacon: {0}.(tformatRR#R$RR
RRR
RRRRR(
tnametbeacon_dataRR!RRR tvalidtvcommentR((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytadd�sb

!		



	



cK@s�idd6td6}tdt|�}||krIdj|�|d<|Sd|kr|drt|d<dj|�|d<ny�tjjjdd	td
t�}t	di|d6|d
6dd6d�}|r|jddd|j
dt��}|d}|d}	n|s6t|d<dj||	�|d<|SWntk
rTd|d<nX|st|d<dj||	�|d<|S||}
|}||
kr�dj|�|d<|Sg}xI|
D]A}
|j
gtj|
�D]\}}dj||�^q��q�Wg}xI|D]A}
|j
gtj|
�D]\}}dj||�^q-�qWtj||�}i|d<dj|�|dd<y�tjjjdd	td
t�}t	di|d6|d
6dd6d�}|rt|jddd|j
dt��}|rX|d rX|d!}||krp|||krpt|d<d"j|�|d<qpnt|d<|d|d<|SWntk
r�d#|d<nX|S($u�
    Modify an existing beacon

    :param name:            Name of the beacon to configure
    :param beacon_data:     Dictionary or list containing updated configuration for beacon.
    :return:                Boolean and status message on success or failure of modify.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.modify ps "[{'salt-master': 'stopped'}, {'apache2': 'stopped'}]"
    uucommenturesultRuBeacon {0} is not configured.utestuBeacon: {0} would be added.uminionRRu
event.fireunameubeacon_datauvalidate_beaconufuncumanage_beaconsRu./salt/minion/minion_beacon_validation_completeRutimeoutuvaliduvcommentu1Beacon {0} configuration invalid, not adding.
{1}u1Event module not available. Beacon modify failed.u4Beacon {0} configuration invalid, not modifying.
{1}uJob {0} in correct stateu{0}:{1}
uchangesudiffumodifyu*/salt/minion/minion_beacon_modify_completeucompleteubeaconsuModified beacon: {0}.u.Event module not available. Beacon add failed.(RR#RR%R
RRR
RRRRRtextendtsixt	iteritemstdifflibtunified_difftjoin(R&R'RR!tcurrent_beaconsRRR R(R)t_currentt_newt_current_linest_itemtkeytvaluet
_new_linest_diffR((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytmodify�s�


!		






	6
	6
!(	



cK@sJidj|�d6td6}d|krS|drSt|d<dj|�|d<n�y�tjjjddtdt�}td	i|d
6dd6d
�}|r'|jddd|j	dt
��}|r|dr|d}||kr$t|d<dj|�|d<|Sq't|d<|d|d<nWntk
rEd|d<nX|S(u'
    Delete a beacon item

    :param name:            Name of the beacon to delete
    :return:                Boolean and status message on success or failure of delete.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.delete ps

        salt '*' beacons.delete load

    uFailed to delete beacon {0}.ucommenturesultutestuBeacon: {0} would be deleted.uminionRRu
event.fireunameudeleteufuncumanage_beaconsRu*/salt/minion/minion_beacon_delete_completeRutimeoutucompleteubeaconsuDeleted beacon: {0}.u.Event module not available. Beacon add failed.(R%RRR
RRR
RRRRR(R&RR!RRR R((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytdelete4s.

!!	



cK@sigd6td6}tdtdt|�}tjjtdtjjtd�d�}|r�i|d6}tj	j
j|d	t�}nd
}yEtj	jj
|d��}|j|�WdQXd
j|�|d<Wn4ttfk
r
dj|�|d<t|d<nX|S(u�
    Save all beacons on the minion

    :return:                Boolean and status message on success or failure of save.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.save
    ucommenturesultRRu
config_dirudefault_includeubeacons.confubeaconsRuuw+NuBeacons saved to {0}.u:Unable to write to beacons file at {0}. Check permissions.(RR#RtostpathR0RtdirnameR
RRRtfilestfopentwriteR%tIOErrortOSError(RR!RtsfnR"tyaml_outtfp_((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytsavebs&

	

cK@s$igd6td6}d|kr7|dr7d|d<n�y�tjjjddtdt�}tdid	d
6d�}|r|jdd
d|jdt��}|r�|dr�|d}d|kr�|dr�t|d<d|d<q�t	|d<d|d<n|SWnt
k
rd|d<nX|S(u�
    Enable all beacons on the minion

    Returns:
        bool: Boolean and status message on success or failure of enable.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.enable
    ucommenturesultutestuBeacons would be enabled.uminionRRu
event.fireuenableufuncumanage_beaconsRu,/salt/minion/minion_beacons_enabled_completeRutimeoutucompleteubeaconsuenableduEnabled beacons on minion.u#Failed to enable beacons on minion.u6Event module not available. Beacons enable job failed.(RR
RRR
RRRRRR(RR!RRR R((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytenable�s,


!	





cK@s5igd6td6}d|kr7|dr7d|d<n�y�tjjjddtdt�}tdid	d
6d�}|r|jdd
d|jdt��}t	j
d|�|r|dr|d}d|kr�|dr�t|d<d|d<qt|d<d|d<n|SWntk
r0d|d<nX|S(u�
    Disable all beacons jobs on the minion

    :return:                Boolean and status message on success or failure of disable.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.disable
    ucommenturesultutestuBeacons would be disabled.uminionRRu
event.fireudisableufuncumanage_beaconsRu-/salt/minion/minion_beacons_disabled_completeRutimeoutuevent_ret %sucompleteubeaconsuenableduDisabled beacons on minion.u$Failed to disable beacons on minion.u6Event module not available. Beacons enable job failed.(
RR
RRR
RRRRRRRR(RR!RRR R((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytdisable�s.


!	





cC@s8i}t|t�r.tt|j|��n|}|S(N(t
isinstancetlistRtupdate(t
beacon_configtbeacon_config_dict((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pyt_get_beacon_config_dict�s
c	K@s�igd6td6}|s2d|d<t|d<|Sd|kr^|dr^dj|�|d<nitdt|�}||kr�dj|�|d<t|d<|Sytjjjdd	td
t�}t	didd
6|d6d�}|r�|jddd|j
dt��}|r�|dr�|d}t||�}d|krl|drlt|d<dj|�|d<q�t|d<dj|�|d<nt|d<|d|d<|SWnt
k
r�d|d<nX|S(u
    Enable beacon on the minion

    :name:                  Name of the beacon to enable.
    :return:                Boolean and status message on success or failure of enable.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.enable_beacon ps
    ucommenturesultuBeacon name is required.utestuBeacon {0} would be enabled.Ru'Beacon {0} is not currently configured.uminionRRu
event.fireu
enable_beaconufuncunameumanage_beaconsRu+/salt/minion/minion_beacon_enabled_completeRutimeoutucompleteubeaconsuenableduEnabled beacon {0} on minion.u&Failed to enable beacon {0} on minion.u5Event module not available. Beacon enable job failed.(RRR%R#R
RRR
RRRRROR(	R&RR!t_beaconsRRR RRN((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pyt
enable_beacon�sD




!!	




c	K@s�igd6td6}|s2d|d<t|d<|Sd|krU|drUd|d<natdt|�}||kr�dj|�|d<t|d<|Sytjjjdd	td
t�}t	didd
6|d6d�}|r�|jddd|j
dt��}|r{|dr{|d}t||�}d|krd|drdt|d<dj|�|d<q�t|d<d|d<nt|d<|d|d<|SWnt
k
r�d|d<nX|S(u
    Disable beacon on the minion

    :name:                  Name of the beacon to disable.
    :return:                Boolean and status message on success or failure of disable.

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.disable_beacon ps
    ucommenturesultuBeacon name is required.utestuBeacons would be enabled.Ru'Beacon {0} is not currently configured.uminionRRu
event.fireudisable_beaconufuncunameumanage_beaconsRu,/salt/minion/minion_beacon_disabled_completeRutimeoutucompleteubeaconsuenableduDisabled beacon {0} on minion.u#Failed to disable beacon on minion.u6Event module not available. Beacon disable job failed.(RRR#R%R
RRR
RRRRROR(	R&RR!RPRRR RRN((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytdisable_beacon!sD





!!	





cK@s0igd6td6}|jd�r0d|d<n�y�tjjjddtdt�}tdid	d
6d�}|r
|jdt�}|jd
dd|�}|r�|dr�t|d<d|d<nD|dkr�t
|d<dj|�|d<nt
|d<|d|d<|SWntk
r+d|d<nX|S(u
    Resest beacon configuration on the minion

    CLI Example:

    .. code-block:: bash

        salt '*' beacons.reset
    ucommenturesultutestuBeacons would be reset.uminionRRu
event.fireuresetufuncumanage_beaconsutimeoutRu)/salt/minion/minion_beacon_reset_completeRucompleteuBeacon configuration reset.u0minion reset event not recieved after {} secondsu6Event module not available. Beacon disable job failed.N(
RRR
RRR
RRRR	RR%R(RR!RRRR ((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pytreset[s2


!		




(#t__doc__t
__future__RRRR.tloggingR<tsalt.ext.sixtextR,tsalt.utils.eventR
tsalt.utils.filestsalt.utils.yamltsalt.ext.six.movesRt	getLoggert__name__RRt__func_alias__RR#R$R*R:R;RGRHRIRORQRRRS(((s8/usr/lib/python2.7/site-packages/salt/modules/beacons.pyt<module>s8
7+	M	c	.	'	*	*	
	:	:

Zerion Mini Shell 1.0