Merge pull request #279 from olysonek/tuned-adm-active-post-loaded-profile
[For v2.15] Make tuned-adm indicate which profile is post-loaded
This commit is contained in:
commit
65e818ae8b
5 changed files with 65 additions and 3 deletions
|
|
@ -27,6 +27,16 @@
|
|||
</defaults>
|
||||
</action>
|
||||
|
||||
<action id="com.redhat.tuned.post_loaded_profile">
|
||||
<description>Show active post-loaded profile</description>
|
||||
<message>Authentication is required to show active post-loaded profile</message>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
</action>
|
||||
|
||||
<action id="com.redhat.tuned.disable">
|
||||
<description>Disable Tuned</description>
|
||||
<message>Authentication is required to disable Tuned</message>
|
||||
|
|
|
|||
|
|
@ -131,6 +131,16 @@ class Admin(object):
|
|||
manual = profile is not None
|
||||
return consts.ACTIVE_PROFILE_MANUAL if manual else consts.ACTIVE_PROFILE_AUTO
|
||||
|
||||
def _dbus_get_post_loaded_profile(self):
|
||||
profile_name = self._controller.post_loaded_profile()
|
||||
if profile_name == "":
|
||||
profile_name = None
|
||||
return profile_name
|
||||
|
||||
def _get_post_loaded_profile(self):
|
||||
profile_name = self._cmd.get_post_loaded_profile()
|
||||
return profile_name
|
||||
|
||||
def _print_profile_info(self, profile, profile_info):
|
||||
if profile_info[0] == True:
|
||||
print("Profile name:")
|
||||
|
|
@ -149,7 +159,12 @@ class Admin(object):
|
|||
def _action_dbus_profile_info(self, profile = ""):
|
||||
if profile == "":
|
||||
profile = self._dbus_get_active_profile()
|
||||
return self._controller.exit(self._print_profile_info(profile, self._controller.profile_info(profile)))
|
||||
if profile:
|
||||
res = self._print_profile_info(profile, self._controller.profile_info(profile))
|
||||
else:
|
||||
print("No current active profile.")
|
||||
res = False
|
||||
return self._controller.exit(res)
|
||||
|
||||
def _action_profile_info(self, profile = ""):
|
||||
if profile == "":
|
||||
|
|
@ -171,20 +186,42 @@ class Admin(object):
|
|||
print("Current active profile: %s" % profile_name)
|
||||
return True
|
||||
|
||||
def _print_post_loaded_profile(self, profile_name):
|
||||
if profile_name:
|
||||
print("Current post-loaded profile: %s" % profile_name)
|
||||
|
||||
def _action_dbus_active(self):
|
||||
return self._controller.exit(self._print_profile_name(self._dbus_get_active_profile()))
|
||||
active_profile = self._dbus_get_active_profile()
|
||||
res = self._print_profile_name(active_profile)
|
||||
if res:
|
||||
post_loaded_profile = self._dbus_get_post_loaded_profile()
|
||||
self._print_post_loaded_profile(post_loaded_profile)
|
||||
return self._controller.exit(res)
|
||||
|
||||
def _action_active(self):
|
||||
try:
|
||||
profile_name = self._get_active_profile()
|
||||
post_loaded_profile = self._get_post_loaded_profile()
|
||||
# The result of the DBus call active_profile includes
|
||||
# the post-loaded profile, so add it here as well
|
||||
if post_loaded_profile:
|
||||
if profile_name:
|
||||
profile_name += " "
|
||||
else:
|
||||
profile_name = ""
|
||||
profile_name += post_loaded_profile
|
||||
except TunedException as e:
|
||||
self._error(str(e))
|
||||
return False
|
||||
if profile_name is not None and not self._tuned_is_running():
|
||||
print("It seems that tuned daemon is not running, preset profile is not activated.")
|
||||
print("Preset profile: %s" % profile_name)
|
||||
if post_loaded_profile:
|
||||
print("Preset post-loaded profile: %s" % post_loaded_profile)
|
||||
return True
|
||||
return self._print_profile_name(profile_name)
|
||||
res = self._print_profile_name(profile_name)
|
||||
self._print_post_loaded_profile(post_loaded_profile)
|
||||
return res
|
||||
|
||||
def _print_profile_mode(self, mode):
|
||||
print("Profile selection mode: " + mode)
|
||||
|
|
|
|||
|
|
@ -117,6 +117,9 @@ class DBusController(object):
|
|||
def profile_mode(self):
|
||||
return self._call("profile_mode")
|
||||
|
||||
def post_loaded_profile(self):
|
||||
return self._call("post_loaded_profile")
|
||||
|
||||
def switch_profile(self, new_profile):
|
||||
if new_profile == "":
|
||||
return (False, "No profile specified")
|
||||
|
|
|
|||
|
|
@ -210,6 +210,12 @@ class Controller(tuned.exports.interfaces.ExportableInterface):
|
|||
mode = consts.ACTIVE_PROFILE_MANUAL if manual else consts.ACTIVE_PROFILE_AUTO
|
||||
return mode, ""
|
||||
|
||||
@exports.export("", "s")
|
||||
def post_loaded_profile(self, caller = None):
|
||||
if caller == "":
|
||||
return ""
|
||||
return self._daemon.post_loaded_profile or ""
|
||||
|
||||
@exports.export("", "b")
|
||||
def disable(self, caller = None):
|
||||
if caller == "":
|
||||
|
|
|
|||
|
|
@ -161,6 +161,12 @@ class Daemon(object):
|
|||
def manual(self):
|
||||
return self._manual
|
||||
|
||||
@property
|
||||
def post_loaded_profile(self):
|
||||
# Return the profile name only if the profile is active. If
|
||||
# the profile is not active, then the value is meaningless.
|
||||
return self._post_loaded_profile if self._profile else None
|
||||
|
||||
@property
|
||||
def profile_loader(self):
|
||||
return self._profile_loader
|
||||
|
|
|
|||
Loading…
Reference in a new issue