Change in vdsm[master]: hsm: Refine error handling in getDevicesVisibility

nsoffer at redhat.com nsoffer at redhat.com
Sat Mar 28 01:01:10 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: hsm: Refine error handling in getDevicesVisibility
......................................................................

hsm: Refine error handling in getDevicesVisibility

Narrow the exception handler, moving out code that cannot raise the
expected exception, and clarify the logic. No behavior change is
expected.

Change-Id: I2382986e886210e921d005dfcb0d4c479b87174d
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 5 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/39305/1

diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 8f07586..a4bb858 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -2071,14 +2071,15 @@
         :rtype: dict
         """
         def _isVisible(guid):
+            path = os.path.join('/dev/mapper', guid)
             try:
-                res = (os.stat('/dev/mapper/' + guid).st_mode &
-                       stat.S_IRUSR != 0)
+                st = os.stat(path)
             except OSError as e:
                 if e.errno != errno.ENOENT:
                     raise
-                res = False
-            return res
+                return False
+            else:
+                return (st.st_mode & stat.S_IRUSR) != 0
 
         visibility = [_isVisible(guid) for guid in guids]
         if not all(visibility):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2382986e886210e921d005dfcb0d4c479b87174d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list