summaryrefslogtreecommitdiffstats
path: root/gluster/api.py
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2015-06-10 20:45:20 +0530
committerThiago da Silva <thiago@redhat.com>2015-06-18 08:49:35 -0400
commit509abefca5902e4f0decf40368a90265d1a598bd (patch)
tree151568be15e44e8b9c4603b5e0f48c3c1716dc18 /gluster/api.py
parent658ebecb84951fd8e418f15a5c8e2c8b1901b9d4 (diff)
Add missing File APIs
Volume.fopen() method mimics Python's built-in File object Example: with v.fopen("/path/to/file", "w") as f: f.write("hello world") fopen() returns a File object. Volume.open() method mimics os.open() Python API. Example: with File(v.open("/path/to/file", os.O_WRONLY | os.O_CREAT)) as f: f.write("hello world") open() returns the raw glfd that (as of today) needs to be passed to File class. In future, more APIs will be provided to directly use the glfd returned. Unlike their C versions, these methods do not return anything on success. If methods fail, exceptions are raised. Added docstrings to methods in File class. Change-Id: Ie46fc77a899806d396762e6740e1538ea298d6e2 Signed-off-by: Prashanth Pai <ppai@redhat.com> Signed-off-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'gluster/api.py')
-rwxr-xr-xgluster/api.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/gluster/api.py b/gluster/api.py
index 6bbd092..560ede8 100755
--- a/gluster/api.py
+++ b/gluster/api.py
@@ -396,6 +396,34 @@ glfs_setfsuid = ctypes.CFUNCTYPE(ctypes.c_int,
glfs_setfsgid = ctypes.CFUNCTYPE(ctypes.c_int,
ctypes.c_uint)(('glfs_setfsgid', client))
+glfs_ftruncate = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p,
+ ctypes.c_int)(('glfs_ftruncate', client))
+
+glfs_fgetxattr = ctypes.CFUNCTYPE(ctypes.c_ssize_t,
+ ctypes.c_void_p,
+ ctypes.c_char_p,
+ ctypes.c_void_p,
+ ctypes.c_size_t)(('glfs_fgetxattr', client))
+
+glfs_fremovexattr = ctypes.CFUNCTYPE(ctypes.c_int,
+ ctypes.c_void_p,
+ ctypes.c_char_p)(('glfs_fremovexattr',
+ client))
+
+glfs_fsetxattr = ctypes.CFUNCTYPE(ctypes.c_int,
+ ctypes.c_void_p,
+ ctypes.c_char_p,
+ ctypes.c_void_p,
+ ctypes.c_size_t,
+ ctypes.c_int)(('glfs_fsetxattr', client))
+
+glfs_flistxattr = ctypes.CFUNCTYPE(ctypes.c_ssize_t,
+ ctypes.c_void_p,
+ ctypes.c_void_p,
+ ctypes.c_size_t)(('glfs_flistxattr',
+ client))
+
+
# TODO: creat and open fails on test_create_file_already_exists & test_open_file_not_exist functional testing, # noqa
# when defined via function prototype.. Need to find RCA. For time being, using it from 'api.glfs_' # noqa