Change in vdsm[master]: [WIP] Add updatePolicyParameters

msivak at redhat.com msivak at redhat.com
Wed Jul 10 09:53:38 UTC 2013


Martin Sivák has uploaded a new change for review.

Change subject: [WIP] Add updatePolicyParameters
......................................................................

[WIP] Add updatePolicyParameters

This adds updatePolicyParameters to the API and a configuration
option mom/tuning_policy to the configuration file.

It is intended to be used for fine tuning MoM policy.

Change-Id: Ie2c2fce24a8a499976ef845ce1e7e40bdd439949
Signed-off-by: Martin Sivak <msivak at redhat.com>
---
M lib/vdsm/config.py.in
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/momIF.py
4 files changed, 28 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/16659/1

diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index 2a5618a..9e6392e 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -157,6 +157,10 @@
 
         ('conf', '@CONFDIR@/mom.conf', 'mom configuration file'),
 
+        ('tuning_policy', '00-parameters',
+            'name of the mom policy to be updated from '
+            'updatePolicyParameters API call'),
+
     ]),
 
     # Section: [irs]
diff --git a/vdsm/API.py b/vdsm/API.py
index 1261996..d6b02dd 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1398,6 +1398,13 @@
         except:
             return errCode['momErr']
 
+    def setMOMPolicyParameters(self, key_value_store):
+        try:
+            self._cif.mom.setPolicyParameters(key_value_store)
+            return dict(status=doneCode)
+        except:
+            return errCode['momErr']
+
     # take a rough estimate on how much free mem is available for new vm
     # memTotal = memFree + memCached + mem_used_by_non_qemu + resident  .
     # simply returning (memFree + memCached) is not good enough, as the
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 4a90658..baa7621 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -410,6 +410,10 @@
         api = API.Global()
         return api.setMOMPolicy(policy)
 
+    def setMOMPolicyParameters(self, key_value_store):
+        api = API.Global()
+        return api.setMOMPolicyParameters(key_value_store)
+
     def domainActivate(self, sdUUID, spUUID, options=None):
         domain = API.StorageDomain(sdUUID)
         return domain.activate(spUUID)
@@ -817,6 +821,7 @@
                 (self.prepareForShutdown, 'prepareForShutdown'),
                 (self.setLogLevel, 'setLogLevel'),
                 (self.setMOMPolicy, 'setMOMPolicy'),
+                (self.setMOMPolicyParameters, 'setMOMPolicyParameters'),
                 (self.vmHotplugDisk, 'hotplugDisk'),
                 (self.vmHotunplugDisk, 'hotunplugDisk'),
                 (self.vmHotplugNic, 'hotplugNic'),
diff --git a/vdsm/momIF.py b/vdsm/momIF.py
index d0f63d1..cb348e6 100644
--- a/vdsm/momIF.py
+++ b/vdsm/momIF.py
@@ -20,6 +20,8 @@
 
 import logging
 import threading
+from vdsm.config import config
+
 try:
     import mom
     _momAvailable = True
@@ -37,13 +39,13 @@
 
 class MomThread(threading.Thread):
 
-    def __init__(self, momconf):
+    def __init__(self, momconf, mominstance=None):
         if not _momAvailable:
             raise MomNotAvailableError()
 
         self.log = logging.getLogger("MOM")
         self.log.info("Starting up MOM")
-        self._mom = mom.MOM(momconf)
+        self._mom = mominstance or mom.MOM(momconf)
         threading.Thread.__init__(self, target=self._mom.run, name="MOM")
         self.start()
 
@@ -60,6 +62,14 @@
         # mom.setPolicy will raise an exception on failure.
         self._mom.setPolicy(policyStr)
 
+    def setPolicyParameters(self, key_value_store):
+        # mom.setNamedPolicy will raise an exception on failure.
+        # Prepare in-memory policy file with tuning variables
+        policy_string = "\n".join(["(defvar %s %r)" % (k,v)
+                                   for k,v in key_value_store.iteritems()])
+
+        self._mom.setNamedPolicy(config.get("mom", "tuning_policy"), policy_string)
+
     def stop(self):
         if self._mom is not None:
             self.log.info("Shutting down MOM")


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2c2fce24a8a499976ef845ce1e7e40bdd439949
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Sivák <msivak at redhat.com>


More information about the vdsm-patches mailing list