%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZddlZddlZddlZddlZddlZddl	m
Z
ddlmZyddl
Z
eZWnek
r�eZnXeje�ZdZiadad�Zd�Zd	�Zd
�Zd�Zd�ZdS(
s+
Beacon to announce via Bonjour (zeroconf)
i(tabsolute_importN(tsix(tmaptbonjour_announcecC@str
tStS(N(t
HAS_PYBONJOURt__virtualname__tFalse(((sA/usr/lib/python2.7/site-packages/salt/beacons/bonjour_announce.pyt__virtual__ scC@strtj�dandS(sS
    Close the SD_REF object if it isn't NULL
    For use with atexit.register
    N(tSD_REFtclosetNone(((sA/usr/lib/python2.7/site-packages/salt/beacons/bonjour_announce.pyt
_close_sd_ref&s
cC@s&|tjkr"tjd|�ndS(Ns.Bonjour registration failed with error code %s(t	pybonjourtkDNSServiceErr_NoErrortlogterror(tsdReftflagst	errorCodetnametregtypetdomain((sA/usr/lib/python2.7/site-packages/salt/beacons/bonjour_announce.pyt_register_callback1sc@sei�tt�j|��t|t�s5tdfSt�fd�dD��s[tdfStdfS(	s+
    Validate the beacon configuration
    s9Configuration for bonjour_announce beacon must be a list.c3@s|]}|�kVqdS(N((t.0tx(t_config(sA/usr/lib/python2.7/site-packages/salt/beacons/bonjour_announce.pys	<genexpr>AstservicetypetportttxtsWConfiguration for bonjour_announce beacon must contain servicetype, port and txt items.sValid beacon configuration.(Rsportstxt(tlistRtupdatet
isinstanceRtalltTrue(tconfig((RsA/usr/lib/python2.7/site-packages/salt/beacons/bonjour_announce.pytvalidate6s


cC@s:t|�t|�ddkr6|dt|� dS|S(s�
    Enforces the TXT record maximum length of 255 characters.
    TXT record length includes key, value, and '='.

    :param str key: Key of the TXT record
    :param str value: Value of the TXT record

    :rtype: str
    :return: The value of the TXT record. It may be truncated if it exceeds
             the maximum permitted length. In case of truncation, '...' is
             appended to indicate that the entire value is not present.
    ii�i�s...(tlen(tkeytvalue((sA/usr/lib/python2.7/site-packages/salt/beacons/bonjour_announce.pyt_enforce_txt_record_maxlenIs cC@s�g}i}i}i}tt|j|��d|krG|d}n-td}trttd|krt||d<ntr	|jdt�r	tjdg�tjdg�kr�tjdg�|d<ntjdg�tjdg�kr	tjdg�|d<q	nxx|dD]l}dtjj	j
|�}|d|jd�rN|d|d	}d!}	|j
d
�}
|
dkr�|ddkr�t||
d
d!�}	||
 }ntj|d�}t|t�r�|	d!k	r�||	}q�dj|�}nt||�||<tritj|d�tj|d�kri||||<qint||d|�||<ts||||<qqW|r�tjd|�}tsn||d<|d|d<|d|d<tjdg�|d<tjdg�|d<tjd|d|dd|dd|dt�atjt�tjtggg�}
t|
dkrntjt�qnn|jdt�s�d|kr7tj�d!a|jdd�}|dkr�tj|�ntjd|d|dd|dd|dt�atjtggg�}
t|
dkrntjt�qnn7tj |�j!d�}tj"tdd!ddd|�|j#idd6|d6�n|jd t�r�tj$�anta|S("s	
    Broadcast values via zeroconf

    If the announced values are static, it is advised to set run_once: True
    (do not poll) on the beacon configuration.

    The following are required configuration settings:

    - ``servicetype`` - The service type to announce
    - ``port`` - The port of the service to announce
    - ``txt`` - The TXT record of the service being announced as a dict. Grains
      can be used to define TXT values using one of following two formats:

      - ``grains.<grain_name>``
      - ``grains.<grain_name>[i]`` where i is an integer representing the
        index of the grain to use. If the grain is not a list, the index is
        ignored.

    The following are optional configuration settings:

    - ``servicename`` - Set the name of the service. Will use the hostname from
      the minion's ``host`` grain if this value is not set.
    - ``reset_on_change`` - If ``True`` and there is a change in TXT records
      detected, it will stop announcing the service and then restart announcing
      the service. This interruption in service announcement may be desirable
      if the client relies on changes in the browse records to update its cache
      of TXT records. Defaults to ``False``.
    - ``reset_wait`` - The number of seconds to wait after announcement stops
      announcing and before it restarts announcing in the case where there is a
      change in TXT records detected and ``reset_on_change`` is ``True``.
      Defaults to ``0``.
    - ``copy_grains`` - If ``True``, Salt will copy the grains passed into the
      beacon when it backs them up to check for changes on the next iteration.
      Normally, instead of copy, it would use straight value assignment. This
      will allow detection of changes to grains where the grains are modified
      in-place instead of completely replaced.  In-place grains changes are not
      currently done in the main Salt code but may be done due to a custom
      plug-in. Defaults to ``False``.

    Example Config

    .. code-block:: yaml

       beacons:
         bonjour_announce:
           - run_once: True
           - servicetype: _demo._tcp
           - port: 1234
           - txt:
               ProdName: grains.productname
               SerialNo: grains.serialnumber
               Comments: 'this is a test'
    tservicenamethosttreset_on_changetipv4tipv6Rstxt.sgrains.it[i����t]itt,titemsRRRRt	txtRecordtcallBackit
reset_waitsutf-8t	RecordRefRtrdatatresultttagtchangestcopy_grainsN(%RRRt
__grains__tLAST_GRAINStgetRtsalttutilststringutilst
to_unicodet
startswithR
tfindtintRtjoinR'Rt	TXTRecordtDNSServiceRegisterRRtatexittregisterRtselecttDNSServiceProcessResultR	ttimetsleepRt	text_typetencodetDNSServiceUpdateRecordtappendtcopy(R"tretR9RRR(titemtchanges_keytgraintgrain_indextsquare_brackettgrain_valuet
txt_recordtreadyR4ttxt_record_raw((sA/usr/lib/python2.7/site-packages/salt/beacons/bonjour_announce.pytbeacon]s�6


$$

*
	

	

	

	(t__doc__t
__future__RRHtloggingRJRLtsalt.utils.stringutilsR>tsalt.extRtsalt.ext.six.movesRRR!RtImportErrorRt	getLoggert__name__RRR<R
RRRRR#R'R](((sA/usr/lib/python2.7/site-packages/salt/beacons/bonjour_announce.pyt<module>s.


					

Zerion Mini Shell 1.0