1
0
Fork 0
Commit graph

47 commits

Author SHA1 Message Date
dufuhang
ae2cfd52e8 Fix the error in the raise statement of check_positive()
1. In the raise statement of the check_positive() function, the error message conflicts with the if condition.
2. If the value of val is 0, it passes the if condition but raises an error message stating [0 has to be >= 0].
3. This PR removes the = from the raise statement, so when val is 0,
it will correctly prompt that the value of val [has to be > 0].

Signed-off-by: dufuhang <dufuhang@kylinos.cn>
2024-09-14 16:49:51 +08:00
Pavol Žáčik
8255b1f34e
Re-check dbus when (re)starting TuneD from tuned-adm profile
If TuneD was simply off before the restart, we can then
switch the profile using the dbus method. Otherwise we
fallback to a profile switch via setting the active_profile
file (where we do not check for success).
2024-04-17 12:07:21 +02:00
Pavol Žáčik
90ea23b8b3
Add an option to configure profile directories
Resolves: RHEL-26157
2024-03-28 10:56:49 +01:00
Pavol Žáčik
db6b880bb6
Add API functions to retrieve active instances and their devices
Resolves: RHEL-15137

Appropriate commands are added to tuned-adm as well.

`get_instances`: Retrieves a list of active instances of a given
plugin or all active instances.

`instance_get_devices`: Retrieves a list of devices assigned
to a given instance.
2023-11-14 15:36:12 +01:00
Pavol Žáčik
f58c25d0bc
Add a tuned-adm command for moving devices between plugin instances
Resolves: RHEL-15141

Until now, this was only possible by manually sending a message to
TuneD via the DBus API.
2023-11-09 19:58:34 +01:00
Jaroslav Škarvada
476be07b46
Use python3 interpreter by default
This may ease development, because development environment will
be probably already on python3.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2019-11-18 11:21:33 +01:00
Tomas Korbar
c0a2e1964a Fix problem with tuned-adm list command on python2
Unfortunately non-required subcommands are not supported by argparse
module on python2, so selection between plugins and profiles must be
done by new positional non-required arguments "profiles" and
"plugins"

Examples of usage:
$ tuned-adm list -- will list tuned profiles like before
$ tuned-adm list profiles -- new command which has the same function
as tuned-adm list
$ tuned-adm list plugins -- will list tuned accessible plugins
$ tuned-adm list plugins [-v|--verbose] -- will list tuned accessible
plugins + their configuration options and hints how to use them

Signed-off-by: Tomas Korbar <tkorbar@redhat.com>
2019-03-08 14:18:11 +01:00
Tomas Korbar
a0f3bb3bb0 Fix typo in tuned-adm
list plugins command had badly spelled option verbouse
changed to verbose

Signed-off-by: Tomas Korbar <tkorbar@redhat.com>
2019-03-07 14:49:20 +01:00
Tomas Korbar
e320c70d3d Move plugin and hint listing functionality into dbus 2018-12-05 12:18:48 +01:00
Ondřej Lysoněk
39ac6d76e8 tuned-adm: Fix a traceback when run without action specified
The previous fix was not sufficient, tuned-adm still tracebacks
in cases when options are specified, but an action is not, e.g.:
$ python3 ./tuned-adm.py -a
Traceback (most recent call last):
  File "./tuned-adm.py", line 106, in <module>
    action_name = options.pop("action")
KeyError: 'action'

The object returned by ArgumentParser.add_subparsers recognizes
a 'required' attribute (at least in Python 3), which is probably
meant to allow to make specifying an action required, but I wasn't
able to make it work properly, I get errors such as
Traceback (most recent call last):
  File "./tuned-adm.py", line 98, in <module>
    args = parser.parse_args(sys.argv[1:])
  File "/usr/lib64/python3.6/argparse.py", line 1730, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib64/python3.6/argparse.py", line 1762, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib64/python3.6/argparse.py", line 1997, in _parse_known_args
    ', '.join(required_actions))
TypeError: sequence item 0: expected str instance, NoneType found

which I think is not expected. The error is raised here:
6ceab46a60/Lib/argparse.py (L2001)

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-07-10 11:20:01 +02:00
Ondřej Lysoněk
5ff48f7bd2 tuned-adm: Fix a traceback when run without arguments
Running tuned-adm without arguments using Python 3 results in
a traceback. This is because in this case parse_args does not
exit with a usage message in Python 3 and the 'action' option
is then undefined. So let's check for this case and print the
usage message ourselves. There may be a better solution to this,
but I wasn't able to come up with anything in a reasonable amount
of time.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-07-10 00:24:00 +02:00
Jaroslav Škarvada
f19b7c5713
Fixed compatibility with python-3.7
In python-3.7 async is a keyword, so it cannot be redefined.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2018-07-04 23:27:38 +02:00
Ondřej Lysoněk
6c1df704ce tuned-adm: Print log excerpt when changing profile
Print messages logged during a profile switch to stderr (this affects
the "profile" and "auto_profile" commands). By default messages with
log level ERROR and higher are printed. This can be changed using the
--loglevel command line option. Valid values are debug, info, warn,
error, console, none ('none' can be used to disable the log printing).
E.g.:
tuned-adm --loglevel info profile powersave

