Navigation Menu

Skip to content

Alphadelta14/libgfapi-python

 
 

Repository files navigation

Overview

Python bindings for the GlusterFS libgfapi interface

Installation

  1. Clone the git repo
$ git clone https://review.gluster.org/libgfapi-python
$ cd libgfapi-python
  1. Run the setup script
$ sudo python setup.py install

Usage

from gluster import gfapi
import os

## Create virtual mount
volume = gfapi.Volume(....)
volume.mount()

## Create a new directory
volume.mkdir('newdir', 0755)

## Create a new directory recursively
volume.makedirs('/somedir/dir',0755)

## Delete a directory
volume.rmdir('/somedir/dir')

## Create a file from a string using fopen.  w+: open file for reading and writing
with volume.fopen('somefile.txt', 'w+') as fd:
    fd.write("shadowfax")

## Read a file.  r: open file for only reading
with volume.fopen('somefile.txt', 'r') as fd:
  print fd.read()

## Write to an existing file. a+:  open a file for reading and appending
with volume.fopen('somefile.txt','a+') as fd:
  fd.write("\n some new line in our file")

## Delete a file
volume.unlink('somefile.txt')

## Unmount a volume
volume.unmount()

Development

About

Python bindings for libgfapi - (This is only a public mirror). Please read the developer workflow here: https://github.com/gluster/libgfapi-python/blob/master/doc/markdown/dev_guide.md

Resources

License

GPL-2.0, LGPL-3.0 licenses found

Licenses found

GPL-2.0
COPYING-GPLV2
LGPL-3.0
COPYING-LGPLV3

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.6%
  • Shell 1.4%