Change in vdsm[master]: vdsm: Replaced all too generic except: handlers

vfeenstr at redhat.com vfeenstr at redhat.com
Wed Aug 7 08:19:29 UTC 2013


Vinzenz Feenstra has uploaded a new change for review.

Change subject: vdsm: Replaced all too generic except: handlers
......................................................................

vdsm: Replaced all too generic except: handlers

Change-Id: I00f1c6650b357cebfcaa375a2babb8c12637fd5a
Signed-off-by: Vinzenz Feenstra <vfeenstr at redhat.com>
---
M vdsm/vm.py
1 file changed, 34 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/40/17740/1

diff --git a/vdsm/vm.py b/vdsm/vm.py
index 0b71314..79e13a9 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -184,7 +184,7 @@
             if not status['status']['code']:
                 self.log.error("Machine already exists on the destination")
                 self.status = errCode['exist']
-        except:
+        except Exception:
             self.log.error("Error initiating connection", exc_info=True)
             self.status = errCode['noConPeer']
 
@@ -243,7 +243,7 @@
         if self._mode != 'file':
             try:
                 self.destServer.destroy(self._vm.id)
-            except:
+            except Exception:
                 self.log.error("Failed to destroy remote VM", exc_info=True)
         # if the guest was stopped before migration, we need to cont it
         if self._mode == 'file' or self._method != 'online':
@@ -332,7 +332,7 @@
                     self._vm._dom.save(fname)
                 finally:
                     self._vm.cif.teardownVolumePath(self._dst)
-            except:
+            except Exception:
                 self._vm._vmStats.cont()
                 raise
         else:
@@ -1393,7 +1393,7 @@
         if self._blockDev is None:
             try:
                 self._blockDev = utils.isBlockDevice(self.path)
-            except:
+            except Exception:
                 self.log.debug("Unable to determine if the path '%s' is a "
                                "block device", self.path, exc_info=True)
         return self._blockDev
@@ -2048,7 +2048,7 @@
                 try:
                     with self._confLock:
                         del self.conf['pauseCode']
-                except:
+                except KeyError:
                     pass
 
             if 'recover' in self.conf:
@@ -2119,7 +2119,7 @@
         self._saveStateInternal()
         try:
             self._getUnderlyingVmInfo()
-        except:
+        except Exception:
             # we do not care if _dom suddenly died now
             pass
 
@@ -2164,7 +2164,7 @@
             if self.conf.get('volatileFloppy'):
                 self._ejectFloppy()
                 self.log.debug('ejected volatileFloppy')
-        except:
+        except Exception:
             self.log.error("Reboot event failed", exc_info=True)
 
     def onShutdown(self):
@@ -2332,7 +2332,7 @@
             try:
                 with self._confLock:
                     del self.conf['pauseCode']
-            except:
+            except KeyError:
                 pass
             return {'status': doneCode, 'output': ['']}
         finally:
@@ -2379,7 +2379,7 @@
                         'code': errCode['exist']['status']['code'],
                         'message': 'VM without ACPI or active SolidICE tools. '
                                    'Try Forced Shutdown.'}}
-        except:
+        except Exception:
             self.log.error("Shutdown failed", exc_info=True)
             return {'status': {'code': errCode['exist']['status']['code'],
                     'message': 'Failed to shutdown VM. Try Forced Shutdown.'}}
@@ -2395,7 +2395,7 @@
                 self.destroy()
             else:
                 self._acpiShutdown()
-        except:
+        except Exception:
             self.log.error("_timedShutdown failed", exc_info=True)
 
     def _cleanupDrives(self, *drives):
@@ -2413,7 +2413,7 @@
             for drive in drives:
                 try:
                     self.cif.teardownVolumePath(drive)
-                except:
+                except Exception:
                     self.log.error("Drive teardown failure for %s",
                                    drive, exc_info=True)
 
@@ -2425,7 +2425,7 @@
             try:
                 self.log.debug("Floppy %s cleanup" % self.conf['floppy'])
                 utils.rmFile(self.conf['floppy'])
-            except:
+            except Exception:
                 pass
 
     def _cleanupGuestAgent(self):
