Change in vdsm[master]: virt: stats: simplify the exception flow

fromani at redhat.com fromani at redhat.com
Tue Apr 8 13:29:39 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: virt: stats: simplify the exception flow
......................................................................

virt: stats: simplify the exception flow

with the content reporting in place, this patch
simplifies the exception flow in getStats()

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


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

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 7517d73..042cb5c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2403,18 +2403,16 @@
             self._addExitedVmStats(stats)
         else:
             stats['content'] = []
-            self._addStaticVmStats(stats)
-            self._addDynamicVmStats(stats)
-            self._addVmStatusStats(stats)
-
             try:
+                self._addStaticVmStats(stats)
+                self._addDynamicVmStats(stats)
+                self._addVmStatusStats(stats)
                 self._addGuestInfoStats(stats)
+                self._addBalloonInfoStats(stats)
+                self._addMigrationVmStats(stats)
             except Exception:
-                return stats
-
-            self._addBalloonInfoStats(stats)
-            self._addMigrationVmStats(stats)
-
+                self.log.error('Error fetching vm stats: reporting partial'
+                               ' content', exc_info=True)
         return stats
 
     def _addExitedVmStats(self, stats):
@@ -2453,29 +2451,22 @@
 
     def _addDynamicVmStats(self, stats):
         decStats = {}
-        try:
-            if self._vmStats:
-                decStats = self._vmStats.get()
-                if (not self.isMigrating()
-                    and decStats['statsAge'] >
-                        config.getint('vars', 'vm_command_timeout')):
-                    stats['monitorResponse'] = '-1'
-        except Exception:
-            self.log.error("Error fetching vm stats", exc_info=True)
+        if self._vmStats:
+            decStats = self._vmStats.get()
+            if (not self.isMigrating()
+                and decStats['statsAge'] >
+                    config.getint('vars', 'vm_command_timeout')):
+                stats['monitorResponse'] = '-1'
         for var in decStats:
             if type(decStats[var]) is not dict:
                 stats[var] = utils.convertToStr(decStats[var])
             elif var == 'network':
                 stats['network'] = decStats[var]
             else:
-                try:
-                    stats['disks'][var] = {}
-                    for value in decStats[var]:
-                        stats['disks'][var][value] = \
-                            utils.convertToStr(decStats[var][value])
-                except Exception:
-                    self.log.error("Error setting vm disk stats",
-                                   exc_info=True)
+                stats['disks'][var] = {}
+                for value in decStats[var]:
+                    stats['disks'][var][value] = \
+                        utils.convertToStr(decStats[var][value])
         stats['content'].append('dynamic')
 
     def _addVmStatusStats(self, stats):


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

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