From 6f1c02f07702324c1848b623dfefd21b6e06b05b Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Mon, 30 Apr 2018 15:40:26 +0200 Subject: [PATCH] Fix DeviceUnavailable exception We were accessing the wrong module (cinderlib) to find the DeviceUnavailable exception, now we access it in the right place (cinder.exception). --- HISTORY.rst | 1 + cinderlib/cinderlib.py | 3 ++- cinderlib/objects.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 750e96d..fd02ab8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -27,6 +27,7 @@ History - Fix name & description inconsistency - Set created_at field on creation - Connection fields not being set + - DeviceUnavailable exception 0.1.0 (2017-11-03) ------------------ diff --git a/cinderlib/cinderlib.py b/cinderlib/cinderlib.py index 0288c65..4299c24 100644 --- a/cinderlib/cinderlib.py +++ b/cinderlib/cinderlib.py @@ -346,7 +346,8 @@ class RBDConnector(connectors.rbd.RBDConnector): """Verify an existing RBD handle is connected and valid.""" try: self._execute('dd', 'if=' + path, 'of=/dev/null', 'bs=4096', - 'count=1', run_as_root=True) + 'count=1', root_helper=self._root_helper, + run_as_root=True) except putils.ProcessExecutionError: return False return True diff --git a/cinderlib/objects.py b/cinderlib/objects.py index 56e3d95..b0c5dbe 100644 --- a/cinderlib/objects.py +++ b/cinderlib/objects.py @@ -22,6 +22,7 @@ from cinder import context # having all the other imports as they could change. from cinder.cmd import volume as volume_cmd from cinder import objects as cinder_objs +from cinder import exception as cinder_exception from cinder.objects import base as cinder_base_ovo from os_brick import exception as brick_exception from os_brick import initiator as brick_initiator @@ -681,7 +682,7 @@ class Connection(Object): LOG.exception('Could not validate device %s', self.path) if unavailable: - raise exception.DeviceUnavailable( + raise cinder_exception.DeviceUnavailable( path=self.path, attach_info=self._ovo.connection_information, reason=('Unable to access the backend storage via path ' '%s.') % self.path)