Log printing cannot be used when --async is used.

Resolves: rhbz#1538745

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-06-11 09:56:14 +02:00
Ondřej Lysoněk
6473d2082b Drop TunedAdminException, it's not raised anywhere
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-06-11 08:10:07 +02:00
Jaroslav Škarvada
f563c7d756
An attempt to port Tuned to python3 and keeping it python2 compatible
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2017-12-21 10:20:13 +01:00
Ondřej Lysoněk
cd655df597 Add 'tuned-adm profile_mode' command
Implement a new 'tuned-adm profile_mode' command, which prints
the current profile mode - automatic vs. manual.

Related: rhbz#1459146

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2017-08-03 15:24:17 +02:00
Ondřej Lysoněk
bc8ffcfb23 Introduce the concept of manually vs automatically set profile
A profile can now be set in two modes: automatic and manual.

When the automatic mode is active, Tuned always activates the
recommended profile upon startup. This mode can be set using
the following command:
tuned-adm auto_profile

When the manual mode is active, the previously applied profile
is activated upon startup. This mode can be set by switching
to the desired profile, e.g.
tuned-adm profile throughput-performance

The mode is saved on the second line of /etc/tuned/active_profile.

When the file /etc/tuned/active_profile does not exist, or is
empty, automatic mode is enabled. When the file has only one line,
i.e. it was generated by a previous Tuned version, manual mode
is enabled so that the upgrade doesn't cause unexpected active profile
changes.

Related: rhbz#1459146

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2017-08-03 15:23:54 +02:00
Ondřej Lysoněk
82997069b4 List available profiles on 'tuned-adm profile'
List available profiles when 'tuned-adm profile' is run
without a profile name.

Resolves: rhbz#988433

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2017-04-21 16:43:55 +02:00
Jaroslav Škarvada
e9c8815c0e tuned-adm: simplified no_deamon check regarding DBus
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-07-14 18:09:46 +02:00
Jaroslav Škarvada
b70a93dd8a tuned-adm: fixed detection of no_daemon mode
In no_daemon mode it doesn't try to query DBus, so it doesn't
output DBus error.

Resolves: rhbz#1351536

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-07-14 17:39:29 +02:00
Jaroslav Škarvada
b117e9204b tuned-adm: rewrote multithreading code to glib
The glib/dbus doesn't like multithreading which is not handled
by them, thus the code may segfault. According to
https://bugzilla.redhat.com/show_bug.cgi?id=1330127#c2
it is not supportd and dbus-glib/dbus-python are not thread safe.
This commit moves multithreading under glib and handles all
in the glib mainloop, thus it may no longer segfaults.

It also adds --timeout, -t command line parameter which may
specify timeout for the sync operations, e.g.:
 # tuned-adm --timeout 200 profile balanced
wil use 200 seconds timeout when waiting for the profile to
load.

The default timeout was increased to 90 seconds to match
systemd default timeouts.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-06-07 17:58:45 +02:00
Jaroslav Škarvada
a174592cfd verify: added ignore-missing mode
The verify command can now be run in ignore-missing mode. In this mode
missing/non-supported settings (i.e. those which current value is None)
are ignored and not treated as errors.

The tuned-adm got new verify options -i and --ignore-missing which
enables the ignore-missing mode, usage:
  tuned-adm verify -i
or:
  tuned-adm verify --ignore-missing

The DBus interface got new method 'verify_profile_ignore_missing' which
does the verification in ignore-missing mode.

Resolves: rhbz#1243807

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-04-22 18:05:16 +02:00
Jaroslav Škarvada
67f78d632e tuned-adm: synchronous profile switching
By default tuned-adm now synchronously switch profiles, i.e it waits untill
the profile is applied and then returns to the shell. It returns with
exitcode 0 if profile is correctly applied. If there is an error it uses
exitcode > 0 (currently only 1 is used) and displays error. For reverting
to old behaviour (i.e. asynchronous profile switching) when the tuned-adm
returns immediately there is an tuned-adm command line option -a (or --async).

D-Bus API was extended to allow synchronous profile switching. Now the
"profile_changed" D-Bus signal is sent when the profile is applied. The
signal contains the following data:

profile_name:string - the name of the profile which was applied
result:boolean      - status of the operation, true if OK, false on error
errstr:string       - string containing description of the error (if result is
                      false)

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-04-21 14:55:19 +02:00
Jaroslav Škarvada
c24e2ea0ca Added support for 'summary' and 'description' of profiles
Added new tuned-adm functionality 'profile_info'. It has optional parameter
'profile_name'. If called without parameter, active profile is used.
It outputs name of the profile it is querying, profile summary, and profile
description. If there is no profile summary or description available it
outputs empty string(s).

