Eduardo has uploaded a new change for review. Change subject: Uniform LocalDirectoryConnection.checkTarget() errors. ......................................................................
Uniform LocalDirectoryConnection.checkTarget() errors. Hard to believe: there are uglier things the the True or Exception pattern. Change-Id: Icb8d2afd26efbd7ab228ccf20658485f776802de Signed-off-by: Eduardo <[email protected]> --- M vdsm/storage/storageServer.py M vdsm/storage/storage_exception.py 2 files changed, 13 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/10150/1 diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py index b457d5b..e1c5c09 100644 --- a/vdsm/storage/storageServer.py +++ b/vdsm/storage/storageServer.py @@ -445,8 +445,10 @@ self._path.replace("_", "__").replace("/", "_")) def checkTarget(self): - return (os.path.isdir(self._path) and - fileSD.validateDirAccess(self._path)) + if not os.path.isdir(self._path): + raise se.StorageServerLocalNotDirError(self._path) + fileSD.validateDirAccess(self._path) + return True def checkLink(self): lnPath = self._getLocalPath() @@ -459,10 +461,7 @@ return False def connect(self): - if not self.checkTarget(): - #TODO: Use proper exception - raise Exception("Could not link to directory. Path does not exist " - "or isn't a directory") + self.checkTarget() if self.checkLink(): return diff --git a/vdsm/storage/storage_exception.py b/vdsm/storage/storage_exception.py index 4a80e78..9f3190b 100644 --- a/vdsm/storage/storage_exception.py +++ b/vdsm/storage/storage_exception.py @@ -1131,6 +1131,14 @@ self.value = "path = %s" % targetPath +class StorageServerLocalNotDirError(StorageException): + code = 469 + message = "The specified local path is not a directory." + + def __init__(self, targetPath): + self.value = "path = %s" % targetPath + + class MountTypeError(StorageException): code = 470 message = "Mount type error" -- To view, visit http://gerrit.ovirt.org/10150 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icb8d2afd26efbd7ab228ccf20658485f776802de Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Eduardo <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