@@ -2434,7 +2434,7 @@
         """
         try:
             self.guestAgent.stop()
-        except:
+        except Exception:
             pass
 
         utils.rmFile(self._guestSocketFile)
@@ -2454,11 +2454,11 @@
             pass
         try:
             self.guestAgent.stop()
-        except:
+        except Exception:
             pass
         try:
             self._vmStats.stop()
-        except:
+        except Exception:
             pass
         self.saveState()
 
@@ -2523,7 +2523,7 @@
                     and decStats['statsAge'] >
                         config.getint('vars', 'vm_command_timeout')):
                     stats['monitorResponse'] = '-1'
-        except:
+        except Exception:
             self.log.error("Error fetching vm stats", exc_info=True)
         for var in decStats:
             if type(decStats[var]) is not dict:
@@ -2536,7 +2536,7 @@
                     for value in decStats[var]:
                         stats['disks'][var][value] = \
                             utils.convertToStr(decStats[var][value])
-                except:
+                except Exception:
                     self.log.error("Error setting vm disk stats",
                                    exc_info=True)
 
@@ -2560,7 +2560,7 @@
             stats['pauseCode'] = self.conf['pauseCode']
         try:
             stats.update(self.guestAgent.getGuestInfo())
-        except:
+        except Exception:
             return stats
         memUsage = 0
         realMemUsage = int(stats['memUsage'])
@@ -2776,7 +2776,7 @@
             # handle it. We must handle it now
             try:
                 self._dom.destroy()
-            except:
+            except Exception:
                 pass
             raise Exception('destroy() called before Vm started')
 
@@ -2819,7 +2819,7 @@
 
         try:
             self._dom.setSchedulerParameters({'cpu_shares': cpuShares})
-        except:
+        except Exception:
             self.log.warning('failed to set Vm niceness', exc_info=True)
 
     def _run(self):
@@ -3524,7 +3524,7 @@
             for vmDevName, drive in newDrives.iteritems():
                 try:
                     self.cif.teardownVolumePath(drive)
-                except:
+                except Exception:
                     self.log.error("Unable to teardown drive: %s", vmDevName,
                                    exc_info=True)
 
@@ -3679,7 +3679,7 @@
             for drive in newDrives.values():  # Update the drive information
                 try:
                     self.updateDriveParameters(drive)
-                except:
+                except Exception:
                     # Here it's too late to fail, the switch already happened
                     # and there's nothing we can do, we must to proceed anyway
                     # to report the live snapshot success.
@@ -3702,7 +3702,7 @@
             try:
                 self._dom.blockRebase(mergeStatus['path'],
                                       mergeStatus['basePath'], 0, 0)
-            except:
+            except Exception:
                 mergeStatus['status'] = MERGESTATUS.FAILED
                 self.log.error("Live merge failed for %s",
                                mergeStatus['path'], exc_info=True)
@@ -3718,7 +3718,7 @@
 
             try:
                 jobInfo = self._dom.blockJobInfo(mergeStatus['path'], 0)
-            except:
+            except Exception:
                 jobInfo = None
 
             if not jobInfo:
@@ -3845,7 +3845,7 @@
 
         try:
             self._setDiskReplica(srcDrive, dstDisk)
-        except:
+        except Exception:
             self.log.error("Unable to set the replication for disk '%s' with "
                            "destination '%s'" % srcDrive.name, dstDisk)
             return errCode['replicaErr']
@@ -3865,12 +3865,12 @@
                     libvirt.VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT |
                     libvirt.VIR_DOMAIN_BLOCK_REBASE_SHALLOW
                 ))
-            except:
+            except Exception:
                 self.log.error("Unable to start the replication for %s to %s",
                                srcDrive.name, dstDiskCopy, exc_info=True)
                 self.cif.teardownVolumePath(dstDiskCopy)
                 raise
-        except:
+        except Exception:
             self.log.error("Cannot complete the disk replication process",
                            exc_info=True)
             self._delDiskReplica(srcDrive)
@@ -3878,7 +3878,7 @@
 
         try:
             self.extendDriveVolume(srcDrive)
-        except:
+        except Exception:
             self.log.error("Initial extension request failed for %s",
                            srcDrive.name, exc_info=True)
 
@@ -3938,12 +3938,12 @@
         try:
             # Stopping the replication
             self._dom.blockJobAbort(srcDrive.name, blockJobFlags)
-        except:
+        except Exception:
             self.log.error("Unable to stop the replication for the drive: %s",
                            srcDrive.name, exc_info=True)
             try:
                 self.cif.teardownVolumePath(srcDrive.diskReplicate)
-            except:
+            except Exception:
                 # There is nothing we can do at this point other than logging
                 self.log.error("Unable to teardown the replication "
                                "destination disk", exc_info=True)
@@ -3951,7 +3951,7 @@
         else:
             try:
                 self.cif.teardownVolumePath(diskToTeardown)
-            except:
+            except Exception:
                 # There is nothing we can do at this point other than logging
                 self.log.error("Unable to teardown the previous chain: %s",
                                diskToTeardown, exc_info=True)
@@ -4044,7 +4044,7 @@
                 return self._diskSizeExtendCow(drive, newSizeBytes)
             else:
                 return self._diskSizeExtendRaw(drive, newSizeBytes)
-        except:
+        except Exception:
             self.log.error("Unable to extend disk %s to size %s",
                            drive.name, newSizeBytes, exc_info=True)
 
@@ -4094,7 +4094,7 @@
         try:
             self._dom.updateDeviceFlags(
                 diskelem.toxml(), libvirt.VIR_DOMAIN_DEVICE_MODIFY_FORCE)
-        except:
+        except Exception:
             self.log.debug("updateDeviceFlags failed", exc_info=True)
             self.cif.teardownVolumePath(drivespec)
             return {'status': {'code': errCode['changeDisk']['status']['code'],
@@ -4178,7 +4178,7 @@
         try:
             vmName = self.conf['vmName'].encode('utf-8')
             pid = supervdsm.getProxy().getVmPid(vmName)
-        except:
+        except Exception:
             pass
         return pid
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I00f1c6650b357cebfcaa375a2babb8c12637fd5a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr at redhat.com>


More information about the vdsm-patches mailing list