Extended tuned-adm 'list' functionality. It now displays profile summary
in the list (if available).

Added summary to profiles.

Extended D-Bus API to support the new feature and for better Cockpit support:
 - Added 'profile_info' method. It gets profile_name argument and it queries
   the requested profile for information. If profile_name is empty string it
   queries the active/selected profile. It returns tuple of the following
   format (status, profile_name, summary, description), where status is
   boolean. If it is False, the query mechanism failed and the other fields
   don't contain valid data
 - Added 'profiles2' method. It's extension of 'profiles' method. It returns
   list of tuples. Tuples have following format:
   (profile_name, profile_summary)

Related: rhbz#1228356
Fixes: #46

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-01-05 11:28:25 +01:00
Jaroslav Škarvada
4cefd36c87 tuned: added one-shot no daemon mode
Most of the functionality don' work in this mode, it just
applies the settings, no rollback possible.

Disable daemon by setting 'daemon = 0' in /etc/tuned/tuned-main.conf

This settings can be overridden if running tuned with '-d' command line
option. In such case daemon mode will be used.

Resolves: rhbz#1068663

Also fixed interpretation of booleans in main config.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-07-02 17:17:31 +02:00
Jaroslav Škarvada
c73bc90ae8 recommend: add global config option to disable 'recommend' functionality
On some platforms the 'recommend' functionality doens't make sense
as there is only one product variant. On such platforms the recommend
functionality can be disabled by adding/changing the following in
the global config (/etc/tuned/tuned-main.conf):

recommend_command = 0

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-06-10 16:26:36 +02:00
Jaroslav Škarvada
6940d280b6 tuned: added verify command
The verify command verifies whether the current system settings matches
activated profile. It also writes all settings from the active profile
with the current / expected values to the log. It is good for checking
what is exactly set and what changed during the run.

Currently custom commands and plugin_scheduler are not supported.

Resolves: rhbz#1150047
Fixes: #34

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-05-18 18:55:01 +02:00
Jaroslav Škarvada
56ecbd362e tuned: Improved error messages
Made tuned error messages less verbose, but more descriptive if running without
debug option. Also made class from the tuned.utils.commands helper functions.
Its logging can be enabled / disabled.

Resolves: rhbz#1068699

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2014-09-24 16:15:06 +02:00
Jaroslav Škarvada
d233fd7c31 misc: bumped year in copyright to 2013
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-11-27 09:30:07 +01:00
Jaroslav Škarvada
f560833d7a tuned, tuned-adm: moved dbus consts to consts file
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-02-18 12:18:18 +01:00
Jaroslav Škarvada
b68fea0ca9 tuned, tuned-adm: added new option --version, -v to show version
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-02-18 12:15:25 +01:00
Jaroslav Škarvada
3d95e77f78 implemented recommend profile functionality
resolves: rhbz#848935
2012-11-29 10:25:05 +01:00
Jan Vcelak
a49f53e60f GPL headers only into executables and main module
GPL license does not require all files to have the copyright notice
and header. To save some space, I removed the headers from all files
except the executables and the main Python module.
2012-11-09 12:27:20 +01:00
Jan Vcelak
718a611a7f tuned-adm: switch completely to DBus 2012-11-05 17:02:52 +01:00
Jan Vcelak
09d20c648a run python interpret with '-Es' options 2012-10-30 11:40:29 +01:00
Jaroslav Škarvada
135e19f654 Use /run instead of /var/run 2012-10-25 12:05:16 +02:00
Jaroslav Škarvada
2edd5852cb tuned-adm: check EUID instead of UID 2012-10-19 17:07:25 +02:00
Jaroslav Škarvada
6f6e366488 Fixed 'null' profile selection 2012-10-10 22:55:52 +02:00
Chris Lockfort
bf0a1f3a68 tuned-adm: sort available profiles 2012-06-08 10:46:20 +02:00
HanzZ
d0028379f4 Load/store more profiles in active_profile file 2012-05-07 09:33:23 +02:00
HanzZ
99a863f517 Fix tuned-adm typo 2012-04-06 09:53:58 +02:00
Jaroslav Škarvada
ea412c9064 tuned-adm: added check if requested profile exists 2012-03-30 19:05:40 +02:00
Jaroslav Škarvada
ae3f629827 tuned: config file suffix changed to .conf
profiles: config files renamed to end with .conf
man: minor update of tuned.conf.5
Makefile: install tuned_powertop_profile.py script
2012-03-28 16:26:18 +02:00
Jan Kaluza
0541ad4081 Implement tuned-adm off 2012-03-14 09:52:27 +01:00
Jan Kaluza
3a5db1257a first try of tuned-adm active command 2012-03-13 14:02:52 +01:00
Jan Kaluza
83a7845f93 tuned-adm list 2012-03-13 13:58:45 +01:00
Jan Kaluza
0faaa74df3 tuned.cfg man page + initial tuned-adm 2012-03-13 13:20:52 +01:00