[node-patches] Change in ovirt-node[master]: DRAFT: RFC: Incomplete version of tuned configuration

mburns at redhat.com mburns at redhat.com
Tue May 21 20:54:04 UTC 2013


Michael Burns has uploaded a new change for review.

Change subject: DRAFT: RFC: Incomplete version of tuned configuration
......................................................................

DRAFT: RFC: Incomplete version of tuned configuration

* Add tuned= kernel command line option
* Add tuned python module that interacts with tuned-adm
to do all tuned configuration work
* Add TUI page that lists current tuned profiles available and
shows the currently selected one.

Change-Id: Ic1ed6db48bfeeed962f1bff656d71243281e1597
Signed-off-by: Mike Burns <mburns at redhat.com>
---
M ovirt-node.spec.in
M scripts/ovirt-init-functions.sh.in
A src/ovirt/node/setup/performance_page.py
A src/ovirt/node/utils/tuned.py
4 files changed, 162 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/62/14962/1

diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index d2a199c..de68b43 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -62,6 +62,7 @@
 Requires:       cracklib-python
 Requires:       dracut
 Requires:       /bin/hostname
+Requires:       tuned
 %if ! %{is_systemd}
 Requires:       grub
 # for applying patches in %post
diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index d78a5c1..a605c2a 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -200,6 +200,7 @@
     #   syslog=server[:port]
     #   collectd=server[:port]
     #   hostname=fqdn
+    #   tuned=profile
     #   TBD logrotate maxsize
     #   rhn_type=[classic|sam]
     #   rhn_url=SATELLITE_URL
@@ -383,6 +384,10 @@
 
     # a list of plugin variables that were set
     plugin_vars=
+
+    #tuned=profile
+    # the tuned profile to run by default
+    tuned=virtual-host
 
     cat /etc/system-release >> $OVIRT_LOGFILE
 
@@ -725,6 +730,9 @@
             ;;
             iscsi_install*)
             iscsi_install="Y"
+            ;;
+            tuned*)
+            tuned_profile=${i#tuned=}
             ;;
             swap_encrypt=* | ovirt_swap_encrypt=* )
             i=${i#ovirt_swap_encrypt=}
@@ -1296,6 +1304,9 @@
             service netconsole restart
         }
 
+        # activate the tuned profile specified in OVIRT_TUNED
+        python -m ovirt.node.utils.tuned.set_active_profile $OVIRT_TUNED_PROFILE
+
         if is_standalone; then
             return 0
         fi
diff --git a/src/ovirt/node/setup/performance_page.py b/src/ovirt/node/setup/performance_page.py
new file mode 100644
index 0000000..ca4e85b
--- /dev/null
+++ b/src/ovirt/node/setup/performance_page.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# performance_page.py - Copyright (C) 2013 Red Hat, Inc.
+# Written by Mike Burns <mburns at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.  A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+from ovirt.node import plugins, ui, valid, utils
+from ovirt.node.config import defaults
+from ovirt.node.plugins import Changeset
+import ovirt.node.utils.tuned as tuned
+
+"""
+Configure Performance Profiles
+"""
+
+
+class Plugin(plugins.NodePlugin):
+    _model = None
+
+    def name(self):
+        return "Performance"
+
+    def rank(self):
+        return 100
+
+    def model(self):
+        profile = tuned.get_active_profile()
+        model = {
+            "tuned.profile": profile,
+        }
+        return model
+
+    def validators(self):
+        return {}
+
+    def ui_content(self):
+        profiles = [(profile,profile) for profile in tuned.get_available_profiles()]
+        # Include an option to disable tuned
+        profiles.append(("None","None"))
+
+        ws = [ui.Header("header", "tuned Configuration"),
+              ui.Label("label", "Choose the tuned profile you would " +
+                       "like to apply to this system."),
+              ui.Divider("divider[0]"),
+              ui.KeywordLabel("tuned.profile", "Current Active Profile:  "),
+              ui.Table("tuned.profile", "", "Available tuned Profiles",
+                       profiles),
+              ]
+        page = ui.Page("page", ws)
+        self.widgets.add(page)
+        return page
+
+    def on_change(self, changes):
+        pass
+
+    def on_merge(self, effective_changes):
+        pass
diff --git a/src/ovirt/node/utils/tuned.py b/src/ovirt/node/utils/tuned.py
new file mode 100644
index 0000000..11b8572
--- /dev/null
+++ b/src/ovirt/node/utils/tuned.py
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# tuned.py - Copyright (C) 2012 Red Hat, Inc.
+# Written by Mike Burns <mburns at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.  A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+"""
+Some convenience functions related to tuned profiles
+"""
+
+from ovirt.node.utils import process
+
+
+def get_available_profiles():
+    """Gets a list of tuned profiles available on the system.
+
+    Returns:
+        A list of profiles
+    """
+    prof_list = []
+    for i in process.check_output("/usr/sbin/tuned-adm list").split("\n"):
+        if "- " in i:
+            prof_list.append(i.replace("- ", ""))
+    return prof_list
+
+
+def get_active_profile():
+    """Gets the active tuned profile on the system.
+
+    Returns:
+        A string with the active tuned profile
+    """
+    profile = process.check_output("/usr/sbin/tuned-adm active")
+    if "No current active" in profile:
+        return "None"
+    else:
+        return profile.replace("\n", "").split(" ")[3]
+
+
+def set_active_profile(profile):
+    """Sets the active tuned profile on the system.
+
+    Returns:
+        A boolean based on the return of tuned-adm
+    """
+    try:
+        if ( profile == "None" or profile = "off" ):
+            ret = process.check_call("/usr/sbin/tuned-adm off")
+            if ret == 0:
+                return True
+            else:
+                return False
+        elif profile not in get_available_profiles()
+            # error
+            #FIXME:  log some message
+            return False
+        else:
+            ret = process.check_call("/usr/sbin/tuned-adm profile %s" % profile)
+            if ret == 0:
+                return True
+            else:
+                return False
+    except:
+        return False


--
To view, visit http://gerrit.ovirt.org/14962
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1ed6db48bfeeed962f1bff656d71243281e1597
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Michael Burns <mburns at redhat.com>



More information about the node-patches mailing list