blob: 3720fcb14dbaadd1164dc5da2d4f986eeec271ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# Overview
Python bindings for the [GlusterFS](http://www.gluster.org) libgfapi interface
# Installation
1) Clone the git repo
```
$ git clone https://review.gluster.org/libgfapi-python
$ cd libgfapi-python
```
2) Run the setup script
```
$ sudo python setup.py install
```
# Usage
```python
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
* [Developer Guide](doc/markdown/dev_guide.md)
|