From: Ramana Raja Date: Fri, 3 Jul 2020 12:24:44 +0000 (+0530) Subject: pybind/cephfs: add DiskQuotaExceeded exception X-Git-Tag: v16.1.0~1794^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4cd247e6d0b7d38eb8e9bf5f6a656fd78393b4f6;p=ceph.git pybind/cephfs: add DiskQuotaExceeded exception Signed-off-by: Ramana Raja --- diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 6687cb86a15..05f93a8dfd1 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -318,6 +318,10 @@ class ObjectNotEmpty(OSError): class NotDirectory(OSError): pass +class DiskQuotaExceeded(OSError): + pass + + IF UNAME_SYSNAME == "FreeBSD": cdef errno_to_exception = { errno.EPERM : PermissionError, @@ -331,6 +335,7 @@ IF UNAME_SYSNAME == "FreeBSD": errno.ERANGE : OutOfRange, errno.EWOULDBLOCK: WouldBlock, errno.ENOTEMPTY : ObjectNotEmpty, + errno.EDQUOT : DiskQuotaExceeded, } ELSE: cdef errno_to_exception = { @@ -345,7 +350,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 c06647f8aa0..dedce84674f 100644 --- a/src/test/pybind/test_cephfs.py +++ b/src/test/pybind/test_cephfs.py @@ -776,3 +776,12 @@ def test_get_pool(): s=os.popen(get_rep_cnt_cmd).read().strip('\n') size=int(s.split(" ")[-1]) assert_equal(cephfs.get_pool_replication(dp_dict["pool_id"]), size) + +@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")