Change in vdsm[master]: virt: stats: make _calcDiskRate a function

fromani at redhat.com fromani at redhat.com
Thu Oct 2 15:32:40 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: virt: stats: make _calcDiskRate a function
......................................................................

virt: stats: make _calcDiskRate a function

used to be a method, but never uses 'self',
so make it a function.

No changes in behaviour, except the drop of the
unused 'self'.

Change-Id: I7f89f52309afc900a166b761e4041a371d217968
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 14 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/33736/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 97f8cbe..a05dd1a 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -542,24 +542,13 @@
                 if (sInfo and vmDrive.name in sInfo and
                    eInfo and vmDrive.name in eInfo):
                     # will be None if sampled during recovery
-                    dStats.update(self._calcDiskRate(vmDrive, sInfo, eInfo,
-                                                     sampleInterval))
+                    dStats.update(_calcDiskRate(vmDrive, sInfo, eInfo,
+                                                sampleInterval))
             except (AttributeError, TypeError, ZeroDivisionError):
                 self._log.exception("Disk %s stats not available",
                                     vmDrive.name)
 
             stats[vmDrive.name] = dStats
-
-    def _calcDiskRate(self, vmDrive, sInfo, eInfo, sampleInterval):
-        return {
-            'readRate': (
-                (eInfo[vmDrive.name][1] -
-                 sInfo[vmDrive.name][1])
-                / sampleInterval),
-            'writeRate': (
-                (eInfo[vmDrive.name][3] -
-                 sInfo[vmDrive.name][3])
-                / sampleInterval)}
 
     def _getDiskLatency(self, stats):
         sInfo, eInfo, sampleInterval = self.sampleDiskLatency.getStats()
@@ -626,6 +615,18 @@
         return True
 
 
+def _calcDiskRate(vmDrive, sInfo, eInfo, sampleInterval):
+    return {
+        'readRate': (
+            (eInfo[vmDrive.name][1] -
+             sInfo[vmDrive.name][1])
+            / sampleInterval),
+        'writeRate': (
+            (eInfo[vmDrive.name][3] -
+             sInfo[vmDrive.name][3])
+            / sampleInterval)}
+
+
 def _calcDiskLatency(vmDrive, sInfo, eInfo):
     dname = vmDrive.name
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f89f52309afc900a166b761e4041a371d217968
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