Change in vdsm[master]: virt: remove unwanted 'response' aliasing

fromani at redhat.com fromani at redhat.com
Mon Mar 16 15:49:26 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: virt: remove unwanted 'response' aliasing
......................................................................

virt: remove unwanted 'response' aliasing

In quite a few place we used the name 'response'
for variables holding the result of an API call.

After the introduction of the 'response' module,
this created unwanted aliasing, with room for subtle
annoying bugs like

AttributeError: 'dict' object has no attribute 'success'

This patch fixes that by renaming the affected variables
all across the virt package.

Change-Id: I53f91af7e6d28aaf033bfb589216c0422bd4a311
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/migration.py
M vdsm/virt/vm.py
2 files changed, 11 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/03/38803/1

diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index c2a112e..10c32a3 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -300,16 +300,16 @@
             # destination. In some cases some expensive operations can cause
             # the migration to get cancelled right after the transfer started.
             destCreateStartTime = time.time()
-            response = self.destServer.migrationCreate(self._machineParams)
+            res = self.destServer.migrationCreate(self._machineParams)
             destCreationTime = time.time() - destCreateStartTime
             startTime += destCreationTime
             self.log.info('Creation of destination VM took: %d seconds',
                           destCreationTime)
 
-            if response['status']['code']:
-                self.status = response
+            if res['status']['code']:
+                self.status = res
                 raise RuntimeError('migration destination error: ' +
-                                   response['status']['message'])
+                                   res['status']['message'])
             if config.getboolean('vars', 'ssl'):
                 transport = 'tls'
             else:
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 953cb2d..268facb 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1271,8 +1271,8 @@
         self._dom = None
         # Try release VM resources first, if failed stuck in 'Powering Down'
         # state
-        response = self.releaseVm()
-        if not response['status']['code']:
+        res = self.releaseVm()
+        if not res['status']['code']:
             with self._shutdownLock:
                 reason = self._shutdownReason
             if reason is None:
@@ -3888,8 +3888,8 @@
                 self._vmStats.stop()
             self.guestAgent.stop()
             if self._dom:
-                response = self._destroyVmGraceful()
-                if response['status']['code']:
+                res = self._destroyVmGraceful()
+                if res['status']['code']:
                     return response
 
             # Wait for any Live Merge cleanup threads.  This will only block in
@@ -3952,9 +3952,9 @@
     def destroy(self):
         self.log.debug('destroy Called')
 
-        response = self.doDestroy()
-        if response['status']['code']:
-            return response
+        res = self.doDestroy()
+        if res['status']['code']:
+            return res
         # Clean VM from the system
         self.deleteVm()
 


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

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