ceph: fix errno_to_exception

We are using an internal API of rados.

This change removes its usage.

Closes-bug: #1690876
Change-Id: Ia1304395748f54fed0995406b9bc7260af8f5e84
This commit is contained in:
Mehdi Abaakouk 2017-05-15 19:53:01 +02:00 committed by Mehdi Abaakouk (sileht)
parent f8b18df786
commit e35e526ad6
1 changed files with 23 additions and 1 deletions

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import errno
from oslo_log import log
LOG = log.getLogger(__name__)
@ -73,6 +75,26 @@ def close_rados_connection(conn, ioctx):
conn.shutdown()
# NOTE(sileht): The mapping is not part of the rados Public API So we copy it
# here.
EXCEPTION_NAMES = {
errno.EPERM: 'PermissionError',
errno.ENOENT: 'ObjectNotFound',
errno.EIO: 'IOError',
errno.ENOSPC: 'NoSpace',
errno.EEXIST: 'ObjectExists',
errno.EBUSY: 'ObjectBusy',
errno.ENODATA: 'NoData',
errno.EINTR: 'InterruptedOrTimeoutError',
errno.ETIMEDOUT: 'TimedOut',
errno.EACCES: 'PermissionDeniedError'
}
def errno_to_exception(ret):
if ret < 0:
raise rados.errno_to_exception[abs(ret)]
name = EXCEPTION_NAMES.get(abs(ret))
if name is None:
raise rados.Error("Unhandled error '%s'" % ret)
else:
raise getattr(rados, name)