%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s4dZddlmZmZmZddlZddlZddlZddl	m
Zddlm
Z
ddlmZdZd
Zd�Zd�Zd
�Zed�Zed�Zd�Zdddeeed�Zdddd�Zd�Zd�Zed�Zed�Z ddeeded�Z!dS(u�
Starting or restarting of services and daemons
==============================================

Services are defined as system daemons and are typically launched using system
init or rc scripts. This service state uses whichever service module is loaded
on the minion with the virtualname of ``service``. Services can be defined as
either running or dead.

If you need to know if your init system is supported, see the list of supported
:mod:`service modules <salt.modules.service.py>` for your desired init system
(systemd, sysvinit, launchctl, etc.).

Note that Salt's service execution module, and therefore this service state,
uses OS grains to ascertain which service module should be loaded and used to
execute service functions. As existing distributions change init systems or
new distributions are created, OS detection can sometimes be incomplete.
If your service states are running into trouble with init system detection,
please see the :ref:`Overriding Virtual Module Providers <module-provider-override>`
section of Salt's module documentation to work around possible errors.

.. note::
    The current status of a service is determined by the return code of the init/rc
    script status command. A status return code of 0 it is considered running.  Any
    other return code is considered dead.

.. code-block:: yaml

    httpd:
      service.running: []

The service can also be set to start at runtime via the enable option:

.. code-block:: yaml

    openvpn:
      service.running:
        - enable: True

By default if a service is triggered to refresh due to a watch statement the
service is restarted. If the desired behavior is to reload the service, then
set the reload value to True:

.. code-block:: yaml

    redis:
      service.running:
        - enable: True
        - reload: True
        - watch:
          - pkg: redis

.. note::

    More details regarding ``watch`` can be found in the
    :ref:`Requisites <requisites>` documentation.

i(tabsolute_importtprint_functiontunicode_literalsN(tget_function_argspec(tCommandExecutionError(tsixuno_blockuunmaskuunmask_runtimeuservicecC@s7dtkrtStdjtjdtd��fSdS(ur
    Only make these states available if a service provider has been detected or
    assigned for this minion
    u
service.startuPNo service execution module loaded: check support for service management on {0} uosfingeruosN(t__salt__t__virtualname__tFalsetformatt
__grains__tget(((s7/usr/lib/python2.7/site-packages/salt/states/service.pyt__virtual__Ns	cC@s�i}g}t|�j}xXtD]P}|j|t�}|r"||krY|||<qr|jdj|��q"q"W||fS(Nu;The '{0}' argument is not supported by this platform/action(t_argspectargstSYSTEMD_ONLYRRtappendR	(tfunctkwargstrettwarningst
valid_argstsystemd_argtarg_val((s7/usr/lib/python2.7/site-packages/salt/states/service.pyt_get_systemd_only]s

cC@s)t|d<ddj|d�|d<|S(u!
    Warn of potential typo.
    uresultu1Service {0} uses non-existent option "enabled".  u%Perhaps "enable" option was intended?unameucomment(RR	(R((s7/usr/lib/python2.7/site-packages/salt/states/service.pyt_enabled_used_errorns

c	K@s�i}yt||�s|SWn+tk
rJ}t|d<|j|d<|SX||d<dtksmdtkr�|tkr�dj|�|d<n5|dkr�dj|�|d<ndj|�|d<|Std||�}|rF|tkrdj|�|d<n?|dkr/i|d	<d
j|�|d<ndj|�|d<|Stdrqd|d<d
j|�|d<|Sy�td||�ri|d	<td||�}||kr�t|d	|<n|tkr�dj|�|d<n5|dkrdj|�|d<ndj|�|d<|SWntk
r;}|j}nXt}t|d<|tkrndj|�|d<n5|dkr�dj|�|d<ndj|�|d<|r�|dcdj|�7<n|S(u
    Enable the service
    uresultucommentuservice.enableuservice.enabledu;Enable is not available on this minion, service {0} starteduKEnable is not available on this minion, service {0} is in the desired stateu;Enable is not available on this minion, service {0} is deadu.Service {0} is already enabled, and is runninguchangesu;Service {0} is already enabled, and is in the desired stateu+Service {0} is already enabled, and is deadutestuService {0} set to be enabledu,Service {0} has been enabled, and is runningu9Service {0} has been enabled, and is in the desired stateu)Service {0} has been enabled, and is deaduLFailed when setting service {0} to start at boot, but the service is runninguUFailed when setting service {0} to start at boot, but the service was already runninguIFailed when setting service {0} to start at boot, and the service is deadu&. Additional information follows:

{0}N(	t
_availableRRtstrerrorRtTrueR	tNonet__opts__(	tnametstartedtresultRRtexctbefore_toggle_enable_statustafter_toggle_enable_statustenable_error((s7/usr/lib/python2.7/site-packages/salt/states/service.pyt_enablezs�








	



cK@s�i}y!t||�s&t|d<|SWn+tk
rT}t|d<|j|d<|SX||d<dtkswdtkr�|tkr�dj|�|d<n5|dkr�dj|�|d<ndj|�|d<|Stj	j
j�rtd|�d	dk}ntd|�}|r||tkr9dj|�|d<n?|dkrei|d<d
j|�|d<ndj|�|d<|Stdr�d|d<dj|�|d<|Std||�rLi|d<td|�}||kr�t|d|<n|tkrdj|�|d<n5|dkr5dj|�|d<ndj|�|d<|St|d<|tkrxdj|�|d<n5|dkr�dj|�|d<ndj|�|d<|S(u
    Disable the service
    uresultucommentuservice.disableuservice.disabledu<Disable is not available on this minion, service {0} starteduLDisable is not available on this minion, service {0} is in the desired stateu<Disable is not available on this minion, service {0} is deaduservice.infou	StartTypeuDisabledu/Service {0} is already disabled, and is runninguchangesu<Service {0} is already disabled, and is in the desired stateu,Service {0} is already disabled, and is deadutestuService {0} set to be disabledu-Service {0} has been disabled, and is runningu:Service {0} has been disabled, and is in the desired stateu*Service {0} has been disabled, and is deaduDFailed when setting service {0} to not start at boot, and is runninguYFailed when setting service {0} to not start at boot, but the service was already runninguMFailed when setting service {0} to not start at boot, and the service is deadN(uDisabled(
RRRRRRR	Rtsalttutilstplatformt
is_windowsR(RR R!RRR"tbefore_toggle_disable_statustafter_toggle_disable_status((s7/usr/lib/python2.7/site-packages/salt/states/service.pyt_disable�s|












cC@sqt}dtkr%td|�}n"dtkrG|td�k}n|smt|d<dj|�|d<n|S(u+
    Check if the service is available
    uservice.availableuservice.get_alluresultu&The named service {0} is not availableucomment(RRR	(RRtavail((s7/usr/lib/python2.7/site-packages/salt/states/service.pyR@s
cK@s�i|d6id6td6dd6}d|kr8t|�St|tj�rbtjjj|�}nyFt	||�s�t
jd�r�d|d<dj
|�|d<n|SWn+tk
r�}	t|d<|	j|d<|SXtd	||�}
d
tkrtd
|�}nt}idd6}|r3t||�}n|
r�djgdj
|�|dgD]}
|
rY|
^qY�|d<|tkr�|r�|jt|d|��n.|tkr�|r�|jt|d|��n|St
dr0d|d<djgd
j
|�|dgD]}
|
r
|
^q
�|d<|Sttdt��\}}|rn|jdg�j|�ntjjj�r�|jdt�r�|ji|jd�d6�nytd||�}Wn+tk
r�}	t|d<|	j|d<|SX|szt|d<dj
|�|d<|tkrH|jt|tdt|��n.|tkrv|jt|tdt|��n|S|r�tj|�ntd	||�}d
tkr�td
|�}nt}||ks�|
|kr|jdi�r||d|<n|r dj
|�|d<ndj
|�|d<t|d<|tkrk|jt||d||��n.|tkr�|jt||d||��n|r�dj
|d|�|d<n|r�dj|d|dg�|d<n|S(u�
    Ensure that the service is running

    name
        The name of the init or rc script used to manage the service

    enable
        Set the service to be enabled at boot time, ``True`` sets the service
        to be enabled, ``False`` sets the named service to be disabled. The
        default is ``None``, which does not enable or disable anything.

    sig
        The string to search for when looking for the service process with ps

    init_delay
        Some services may not be truly available for a short period after their
        startup script indicates to the system that they are. Provide an
        'init_delay' to specify that this state should wait an additional given
        number of seconds after a service has started before returning. Useful
        for requisite states wherein a dependent state might assume a service
        has started but is not yet fully initialized.

    no_block : False
        **For systemd minions only.** Starts the service using ``--no-block``.

        .. versionadded:: 2017.7.0

    unmask : False
        **For systemd minions only.** Set to ``True`` to remove an indefinite
        mask before attempting to start the service.

        .. versionadded:: 2017.7.0
            In previous releases, Salt would simply unmask a service before
            making any changes. This behavior is no longer the default.

    unmask_runtime : False
        **For systemd minions only.** Set to ``True`` to remove a runtime mask
        before attempting to start the service.

        .. versionadded:: 2017.7.0
            In previous releases, Salt would simply unmask a service before
            making any changes. This behavior is no longer the default.

    .. note::
        ``watch`` can be used with service.running to restart a service when
         another state changes ( example: a file.managed state that creates the
         service's config file ). More details regarding ``watch`` can be found
         in the :ref:`Requisites <requisites>` documentation.
    unameuchangesuresultuucommentuenabledutestuQService {0} not present; if created in this state run, it would have been starteduservice.statususervice.enabledu
u"The service {0} is already runninguService {0} is set to startu
service.startuwarningsutimeoutuService {0} failed to startR!uStarted Service {0}u"{0}
Delayed return for {1} secondsN(RRt
isinstanceRtstring_typesR'R(tdatatis_trueRRRRR	RRRRtunmaskedtjointupdateR&R-Rtlocalst
setdefaulttextendR)R*ttimetsleep(Rtenabletsigt
init_delaytno_blocktunmasktunmask_runtimeRRR"tbefore_toggle_statusR#t
unmask_rett_ftstart_kwargsRtfunc_rettafter_toggle_statusR$((s7/usr/lib/python2.7/site-packages/salt/states/service.pytrunningOs�9






*

*$ 


""
""$cK@s#i|d6id6td6dd6}d|kr8t|�St|tj�rbtjjj|�}nyPt	||�s�t
jd�r�d|d<dj
|�|d<n
t|d<|SWn+tk
r�}t|d<|j|d<|SXtd	||�}d
tkrAtjjj�r.td|�ddk}qGtd
|�}nt}|s�dj
|�|d<|tkr�|r�|jt|d|��n.|tkr�|r�|jt|d|��n|St
dr�d|d<dj
|�|d<|Sttd|�\}	}
|
r'|jdg�j|
�ntjjj�rk|jdt�rk|	ji|jd�d6�ntd||	�}|st|d<dj
|�|d<|tkr�|jt|tdt|��n.|tkr�|jt|tdt|��n|S|rtj|�ntd	|�}d
tkrFtd
|�}
nt}
||
ksd||kr�|jdi�r�||d|<n|r�t|d<dj
|�|d<ndj
|�|d<|tkr�|jt||d||��n/|tkr|jt||d||��n|S(u

    Ensure that the named service is dead by stopping the service if it is running

    name
        The name of the init or rc script used to manage the service

    enable
        Set the service to be enabled at boot time, ``True`` sets the service
        to be enabled, ``False`` sets the named service to be disabled. The
        default is ``None``, which does not enable or disable anything.

    sig
        The string to search for when looking for the service process with ps

    init_delay
        Add a sleep command (in seconds) before the check to make sure service
        is killed.

        .. versionadded:: 2017.7.0

    no_block : False
        **For systemd minions only.** Stops the service using ``--no-block``.

        .. versionadded:: 2017.7.0
    unameuchangesuresultuucommentuenabledutestuQService {0} not present; if created in this state run, it would have been stoppeduservice.statususervice.enableduservice.infou	StartTypeuAutouManualuThe service {0} is already deaduService {0} is set to be killeduservice.stopuwarningsutimeoutuService {0} failed to dieR!uService {0} was killedN(uAutouManual(RRR/RR0R'R(R1R2RRRRR	RRRRR)R*R5R&R-RR7R8R9R:(RR;R<R=RRR"RAR#tstop_kwargsRRERFR$((s7/usr/lib/python2.7/site-packages/salt/states/service.pytdeads�








$ 
""
##cK@s?i|d6id6td6dd6}|jt|d|��|S(uL
    Ensure that the service is enabled on boot, only use this state if you
    don't want to manage the running process, remember that if you want to
    enable a running service to use the enable: True option for the running
    or dead function.

    name
        The name of the init or rc script used to manage the service
    unameuchangesuresultuucommentN(RR5R&R(RRR((s7/usr/lib/python2.7/site-packages/salt/states/service.pytenabled�s


cK@s?i|d6id6td6dd6}|jt|d|��|S(uG
    Ensure that the service is disabled on boot, only use this state if you
    don't want to manage the running process, remember that if you want to
    disable a service to use the enable: False option for the running or dead
    function.

    name
        The name of the init or rc script used to manage the service
    unameuchangesuresultuucommentN(RR5R-R(RRR((s7/usr/lib/python2.7/site-packages/salt/states/service.pytdisabled�s


cC@sli|d6id6td6dd6}dtkrFd|d<t|d<|S|rRdnd	}iitd
6td6|6}y�td||�r�dj||�|d<|Std
r�d|d<||d<dj||�|d<|Std||�td||�r"||d<dj||�|d<ndj|�|d<|SWn+tk
rg}t|d<|j|d<|SXdS(u�
    .. versionadded:: 2017.7.0

    .. note::
        This state is only available on minions which use systemd_.

    Ensures that the named service is masked (i.e. prevented from being
    started).

    name
        Name of the service to mask

    runtime : False
        By default, this state will manage an indefinite mask for the named
        service. Set this argument to ``True`` to runtime mask the service.

    .. note::
        It is possible for a service to have both indefinite and runtime masks
        set for it. Therefore, this state will manage a runtime or indefinite
        mask independently of each other. This means that if the service is
        already indefinitely masked, running this state with ``runtime`` set to
        ``True`` will _not_ remove the indefinite mask before setting a runtime
        mask. In these cases, if it is desirable to ensure that the service is
        runtime masked and not indefinitely masked, pair this state with a
        :py:func:`service.unmasked <salt.states.service.unmasked>` state, like
        so:

        .. code-block:: yaml

            mask_runtime_foo:
              service.masked:
                - name: foo
                - runtime: True

            unmask_indefinite_foo:
              service.unmasked:
                - name: foo
                - runtime: False

    .. _systemd: https://freedesktop.org/wiki/Software/systemd/

    unameuchangesuresultuucommentuservice.maskedu,Service masking not available on this minionuruntime maskedumaskeduoldunewuService {0} is already {1}utestuService {0} would be {1}uservice.maskuService {0} was {1}uFailed to mask service {0}N(RRRR	RRRR(RtruntimeRt	mask_typetexpected_changesR"((s7/usr/lib/python2.7/site-packages/salt/states/service.pytmasked�s>+










cC@s~i|d6id6td6dd6}dtkrFd|d<t|d<|S|rRdnd	}|rdd
nd}iitd6td
6|6}y�td||�s�dj||�|d<|Stdr�d|d<||d<dj||�|d<|Std||�td||�s4||d<dj||�|d<ndj|�|d<|SWn+tk
ry}t|d<|j|d<|SXdS(uW
    .. versionadded:: 2017.7.0

    .. note::
        This state is only available on minions which use systemd_.

    Ensures that the named service is unmasked

    name
        Name of the service to unmask

    runtime : False
        By default, this state will manage an indefinite mask for the named
        service. Set this argument to ``True`` to ensure that the service is
        runtime masked.

    .. note::
        It is possible for a service to have both indefinite and runtime masks
        set for it. Therefore, this state will manage a runtime or indefinite
        mask independently of each other. This means that if the service is
        indefinitely masked, running this state with ``runtime`` set to
        ``True`` will _not_ remove the indefinite mask.

    .. _systemd: https://freedesktop.org/wiki/Software/systemd/

    unameuchangesuresultuucommentuservice.maskedu,Service masking not available on this minionuruntime maskedumaskeduruntime unmaskeduunmaskeduoldunewuService {0} was already {1}utestuService {0} would be {1}uservice.unmaskuService {0} was {1}uFailed to unmask service {0}N(RRRR	RRRR(RRLRRMtactionRNR"((s7/usr/lib/python2.7/site-packages/salt/states/service.pyR3s<









cK@s�i|d6id6td6dd6}d}	|dkr�d}
|
d}	td	||�rdtd
}qpt|d<dj|	�|d<|Sn�|dkrOtd	||�r)d
tkr�|r�dtkr�|r�td}d}
q&td
}d}
q9dtkr|rtd}d}
q9td}d}
ntd}d}
|	sp|
d}	qpn!dj|�|d<t|d<|Stdr�d|d<dj|	�|d<|S|
dkr�d
tkr�td
|�nt||�\}}
|
r�|jdg�j|
�ny|||�}Wn+t	k
r;}t|d<|j
|d<|SX|rRtj|�ni||6|d<||d<|r�dj|	�ndj|
�|d<|S(u�
    The service watcher, called to invoke the watch command.
    When called, it will restart or reload the named service.

    .. note::
        This state exists to support special handling of the ``watch``
        :ref:`requisite <requisites>`. It should not be called directly.

        Parameters for this function should be set by the watching service.
        (i.e. ``service.running``)

    name
        The name of the init or rc script used to manage the service

    sfun
        The original function which triggered the mod_watch call
        (`service.running`, for example).

    sig
        The string to search for when looking for the service process with ps

    reload
        When set, reload the service instead of restarting it.
        (i.e. ``service nginx reload``)

    full_restart
        Perform a full stop/start of a service by passing ``--full-restart``.
        This option is ignored if ``reload`` is set and is supported by only a few
        :py:func:`service modules <salt.modules.service>`.

    force
        Use service.force_reload instead of reload (needs reload to be set to True)

    init_delay
        Add a sleep command (in seconds) before the service is restarted/reloaded
    unameuchangesuresultuucommentudeadustopupeduservice.statususervice.stopuService is already {0}urunninguservice.reloaduservice.force_reloaduforcefully reloadureloaduservice.full_restartu
fully restartuservice.restarturestartu
service.startustartuedu'Unable to trigger watch for service.{0}utestuService is set to be {0}uwarningsuService {0}uFailed to {0} the serviceN(
RRRR	RRRR7R8RRR9R:(RtsfunR<treloadtfull_restartR=tforceRRtpast_participletverbRtfunc_kwargsRR!R"((s7/usr/lib/python2.7/site-packages/salt/states/service.pyt	mod_watchEsn,





	
	
	
	






(uno_blockuunmaskuunmask_runtime("t__doc__t
__future__RRRR9tsalt.utils.dataR'tsalt.utils.platformtsalt.utils.argsRR
tsalt.exceptionsRtsalt.extRRRRRRRR&R-RRRRGRIRJRKROR3RX(((s7/usr/lib/python2.7/site-packages/salt/states/service.pyt<module>;sD			f`	��		UD

Zerion Mini Shell 1.0