Play with libgfapi and its python bindings..

What is libgfapi ?

User-space library for accessing data in GlusterFS
Filesystem-like API
Runs in application process
no FUSE, no copies, no context switches
…but same volfiles, translators, etc.
Could be used for Apache/nginx modules, MPI I/O
(maybe), Ganesha, etc. ad infinitum
BTW it’s usable from Python too 🙂

Yes, I copied it from

libgfapi improves gluster performance by avoiding “fuse” layer. Its a different route to access glusterfs data. Imagine that, libgfapi sits in the application layer. Different bindings are available to access libgfapi.

In this article, I will introduce the python bindings of libgfapi.

The libgfapi python binding is available on GitHub, with a mirror on the Gluster Forge:

1) First of all, clone the git repo:

2) Then run the setup script:

Once its done, you are almost done with the dev environment 🙂

Now its really easy to use the functions provided by libgfapi. Let me mention some of the gluster functions available through the python bindings:

The Libgfapi functions available through the bindings are:

[1] The patch ( ) for “statvfs” is not merged as of now , 🙂

I have a gluster setup where I created a distributed volume called “vol2” :

Lets start accessing this volume using Python. To use the gfapi binding, you need to import gfapi as shown below:

Once it’s done, you access the volume with the mount() method like this:

“10.X.X.152” is my gluster server and “vol2” is the volume name:

The mount() method basically initialises the connection to the volume.

These are the methods available for the Volume object:

Lets create some entries in this volume and check further:

This created a 5M file called “file1″ inside “vol2″ volume.

To list the files and directories inside the volume, we use the listdir() method:

Running a “stat” on the file, from the server, shows this information:

Lets prove the python binding works 🙂

If I want to list the extended attributes, I can try something like:

Lets create a directory called “humble”:

Checking on the server using ls, it should be there:

Success! For fun, some ‘stat’ information can be displayed using these methods:

If you want to mount a gluster volume as a non-root user, you need to follow the steps below.
By default, gluster allows client connections only from privileged ports. To enable connections from unprivileged ports you have to follow below steps.

1. Turn on the allow-insecure option for the volume:

2. Edit /etc/glusterfs/glusterd.vol, adding the line:

3. Obviously you should have the permissions on the directory you are accessing for non-root access

4. Start and stop volume

Leave a Reply

Your email address will not be published. Required fields are marked *