Federico Simoncelli has uploaded a new change for review.

Change subject: Move the lastCheck computation in getRepoStats
......................................................................

Move the lastCheck computation in getRepoStats

Since getVdsStats relies on repoStats for the storage domain statistics
it makes sense to move the lastCheck computation in the latter one.
Moreover the repoStats call before this patch was returning the unix
timestamp for the lastCheck (wrong) instead of the elapsed time.

Signed-off-by: Federico Simoncelli <[email protected]>
Change-Id: I58de0c517bc6940f21c7f6506854c9d9735e964b
---
M vdsm/storage/sp.py
M vdsm/utils.py
2 files changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/7993/1

diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 78fbe66..e746a88 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -19,6 +19,7 @@
 #
 
 import os
+import time
 from glob import iglob, glob
 import logging
 import threading
@@ -1355,6 +1356,7 @@
     def getRepoStats(self):
         #FIXME : this should actually be  built in HSM
         res = {}
+        now = time.time()
         for sdUUID in self.domainMonitor.monitoredDomains:
             st = self.domainMonitor.getStatus(sdUUID)
             if st.error is None:
@@ -1369,7 +1371,7 @@
                     'finish' : st.lastCheck,
                     'result' : {
                         'code'      : code,
-                        'lastCheck' : st.lastCheck,
+                        'lastCheck' : '%.1f' % (now - st.lastCheck),
                         'delay'     : str(st.readDelay),
                         'valid'     : (st.error is None)
                         },
diff --git a/vdsm/utils.py b/vdsm/utils.py
index 6093235..8286210 100644
--- a/vdsm/utils.py
+++ b/vdsm/utils.py
@@ -561,7 +561,7 @@
         for sd, d in self._imagesStatus.storageDomains.iteritems():
             stats['storageDomains'][sd] = {'code': d['code'],
                         'delay': d['delay'],
-                        'lastCheck': '%.1f' % (now - d['lastCheck']),
+                        'lastCheck': d['lastCheck'],
                         'valid': d['valid']}
         stats['elapsedTime'] = int(now - self.startTime)
         if len(self._samples) < 2:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I58de0c517bc6940f21c7f6506854c9d9735e964b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to