Exemple #1
0
def get_disabled(limit=''):
    '''
    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
    '''
    limit = limit.lower()
    if limit == 'upstart':
        return sorted(name for name in _upstart_services()
                      if not _upstart_is_enabled(name))
    elif limit == 'sysvinit':
        runlevel = _runlevel()
        return sorted(name for name in _sysv_services()
                      if not _sysv_is_enabled(name, runlevel))
    else:
        runlevel = _runlevel()
        return sorted([
            name
            for name in _upstart_services() if not _upstart_is_enabled(name)
        ] + [
            name for name in _sysv_services()
            if not _sysv_is_enabled(name, runlevel)
        ])
def get_disabled(limit=""):
    """
    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
    """
    limit = limit.lower()
    if limit == "upstart":
        return sorted(name for name in _upstart_services() if not _upstart_is_enabled(name))
    elif limit == "sysvinit":
        runlevel = _runlevel()
        return sorted(name for name in _sysv_services() if not _sysv_is_enabled(name, runlevel))
    else:
        runlevel = _runlevel()
        return sorted(
            [name for name in _upstart_services() if not _upstart_is_enabled(name)]
            + [name for name in _sysv_services() if not _sysv_is_enabled(name, runlevel)]
        )
def get_enabled(limit=''):
    '''
    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
    '''
    limit = limit.lower()
    if limit == 'upstart':
        return sorted(name for name in _upstart_services()
            if _upstart_is_enabled(name))
    elif limit == 'sysvinit':
        runlevel = _runlevel()
        return sorted(name for name in _sysv_services()
            if _sysv_is_enabled(name, runlevel))
    else:
        runlevel = _runlevel()
        return sorted(
            [name for name in _upstart_services()
                if _upstart_is_enabled(name)]
            + [name for name in _sysv_services()
            if _sysv_is_enabled(name, runlevel)])
Exemple #4
0
def _services():
    """
    Return a dict of services and their types (sysv or upstart), as well
    as whether or not the service is enabled.
    """
    if "service.all" in __context__:
        return __context__["service.all"]

    # First, parse sysvinit services from chkconfig
    rlevel = _runlevel()
    ret = {}
    for line in __salt__["cmd.run"]("/sbin/chkconfig --list").splitlines():
        cols = line.split()
        try:
            name = cols[0]
        except IndexError:
            continue
        if name in ret:
            continue
        ret.setdefault(name, {})["type"] = "sysvinit"
        ret[name]["enabled"] = _sysv_is_enabled(cols, rlevel)
    if HAS_UPSTART:
        for line in glob.glob("/etc/init/*.conf"):
            name = os.path.basename(line)[:-5]
            if name in ret:
                continue
            ret.setdefault(name, {})["type"] = "upstart"
            ret[name]["enabled"] = _upstart_is_enabled(name)
    __context__["service.all"] = ret
    return ret
Exemple #5
0
def _services():
    '''
    Return a dict of services and their types (sysv or upstart), as well
    as whether or not the service is enabled.
    '''
    if 'service.all' in __context__:
        return __context__['service.all']

    # First, parse sysvinit services from chkconfig
    rlevel = _runlevel()
    ret = {}
    for line in __salt__['cmd.run']('/sbin/chkconfig --list').splitlines():
        cols = line.split()
        try:
            name = cols[0].strip(':')
        except IndexError:
            continue
        if name in ret:
            continue
        ret.setdefault(name, {})['type'] = 'sysvinit'
        ret[name]['enabled'] = _sysv_is_enabled(cols, rlevel)
    if HAS_UPSTART:
        for line in glob.glob('/etc/init/*.conf'):
            name = os.path.basename(line)[:-5]
            if name in ret:
                continue
            ret.setdefault(name, {})['type'] = 'upstart'
            ret[name]['enabled'] = _upstart_is_enabled(name)
    __context__['service.all'] = ret
    return ret
Exemple #6
0
def disabled(name):
    '''
    Check to see if the named service is disabled to start on boot

    CLI Example::

        salt '*' service.disabled <service name>
    '''
    if _service_is_upstart(name):
        return not _upstart_is_enabled(name)
    else:
        return not _sysv_is_enabled(name)
Exemple #7
0
def disabled(name):
    """
    Check to see if the named service is disabled to start on boot

    CLI Example::

        salt '*' service.disabled <service name>
    """
    if _service_is_upstart(name):
        return not _upstart_is_enabled(name)
    _add_custom_initscript(name)
    return name in get_disabled()
Exemple #8
0
def enabled(name):
    '''
    Check to see if the named service is enabled to start on boot

    CLI Example::

        salt '*' service.enabled <service name>
    '''
    if _service_is_upstart(name):
        return _upstart_is_enabled(name)
    _add_custom_initscript(name)
    return name in get_enabled()
def disabled(name):
    """
    Check to see if the named service is disabled to start on boot

    CLI Example:

    .. code-block:: bash

        salt '*' service.disabled <service name>
    """
    if _service_is_upstart(name):
        return not _upstart_is_enabled(name)
    else:
        return not _sysv_is_enabled(name)
def enabled(name):
    '''
    Check to see if the named service is enabled to start on boot

    CLI Example:

    .. code-block:: bash

        salt '*' service.enabled <service name>
    '''
    if _service_is_upstart(name):
        return _upstart_is_enabled(name)
    else:
        return _sysv_is_enabled(name)
Exemple #11
0
def disabled(name):
    '''
    Check to see if the named service is disabled to start on boot

    CLI Example:

    .. code-block:: bash

        salt '*' service.disabled <service name>
    '''
    if _service_is_upstart(name):
        return not _upstart_is_enabled(name)
    else:
        return not _sysv_is_enabled(name)
Exemple #12
0
def enabled(name, **kwargs):
    '''
    Check to see if the named service is enabled to start on boot

    CLI Example:

    .. code-block:: bash

        salt '*' service.enabled <service name>
    '''
    if _service_is_upstart(name):
        return _upstart_is_enabled(name)
    else:
        return _sysv_is_enabled(name)