Change in vdsm[master]: DONTMERGE: bench-only: fake MOM.

fromani at redhat.com fromani at redhat.com
Mon Jan 19 15:41:02 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: DONTMERGE: bench-only: fake MOM.
......................................................................

DONTMERGE: bench-only: fake MOM.

Let's pretend MOM is not in the VDSM process.

This patch is posted on gerrit only for easier
sharing. Should never be merged.

Change-Id: Icccf080e504e780f8a091835c7962e514796fe92
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M lib/vdsm/config.py.in
M vdsm/clientIF.py
M vdsm/momIF.py
3 files changed, 41 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/83/37083/1

diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index b76de8d..357e09e 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -350,6 +350,8 @@
         ('python_warnings_enable', 'false',
             'Display python warnings in the log'),
 
+        ('fake_mom', 'false',
+            'Fakes MOM. Use ONLY for benchmark/development purposes!'),
     ]),
 
 ]
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 85c0705..5ab579c 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -28,7 +28,7 @@
 
 import alignmentScan
 from vdsm.config import config
-from momIF import MomThread
+from momIF import MomThread, FakeMom
 from vdsm.compat import pickle
 from vdsm.define import doneCode, errCode
 import libvirt
@@ -212,7 +212,10 @@
     def _prepareMOM(self):
         momconf = config.get("mom", "conf")
 
-        self.mom = MomThread(momconf)
+        if config.getboolean('devel', 'fake_mom'):
+            self.mom = FakeMom(momconf)
+        else:
+            self.mom = MomThread(momconf)
 
     def prepareForShutdown(self):
         """
diff --git a/vdsm/momIF.py b/vdsm/momIF.py
index d70d826..7ade139 100644
--- a/vdsm/momIF.py
+++ b/vdsm/momIF.py
@@ -92,3 +92,37 @@
             return 'active'
         else:
             return 'inactive'
+
+
+class FakeMom(object):
+
+    def __init__(self, momconf):
+        self.log = logging.getLogger("MOM")
+        self.log.info("Faking up MOM")
+        self._conf = momconf
+
+    def getKsmStats(self):
+        """
+        Get information about KSM and convert memory data from page
+        based values to MiB.
+        """
+        ret = {}
+        ret['ksmState'] = False
+        ret['ksmPages'] = 0
+        ret['memShared'] = 0
+        ret['memShared'] = 0
+        ret['ksmCpu'] = 0
+        return ret
+
+    def setPolicy(self, policyStr):
+        # mom.setPolicy will raise an exception on failure.
+        pass
+
+    def setPolicyParameters(self, key_value_store):
+        pass
+
+    def stop(self):
+        self.log.info("Shutting down Faked MOM")
+
+    def getStatus(self):
+        return 'inactive'


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icccf080e504e780f8a091835c7962e514796fe92
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list