diff --git a/com.redhat.tuned.policy b/com.redhat.tuned.policy
index 1db1bf2..b34fdab 100644
--- a/com.redhat.tuned.policy
+++ b/com.redhat.tuned.policy
@@ -17,6 +17,16 @@
+
+ Show current profile selection mode
+ Authentication is required to show current profile selection mode
+
+ yes
+ yes
+ yes
+
+
+
Disable Tuned
Authentication is required to disable Tuned
diff --git a/tuned-adm.py b/tuned-adm.py
index c56dc68..a5b6b39 100755
--- a/tuned-adm.py
+++ b/tuned-adm.py
@@ -74,6 +74,9 @@ if __name__ == "__main__":
parser_auto_profile = subparsers.add_parser("auto_profile", help="enable automatic profile selection mode, switch to the recommended profile")
parser_auto_profile.set_defaults(action="auto_profile")
+ parser_profile_mode = subparsers.add_parser("profile_mode", help="show current profile selection mode")
+ parser_profile_mode.set_defaults(action="profile_mode")
+
args = parser.parse_args(sys.argv[1:])
options = vars(args)
diff --git a/tuned/admin/admin.py b/tuned/admin/admin.py
index b751ff0..fd96b0a 100644
--- a/tuned/admin/admin.py
+++ b/tuned/admin/admin.py
@@ -122,6 +122,19 @@ class Admin(object):
profile_name = None
return profile_name
+ def _get_profile_mode(self):
+ contents = str.strip(self._cmd.read_file(consts.ACTIVE_PROFILE_FILE))
+ if contents == '':
+ mode = consts.ACTIVE_PROFILE_AUTO
+ else:
+ arr = contents.split('\n')
+ if len(arr) == 1:
+ # The file was generated by old Tuned -> manual mode
+ mode = consts.ACTIVE_PROFILE_MANUAL
+ else:
+ mode = arr[1]
+ return mode
+
def _print_profile_info(self, profile, profile_info):
if profile_info[0] == True:
print("Profile name:")
@@ -166,7 +179,18 @@ class Admin(object):
return True
return self._print_profile_name(profile_name)
- # TODO action profile mode - auto/manual
+ def _print_profile_mode(self, mode):
+ print("Profile selection mode: " + mode)
+
+ def _action_dbus_profile_mode(self):
+ mode = self._controller.profile_mode()
+ self._print_profile_mode(mode)
+ return self._controller.exit(True)
+
+ def _action_profile_mode(self):
+ mode = self._get_profile_mode()
+ self._print_profile_mode(mode)
+ return True
def _profile_print_status(self, ret, msg):
if ret:
diff --git a/tuned/admin/dbus_controller.py b/tuned/admin/dbus_controller.py
index 322b8c0..fa46a0d 100644
--- a/tuned/admin/dbus_controller.py
+++ b/tuned/admin/dbus_controller.py
@@ -99,6 +99,9 @@ class DBusController(object):
def active_profile(self):
return self._call("active_profile")
+ def profile_mode(self):
+ return self._call("profile_mode")
+
def switch_profile(self, new_profile):
if new_profile == "":
return (False, "No profile specified")
diff --git a/tuned/daemon/controller.py b/tuned/daemon/controller.py
index d626bf5..087380b 100644
--- a/tuned/daemon/controller.py
+++ b/tuned/daemon/controller.py
@@ -128,6 +128,15 @@ class Controller(tuned.exports.interfaces.ExportableInterface):
else:
return ""
+ @exports.export("", "s")
+ def profile_mode(self, caller = None):
+ if caller == "":
+ return ""
+ if self._daemon.manual:
+ return consts.ACTIVE_PROFILE_MANUAL
+ else:
+ return consts.ACTIVE_PROFILE_AUTO
+
@exports.export("", "b")
def disable(self, caller = None):
if caller == "":
@@ -135,7 +144,7 @@ class Controller(tuned.exports.interfaces.ExportableInterface):
if self._daemon.is_running():
self._daemon.stop()
if self._daemon.is_enabled():
- self._daemon.set_profile(None, True, save_instantly=True)
+ self._daemon.set_profile(None, None, save_instantly=True)
return True
@exports.export("", "b")
diff --git a/tuned/daemon/daemon.py b/tuned/daemon/daemon.py
index 55f66d8..4292575 100644
--- a/tuned/daemon/daemon.py
+++ b/tuned/daemon/daemon.py
@@ -90,6 +90,11 @@ class Daemon(object):
def profile(self):
return self._profile
+ @property
+ def manual(self):
+ # manual == None means /etc/tuned/active_profile is empty -> automatic mode
+ return self._manual == True or self._manual is None
+
@property
def profile_loader(self):
return self._profile_loader