%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s3dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddl
mZeje�Zidd6ZdZeZejjjd�ry dd	lmZmZmZWn#ek
rZejd
e�qXe Znd�Z!d�Z"d
�Z#d�Z$d�Z%d�Z&dd�Z(dd�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/dd�Z0dd�Z1dd�Z2dd�Z3dd�Z4d�Z5d �Z6d!�Z7d"�Z8dd#�Z9d$�Z:d%�Z;d&�Z<d'�Z=d(�Z>dS()u]
Service support for RHEL-based systems, including support for both upstart and sysvinit

.. important::
    If you feel that Salt should be using this module to manage services on a
    minion, and it is using a different module (or gives an error similar to
    *'service.start' is not available*), see :ref:`here
    <module-provider-override>`.
i(tabsolute_importtunicode_literalstprint_functionN(tsixureloadureload_userviceuinitctl(t_upstart_enablet_upstart_disablet_upstart_is_enabledu?Unable to import helper functions from salt.modules.upstart: %scC@stdt�rtdfStd�}td|krtddkrstjtd�jd�rftStdfSntj	ddg�d}tddkr�|dkr�tdfStStdd
kr�|dkr�tdfSntddkr|dkrtdfSntStdj
|�fS( u�
    Only work on select distros which still use Red Hat's /usr/bin/service for
    management of either sysvinit or a hybrid sysvinit/upstart init system.
    usystemd.booteduTThe rh_service execution module failed to load: this system was booted with systemd.u	XenServeruXCP-nguRedHatuCentOSuScientificLinuxu
CloudLinuxuAmazonuFedorauALTuOELuSUSE  Enterprise ServeruSUSEuMcAfee  OS ServeruVirtuozzoLinuxuosu	osreleaseu11u*Cannot load rh_service module on SUSE > 11uosrelease_infoiiuWXenServer and XCP-ng >= 7 use systemd, will not load rh_service.py as virtual 'service'iuKFedora >= 15 uses systemd, will not load rh_service.py as virtual 'service'u_RedHat-based distros >= version 7 use systemd, will not load rh_service.py as virtual 'service'u,Cannot load rh_service module: OS not in {0}(u	XenServeruXCP-nguRedHatuCentOSuScientificLinuxu
CloudLinuxuAmazonuFedorauALTuOELuSUSE  Enterprise ServeruSUSEuMcAfee  OS ServeruVirtuozzoLinux(u	XenServeruXCP-ng(uRedHatuCentOSuScientificLinuxuOELu
CloudLinux(t	__utils__t__context__tFalsetsett
__grains__Rt	text_typet
startswitht__virtualname__tgettformat(tenabletosrelease_major((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt__virtual__0sL
	


cC@s2tdd�}d|kr dS|j�dSdS(u%
    Return the current runlevel
    ucmd.runu/sbin/runleveluunknownu3iN(t__salt__tsplit(tout((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt	_runleveloscC@sWdj|�}td|dt�dkr?tjd|�tStjd|�tSdS(u�
    Run 'chkconfig --add' for a service whose script is installed in
    /etc/init.d.  The service is initially configured to be disabled at all
    run-levels.
    u/sbin/chkconfig --add {0}ucmd.retcodetpython_shelliu"Added initscript "%s" to chkconfigu*Unable to add initscript "%s" to chkconfigN(RRR	tlogtinfotTrueterror(tnametcmd((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_chkconfig_add~scC@stotjjdj|��S(uS
    Return True if the service is an upstart service, otherwise return False.
    u/etc/init/{0}.conf(tHAS_UPSTARTtostpathtexistsR(R((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_service_is_upstart�scC@sIy0ttjtjjd|��jtj@�SWntk
rDtSXdS(u}
    Return True if the service is a System V service (includes those managed by
    chkconfig); otherwise return False.
    u/etc/init.dN(	tboolR!tstatR"tjointst_modetS_IXUSRtOSErrorR	(R((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_service_is_sysv�s
	'
cC@s/dj|�}td|dtdt�dkS(u=
    Return True if the service is managed by chkconfig.
    u/sbin/chkconfig --list {0}ucmd.retcodeRtignore_retcodei(RRR	R(Rtcmdline((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_service_is_chkconfig�scC@sVt||�}|rtS|dkr1t�}nttjdj||���dkS(u�
    Return True if the sysv (or chkconfig) service is enabled for the specified
    runlevel; otherwise return False.  If `runlevel` is None, then use the
    current runlevel.
    u/etc/rc.d/rc{0}.d/S??{1}iN(t_chkconfig_is_enabledRtNoneRtlentglobR(Rtrunleveltresult((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_sysv_is_enabled�scC@s�dj|�}td|dt�}|d	kr=t�}n|ddkr�xi|dj�D]T}dj|�|kr�|j�d|kr�tSq^|j�|dgkr^tSq^WntS(
u�
    Return ``True`` if the service is enabled according to chkconfig; otherwise
    return ``False``.  If ``runlevel`` is ``None``, then use the current
    runlevel.
    u/sbin/chkconfig --list {0}ucmd.run_allRuretcodeiustdoutu{0}:onuonN(RRR	R0Rt
splitlinesRR(RR3R-R4trow((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyR/�scC@sBt|�rt|�rtSdj|�}td|dt�S(u�
    Enable the named sysv service to start at boot.  The service will be enabled
    using chkconfig with default run-levels if the service is chkconfig
    compatible.  If chkconfig is not available, then this will fail.
    u/sbin/chkconfig {0} onucmd.retcodeR(R.RR	RR(RR((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_sysv_enable�scC@sBt|�rt|�rtSdj|�}td|dt�S(u
    Disable the named sysv service from starting at boot.  The service will be
    disabled using chkconfig with default run-levels if the service is chkconfig
    compatible; otherwise, the service will be disabled for the current
    run-level only.
    u/sbin/chkconfig {0} offucmd.retcodeR(R.RR	RR(RR((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt
_sysv_disable�scC@s.t|�stSdj|�}td|�S(ui
    Delete the named sysv service from the system. The service will be
    deleted using chkconfig.
    u/sbin/chkconfig --del {0}ucmd.retcode(R.R	RR(RR((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_sysv_delete�scC@sMtrItjjdj|��rItjdj|�dj|��qIntS(uI
    Delete an upstart service. This will only rename the .conf file
    u/etc/init/{0}.confu/etc/init/{0}.conf.removed(R R!R"R#RtrenameR(R((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_upstart_delete�s
cC@s>tr6gtjd�D]}tjj|�d ^qSgSdS(u*
    Return list of upstart services.
    u/etc/init/*.confi����N(R R2R!R"tbasename(R((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_upstart_services�s-cC@s�g}tdddgdt�}xb|j�D]T}|j�}y+|djd�rk|j|d�nWq/tk
r�q/q/Xq/Wg|D]}t|�r�|^q�S(u'
    Return list of sysv services.
    ucmd.runu	chkconfigu--listRiu0:i(RR	R6RR
tappendt
IndexErrorR+(t	_servicestoutputtlinetcompstx((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt_sysv_services	s
uc@s�|j�}|dkr/td�t�D��S|dkrat��t�fd�t�D��St��tgt�D]}t|�rw|^qwgt�D]}t|��r�|^q��SdS(u*
    Return the enabled services. Use the ``limit`` param to restrict results
    to services of that type.

    CLI Examples:

    .. code-block:: bash

        salt '*' service.get_enabled
        salt '*' service.get_enabled limit=upstart
        salt '*' service.get_enabled limit=sysvinit
    uupstartcs@s!|]}t|�r|VqdS(N(R(t.0R((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pys	<genexpr>)susysvinitc3@s$|]}t|��r|VqdS(N(R5(RGR(R3(s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pys	<genexpr>-sN(tlowertsortedR>RRFRR5(tlimitR((R3s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytget_enableds
		c@s�|j�}|dkr/td�t�D��S|dkrat��t�fd�t�D��St��tgt�D]}t|�sw|^qwgt�D]}t|��s�|^q��SdS(u-
    Return the disabled services. Use the ``limit`` param to restrict results
    to services of that type.

    CLI Example:

    .. code-block:: bash

        salt '*' service.get_disabled
        salt '*' service.get_disabled limit=upstart
        salt '*' service.get_disabled limit=sysvinit
    uupstartcs@s!|]}t|�s|VqdS(N(R(RGR((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pys	<genexpr>Gsusysvinitc3@s$|]}t|��s|VqdS(N(R5(RGR(R3(s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pys	<genexpr>KsN(RHRIR>RRFRR5(RJR((R3s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytget_disabled8s
		cC@sV|j�}|dkr%tt��S|dkr>tt��Stt�t��SdS(u
    Return all installed services. Use the ``limit`` param to restrict results
    to services of that type.

    CLI Example:

    .. code-block:: bash

        salt '*' service.get_all
        salt '*' service.get_all limit=upstart
        salt '*' service.get_all limit=sysvinit
    uupstartusysvinitN(RHRIR>RF(RJ((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytget_allVs


cC@sR|dkrt|�S|dkr,t|�St|�pMt|�pMt|�SdS(uF
    Return True if the named service is available.  Use the ``limit`` param to
    restrict results to services of that type.

    CLI Examples:

    .. code-block:: bash

        salt '*' service.available sshd
        salt '*' service.available sshd limit=upstart
        salt '*' service.available sshd limit=sysvinit
    uupstartusysvinitN(R$R+R.(RRJ((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt	availablels



cC@sR|dkrt|�S|dkr.t|�St|�sFt|�rJtStSdS(uj
    The inverse of service.available.
    Return True if the named service is not available.  Use the ``limit`` param to
    restrict results to services of that type.

    CLI Examples:

    .. code-block:: bash

        salt '*' service.missing sshd
        salt '*' service.missing sshd limit=upstart
        salt '*' service.missing sshd limit=sysvinit
    uupstartusysvinitN(R$R+R	R(RRJ((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytmissing�scC@sBt|�rdj|�}ndj|�}td|dt�S(u�
    Start the specified service

    CLI Example:

    .. code-block:: bash

        salt '*' service.start <service name>
    u	start {0}u/sbin/service {0} startucmd.retcodeR(R$RRR	(RR((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytstart�s
cC@sBt|�rdj|�}ndj|�}td|dt�S(u~
    Stop the specified service

    CLI Example:

    .. code-block:: bash

        salt '*' service.stop <service name>
    ustop {0}u/sbin/service {0} stopucmd.retcodeR(R$RRR	(RR((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytstop�s
cC@sBt|�rdj|�}ndj|�}td|dt�S(u�
    Restart the named service

    CLI Example:

    .. code-block:: bash

        salt '*' service.restart <service name>
    urestart {0}u/sbin/service {0} restartucmd.retcodeR(R$RRR	(RR((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytrestart�s
cC@sBt|�rdj|�}ndj|�}td|dt�S(u~
    Reload the named service

    CLI Example:

    .. code-block:: bash

        salt '*' service.reload <service name>
    u
reload {0}u/sbin/service {0} reloaducmd.retcodeR(R$RRR	(RR((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytreload_�s
cC@s�|rttd|��Sttjd|��}|rPtjt�|�}n	|g}i}x�|D]y}t|�r�dj|�}dtd|dt	�k||<qfdj|�}td|dt	d	t
�d
k||<qfW|r�|S||S(u]
    Return the status for a service.
    If the name contains globbing, a dict mapping service name to True/False
    values is returned.

    .. versionchanged:: 2018.3.0
        The service name can now be a glob (e.g. ``salt*``)

    Args:
        name (str): The name of the service to check
        sig (str): Signature to use to find the service via ps

    Returns:
        bool: True if running, False otherwise
        dict: Maps service name to True if running, False otherwise

    CLI Example:

    .. code-block:: bash

        salt '*' service.status <service name> [service signature]
    u
status.pidu\*|\?|\[.+\]u
status {0}u
start/runningucmd.runRu/sbin/service {0} statusucmd.retcodeR,i(R%RtretsearchtfnmatchtfilterRMR$RR	R(Rtsigtcontains_globbingtservicestresultstserviceR((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytstatus�s 	
#*cK@s$t|�rt|�St|�SdS(u�
    Delete the named service

    .. versionadded:: 2016.3

    CLI Example:

    .. code-block:: bash

        salt '*' service.delete <service name>
    N(R$R<R:(Rtkwargs((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytdelete
s
cK@s$t|�rt|�St|�SdS(u�
    Enable the named service to start at boot

    CLI Example:

    .. code-block:: bash

        salt '*' service.enable <service name>
    N(R$RR8(RR^((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyRs

cK@s$t|�rt|�St|�SdS(u�
    Disable the named service to start at boot

    CLI Example:

    .. code-block:: bash

        salt '*' service.disable <service name>
    N(R$RR9(RR^((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytdisable,s

cK@s$t|�rt|�St|�SdS(u�
    Check to see if the named service is enabled to start on boot

    CLI Example:

    .. code-block:: bash

        salt '*' service.enabled <service name>
    N(R$RR5(RR^((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytenabled<s

cC@s&t|�rt|�St|�SdS(u�
    Check to see if the named service is disabled to start on boot

    CLI Example:

    .. code-block:: bash

        salt '*' service.disabled <service name>
    N(R$RR5(R((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pytdisabledLs
(?t__doc__t
__future__RRRR2tloggingR!R&RVRTtsalt.utils.pathtsalttsalt.extRt	getLoggert__name__Rt__func_alias__RR	R tutilsR"twhichtsalt.modules.upstart_serviceRRRt	ExceptiontexcRRRRRR$R+R.R0R5R/R8R9R:R<R>RFRKRLRMRNRORPRQRRRSR]R_RR`RaRb(((s;/usr/lib/python2.7/site-packages/salt/modules/rh_service.pyt<module>
sd
 			?				
			
								,				

Zerion Mini Shell 1.0