Francesco Romani has uploaded a new change for review.

Change subject: vm: factor out common fields in vm stats
......................................................................

vm: factor out common fields in vm stats

vmId must always be present in vm stats,
so factor it out, to remove duplication,
and to have slightly more clearer code.

Change-Id: Ifb9e8acf3a872e34ed0a2b90e99111a63606e64d
Signed-off-by: Francesco Romani <from...@redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 9 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/98/37698/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 6ff94b3..91dcc3f 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1745,18 +1745,20 @@
         attribute. Use the VmStatsThread instead!
         """
 
-        if self.lastStatus == vmstatus.DOWN:
-            return self._getExitedVmStats()
+        stats = {'vmId': self.conf['vmId']}
 
-        stats = self._getConfigVmStats()
-        stats.update(self._getRunningVmStats())
-        stats.update(self._getVmStatus())
-        stats.update(self._getGuestStats())
+        if self.lastStatus == vmstatus.DOWN:
+            stats.update(self._getExitedVmStats())
+        else:
+            stats.update(self._getConfigVmStats())
+            stats.update(self._getRunningVmStats())
+            stats.update(self._getVmStatus())
+            stats.update(self._getGuestStats())
+
         return stats
 
     def _getExitedVmStats(self):
         stats = {
-            'vmId': self.conf['vmId'],
             'exitCode': self.conf['exitCode'],
             'status': self.lastStatus,
             'exitMessage': self.conf['exitMessage'],
@@ -1772,7 +1774,6 @@
         but can change as result as interaction with libvirt (display*)
         """
         stats = {
-            'vmId': self.conf['vmId'],
             'pid': self.conf['pid'],
             'vmType': self.conf['vmType'],
             'kvmEnable': self._kvmEnable,


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb9e8acf3a872e34ed0a2b90e99111a63606e64d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <from...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to