Change in vdsm[master]: sampling: take storageDomains directly from storage subsys

danken at redhat.com danken at redhat.com
Sun Nov 17 17:21:36 UTC 2013


Dan Kenigsberg has uploaded a new change for review.

Change subject: sampling: take storageDomains directly from storage subsys
......................................................................

sampling: take storageDomains directly from storage subsys

HostStatsThread does not poll storageDomains statistics, but still it is
used to relay them from the storage subsystem to the getVdsStats api.
This is cumbersome and confusing. This patch eliminates the need to pass
a clientIF reference to the HostStatsThread, and keeps the knowledge of
which statistic elements are provided (code, delay, lastCheck, etc)
with the storage subsystem.

Change-Id: I1a86b828fdf43d74bf4475d2c6632c4511519356
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M tests/functional/storageTests.py
M vdsm/API.py
M vdsm/clientIF.py
M vdsm/sampling.py
4 files changed, 13 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/34/21334/1

diff --git a/tests/functional/storageTests.py b/tests/functional/storageTests.py
index e9b2c4f..542f72a 100644
--- a/tests/functional/storageTests.py
+++ b/tests/functional/storageTests.py
@@ -199,6 +199,12 @@
                     r = self.s.activateStorageDomain(sdid, poolid)
                     self.assertVdsOK(r)
 
+        r = self.s.getVdsStats()
+        self.assertVdsOK(r)
+        self.assertIn('storageDomains', r['info'])
+        self.assertEquals(set(r['info']['storageDomains'].keys()),
+                          set(domains.keys()))
+
     def _createVolume(self, images, layout, rollback):
         for poolid, domains in layout.iteritems():
             for sdid, imageList in domains.iteritems():
diff --git a/vdsm/API.py b/vdsm/API.py
index 48eecc6..1195fa7 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1191,6 +1191,11 @@
 
         stats = {}
         decStats = self._cif._hostStats.get()
+        decStats['storageDomains'] = {}
+        if self._cif.irs:
+            decStats['storageDomains'] = self._cif.irs.repoStats()
+            del decStats['storageDomains']["status"]
+
         for var in decStats:
             stats[var] = utils.convertToStr(decStats[var])
         stats['memAvailable'] = self._memAvailable() / Mbytes
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 0b67e45..7c3a0ea 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -83,7 +83,7 @@
             self.gluster = None
         try:
             self.vmContainer = {}
-            self._hostStats = sampling.HostStatsThread(cif=self, log=log)
+            self._hostStats = sampling.HostStatsThread(log=log)
             self._hostStats.start()
             self.lastRemoteAccess = 0
             self._memLock = threading.Lock()
diff --git a/vdsm/sampling.py b/vdsm/sampling.py
index d87f5bf..5a46b39 100644
--- a/vdsm/sampling.py
+++ b/vdsm/sampling.py
@@ -364,7 +364,7 @@
     AVERAGING_WINDOW = 5
     SAMPLE_INTERVAL_SEC = 2
 
-    def __init__(self, cif, log):
+    def __init__(self, log):
         self.startTime = time.time()
 
         threading.Thread.__init__(self)
@@ -376,7 +376,6 @@
         self._lineRate = (sum(self._ifrates) or 1000) * (10 ** 6) / 8
         self._lastSampleTime = time.time()
 
-        self._cif = cif
         self._pid = os.getpid()
         self._ncpus = max(os.sysconf('SC_NPROCESSORS_ONLN'), 1)
 
@@ -416,7 +415,6 @@
     def get(self):
         stats = self._getInterfacesStats()
         stats['cpuSysVdsmd'] = stats['cpuUserVdsmd'] = 0.0
-        stats['storageDomains'] = self._getStorageDomainsStats()
         stats['elapsedTime'] = int(time.time() - self.startTime)
         if len(self._samples) < 2:
             return stats
@@ -508,23 +506,4 @@
         stats['rxDropped'] = rxDropped
         stats['txDropped'] = txDropped
 
-        return stats
-
-    def _getStorageDomainsStats(self):
-        stats = {}
-        if self._cif.irs:
-            res = self._cif.irs.repoStats()
-            del res["status"]
-            if "args" in res:
-                del res["args"]
-
-            for sd, d in res.iteritems():
-                stats[sd] = {
-                    'code': d['code'],
-                    'delay': d['delay'],
-                    'lastCheck': d['lastCheck'],
-                    'valid': d['valid'],
-                    'version': d['version'],
-                    'acquired': d['acquired'],
-                }
         return stats


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a86b828fdf43d74bf4475d2c6632c4511519356
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list