Source code for insights.parsers.tuned

Tuned - command ``/usr/sbin/tuned-adm list``

This parser reads the output of the ``/usr/sbin/tuned-adm list`` command and
reads it into a simple dictionary in the ``data`` property with two of three

* ``available`` - the list of available profiles
* ``active`` - the active profile name
* ``preset`` - the profile name that's preset to be used when tuned is active

The ``active`` key is available when ``tuned`` is running, because the active
profile is only listed when the daemon is active.  If ``tuned`` is not
running, the tuned-adm command will list the profile that will be used when
the daemon is running, and this is given in the ``preset`` key.

Sample data::

    Available profiles:
    - balanced
    - desktop
    - latency-performance
    - network-latency
    - network-throughput
    - powersave
    - throughput-performance
    - virtual-guest
    - virtual-host
    Current active profile: virtual-guest


    >>> result = shared[Tuned]
    >>> 'active' in
    >>> len(['available'])
    >>> 'balanced' in['available']

from .. import parser, CommandParser
from insights.specs import Specs

[docs]@parser(Specs.tuned_adm) class Tuned(CommandParser): """ Parse data from the ``/usr/sbin/tuned-adm list`` command. """
[docs] def parse_content(self, content): = {}['available'] = [] for line in content: if line.startswith('-'):['available'].append(line.split('- ')[1]) elif line.startswith('Current'):['active'] = line.split(': ')[1] elif line.startswith('Preset'):['preset'] = line.split(': ')[1]
# Ignore everything else for now