Change in vdsm[master]: vm: simplify Vm._getVmStatus method

fromani at redhat.com fromani at redhat.com
Wed Jul 8 09:38:53 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: vm: simplify Vm._getVmStatus method
......................................................................

vm: simplify Vm._getVmStatus method

Vm._getVmStatus returns a dict with just one key/value pair,
being the computed vm status (unsurprisingly).

This was done without a good reason, just to make the caller
look uniform. But more and more we need just the status value,
so the temporary dictionary is wasteful and redundant.

So, this patch simplifies the code to return indeed just the value.

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


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/67/43267/2

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 826e4e9..4dd8153 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -379,7 +379,7 @@
                 self._lastStatus = value
 
     def send_status_event(self):
-        vm_status = self._getVmStatus()['status']
+        vm_status = self._getVmStatus()
         stats = {}
         with self._eventLock:
             if vm_status != self._evaluatedStatus:
@@ -1327,7 +1327,7 @@
         else:
             stats.update(self._getConfigVmStats())
             stats.update(self._getRunningVmStats())
-            stats.update(self._getVmStatus())
+            stats['status'] = self._getVmStatus()
             stats.update(self._getGuestStats())
         return stats
 
@@ -1474,16 +1474,16 @@
                     vmstatus.MIGRATION_SOURCE, vmstatus.MIGRATION_DESTINATION,
                     vmstatus.PAUSED)
         if self.lastStatus in statuses:
-            return {'status': self.lastStatus}
+            return self.lastStatus
         elif self.isMigrating():
             if self._migrationSourceThread.hibernating:
-                return {'status': vmstatus.SAVING_STATE}
+                return vmstatus.SAVING_STATE
             else:
-                return {'status': vmstatus.MIGRATION_SOURCE}
+                return vmstatus.MIGRATION_SOURCE
         elif self.lastStatus == vmstatus.UP:
-            return {'status': _getVmStatusFromGuest()}
+            return _getVmStatusFromGuest()
         else:
-            return {'status': self.lastStatus}
+            return self.lastStatus
 
     def _getGraphicsStats(self):
         def getInfo(dev):


-- 
To view, visit https://gerrit.ovirt.org/43267
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f02efa1001aff5fbf01d127b333250500de9d54
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: automation at ovirt.org


More information about the vdsm-patches mailing list