From: Ramana Raja Date: Fri, 3 Jul 2020 12:24:44 +0000 (+0530) Subject: pybind/cephfs: add DiskQuotaExceeded exception X-Git-Tag: v15.2.9~122^2~21^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=12a948bc73a0c87d7c97766bb6942d3ac51fecbd;p=ceph.git pybind/cephfs: add DiskQuotaExceeded exception Signed-off-by: Ramana Raja (cherry picked from commit 4cd247e6d0b7d38eb8e9bf5f6a656fd78393b4f6) Conflicts: src/test/pybind/test_cephfs.py - some cephfs pybind interfaces and their tests were missing in octopus --- diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 916ef81eccc4..83e6454bcbbc 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -269,6 +269,10 @@ class ObjectNotEmpty(OSError): class NotDirectory(OSError): pass +class DiskQuotaExceeded(OSError): + pass + + IF UNAME_SYSNAME == "FreeBSD": cdef errno_to_exception = { errno.EPERM : PermissionError, @@ -282,6 +286,7 @@ IF UNAME_SYSNAME == "FreeBSD": errno.ERANGE : OutOfRange, errno.EWOULDBLOCK: WouldBlock, errno.ENOTEMPTY : ObjectNotEmpty, + errno.EDQUOT : DiskQuotaExceeded, } ELSE: cdef errno_to_exception = { @@ -296,7 +301,8 @@ ELSE: errno.ERANGE : OutOfRange, errno.EWOULDBLOCK: WouldBlock, errno.ENOTEMPTY : ObjectNotEmpty, - errno.ENOTDIR : NotDirectory + errno.ENOTDIR : NotDirectory, + errno.EDQUOT : DiskQuotaExceeded, } diff --git a/src/test/pybind/test_cephfs.py b/src/test/pybind/test_cephfs.py index e633ee0cd017..c6bd0c9bea76 100644 --- a/src/test/pybind/test_cephfs.py +++ b/src/test/pybind/test_cephfs.py @@ -431,3 +431,12 @@ def test_futimens(): cephfs.close(fd) cephfs.unlink(b'/file-1') + +@with_setup(setup_test) +def test_disk_quota_exceeeded_error(): + cephfs.mkdir("/dir-1", 0o755) + cephfs.setxattr("/dir-1", "ceph.quota.max_bytes", b"5", 0) + fd = cephfs.open(b'/dir-1/file-1', 'w', 0o755) + assert_raises(libcephfs.DiskQuotaExceeded, cephfs.write, fd, b"abcdeghiklmnopqrstuvwxyz", 0) + cephfs.close(fd) + cephfs.unlink(b"/dir-1/file-1")