%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/apache.pyo

�
���^c@�s~dZddlmZmZmZmZmZddlZddlZddl	m
Z
ddlmZddl
mZddlmZmZmZmZmZddlZddlZddlZddlZddlm Z ej!e"�Z#d	�Z$d
�Z%d�Z&d�Z'd
�Z(d�Z)d�Z*d�Z+dd�Z-dd�Z.d�Z/dd�Z0dd�Z1e2d�Z3dS(u)
Support for Apache

.. note::
    The functions in here are generic functions designed to work with
    all implementations of Apache. Debian-specific functions have been moved into
    deb_apache.py, but will still load under the ``apache`` namespace when a
    Debian-based system is detected.
i(tabsolute_importt
generatorstprint_functiontwith_statementtunicode_literalsN(tsix(t	cStringIO(tURLError(tHTTPBasicAuthHandlertHTTPDigestAuthHandlerturlopentbuild_openertinstall_opener(t
SaltExceptioncC�s,t�}tjjj|�r"dStdfS(u5
    Only load the module if apache is installed
    uapacheuFThe apache execution module cannot be loaded: apache is not installed.(t
_detect_ostsalttutilstpathtwhichtFalse(tcmd((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pyt__virtual__)s	cC�s>td}|dkrdS|dks2|dkr6dSdSdS(uA
    Apache commands and paths differ depending on packaging
    u	os_familyuRedHatu	apachectluDebianuSuseu
apache2ctlN(t
__grains__(t	os_family((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pyR3s
cC�sCdjt��}td|�j�}|djd�}|dS(u
    Return server version (``apachectl -v``)

    CLI Example:

    .. code-block:: bash

        salt '*' apache.version
    u{0} -vucmd.runiu: i(tformatRt__salt__t
splitlinestsplit(Rtouttret((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pytversionAs
cC�s�djt��}i}g|d<td|�j�}tjd�}x�|D]�}d|kr�|jd�}|s{qNn|dj�||dj�j�j	dd	�<qNd
|krN|j
d|�}|dj|�qNqNW|S(u�
    Return server version (``apachectl -V``)

    CLI Example:

    .. code-block:: bash

        salt '*' apache.fullversion
    u{0} -Vu
compiled_withucmd.runu	^\s+-D\s+u: iiu u_u -Du(RRRRtretcompileRtstriptlowertreplacetsubtappend(RRRt	define_retlinetcompstcwith((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pytfullversionQs


3cC�s�djt��}i}g|d<g|d<td|�j�}xn|D]f}|j�}|sgqInd|kr�|dj|d�nd|krI|dj|d�qIqIW|S(u�
    Return list of static and shared modules (``apachectl -M``)

    CLI Example:

    .. code-block:: bash

        salt '*' apache.modules
    u{0} -Mustaticushareducmd.runu(static)iu(shared)(RRRRRR%(RRRR'R(((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pytmodulesns



cC�sqdjt��}g}td|�j�}x<|D]4}|sGq5nd|kr5|j|j��q5q5W|S(u�
    Return list of modules compiled into the server (``apachectl -l``)

    CLI Example:

    .. code-block:: bash

        salt '*' apache.servermods
    u{0} -lucmd.runu.c(RRRRR%R!(RRRR'((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pyt
servermods�s

cC�s�djt��}i}td|�}|jdd�}xP|j�D]B}|sYqGn|jd�}dj|d�}|||d<qGW|S(u�
    Return list of directives together with expected arguments
    and places where the directive is valid (``apachectl -L``)

    CLI Example:

    .. code-block:: bash

        salt '*' apache.directives
    u{0} -Lucmd.runu
	u	u
ii(RRRR#RRtjoin(RRRR'R(tdesc((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pyt
directives�scC�sbdjt��}i}d}td|�}x-|j�D]}|sMq;n|j�}d|kr||d}i||<q;|ddkr�i||d<|d||dd<tjd	d|d
�||dd<n|ddkr;i|||d
<|d
|||d
d<tjd	d|d
�|||d
d<|d|||d
d<q;q;W|S(uj
    Show the settings as parsed from the config file (currently
    only shows the virtualhost settings) (``apachectl -S``).
    Because each additional virtual host adds to the execution
    time, this command may require a long timeout be specified
    by using ``-t 10``.

    CLI Example:

    .. code-block:: bash

        salt -t 10 '*' apache.vhosts
    u{0} -Suucmd.runuis a NameVirtualHostiudefaultiuvhostu\(|\)iuconfuportii(RRRRRRR$(RRt	namevhostRR'R(((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pytvhosts�s6

!cC�s�d}d}||kr(||kr(d	S||krFd
j|�}ndj|�}t�|}td|�}|d
r�|dr�|dj�}nI|dr�|dj�}n,|dr�|dj�}ndj|�}|S(u�
    Signals httpd to start, restart, or stop.

    CLI Example:

    .. code-block:: bash

        salt '*' apache.signal restart
    u
configtestustatusu
fullstatusustartustopurestartugracefulu
graceful-stopNu -k {0}u {0}ucmd.run_alluretcodeustderrustdoutu&Command: "{0}" completed successfully!(u
configtestustatusu
fullstatus(ustartustopurestartugracefulu
graceful-stop(RRRR!(tsignalt
no_extra_argst
valid_signalst	argumentsRRR((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pyR2�s"



ucC�std||||�S(u{
    Add HTTP user using the ``htpasswd`` command. If the ``htpasswd`` file does not
    exist, it will be created. Valid options that can be passed are:

    .. code-block:: text

        n  Don't update file; display results on stdout.
        m  Force MD5 hashing of the password (default).
        d  Force CRYPT(3) hashing of the password.
        p  Do not hash the password (plaintext).
        s  Force SHA1 hashing of the password.

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.useradd /etc/httpd/htpasswd larry badpassword
        salt '*' apache.useradd /etc/httpd/htpasswd larry badpass opts=ns
    uwebutil.useradd(R(tpwfiletusertpasswordtopts((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pytuseraddscC�std||�S(u�
    Delete HTTP user from the specified ``htpasswd`` file.

    CLI Example:

    .. code-block:: bash

        salt '*' apache.userdel /etc/httpd/htpasswd larry
    uwebutil.userdel(R(R6R7((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pytuserdels
udefaultc

C�smiidd6dd6dd6dd6dd6dd6dd6dd	6dd
6dd6dd6d
6}tddj|�d�}tddj|�d�}tddj|�d�}tddj|�d�}tddj|�d�}|r^|r^t�}|jd|d|d|d|�t�}|jd|d|d|d|�tt||��n|d7}y"t|d|�j�j	�}	Wnt
k
r�dSXx�|	D]�}
|
jdd�}|dj�|d<|dj�|d<|dd
kr"xl|dD]}|d
|cd7<qWq�|dj
�rMt|d�||d<q�t|d�||d<q�W|S( ur
    Get Information from the Apache server-status handler

    .. note::

        The server-status handler is disabled by default.
        In order for this function to work it needs to be enabled.
        See http://httpd.apache.org/docs/2.2/mod/mod_status.html

    The following configuration needs to exists in pillar/grains.
    Each entry nested in ``apache.server-status`` is a profile of a vhost/server.
    This would give support for multiple apache servers/vhosts.

    .. code-block:: yaml

        apache.server-status:
          default:
            url: http://localhost/server-status
            user: someuser
            pass: password
            realm: 'authentication realm for digest passwords'
            timeout: 5

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.server_status
        salt '*' apache.server_status other-profile
    iu_uSuRuWuKuDuCuLuGuIu.u
Scoreboardu
config.getuapache.server-status:{0}:urluhttp://localhost/server-statusuapache.server-status:{0}:useruuapache.server-status:{0}:passuapache.server-status:{0}:realmu apache.server-status:{0}:timeoutitrealmturiR7tpasswdu?autottimeoutuerroru:i(RRt_HTTPBasicAuthHandlertadd_passwordt_HTTPDigestAuthHandlert_install_openert
_build_openert_urlopentreadRRRR!tisdigittinttfloat(
tprofileRturlR7R>R<R?tbasictdigesttresponseR'tsplttc((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pyt
server_status,sd						"	"
"

c	C�s�t�}t|tj�rh|rFtdj||�d|dd�q�tdj|�d|dd�nOt|t�r�t}x6|D].}d|kr�t}tj	|d�}q�q�W|rStdj||�d|�x\|D]T}xK|j
�D]=\}}|dkr�tt|tj	|��d|�q�q�Wq�Wtdj|�d|�q�xa|D](}tt|tj	|��d|�qZWn.t|t�r�y$tdj||d�d|�Wn&t
k
r�td	j|���nXx�tj|�D]�\}}|dkr�t|tj�r>tdj||�d|�q�t|t�ritt||�d|�q�t|t�r�tt||�d|�q�q�q�Wtdj|�d|�n|jd
�|j�S(u�
    Recursively goes through config structure and builds final Apache configuration

    :param conf: defined config structure
    :param slot: name of section container if needed
    u{0} {1}tfiletenduu{0}uthisu	<{0} {1}>u</{0}>uPApache section container "<{0}>" expects attribute. Specify it using key "this".i(Rt
isinstanceRtstring_typestprintRtlistRtTruet	text_typetitemst
_parse_configtdicttKeyErrorR
t	iteritemstseekRF(	tconftslotRt
is_sectiontitemt	slot_thistkeytvaltvalue((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pyR[�sJ	%"

-
)$
	#
cC�s�g}x=|D]5}ttj|��}|jt|||��q
Wdjtjjj	|��}|r�tjj
j|d��0}|jd�|jtjj
j|��WdQXn|S(u�
    Create VirtualHost configuration files

    name
        File for the virtual host
    config
        VirtualHost configurations

    .. note::

        This function is not meant to be used from the command line.
        Config is meant to be an ordered dict of all of the apache configs.

    CLI Example:

    .. code-block:: bash

        salt '*' apache.config /etc/httpd/conf.d/ports.conf config="[{'Listen': '22'}]"
    u
uwu # This file is managed by Salt.
N(tnextRtiterkeysR%R[R-RRtdatatdecodetfilestfopentwritetstringutilstto_str(tnametconfigtedittconfigstentryRetconfigstextt
configfile((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pyRr�s

%(4t__doc__t
__future__RRRRRRtloggingtsalt.extRtsalt.ext.six.movesRtsalt.ext.six.moves.urllib.errorRt!salt.ext.six.moves.urllib.requestRR@R	RBR
RERRDRRCtsalt.utils.dataRtsalt.utils.filestsalt.utils.pathtsalt.utils.stringutilstsalt.exceptionsR
t	getLoggert__name__tlogRRRR*R+R,R/R1tNoneR2R:R;RQR[RXRr(((s7/usr/lib/python2.7/site-packages/salt/modules/apache.pyt<module>
s6((
	
							.%	
g1

Zerion Mini Shell 1.0