summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZandrr <campbellalex11@gmail.com>2015-06-05 13:56:13 -0400
committerPrashanth Pai <ppai@redhat.com>2015-09-16 17:32:38 +0530
commit299317d5937c755abd956524ecb0f4b376c6881f (patch)
tree42c2c973c1d47794194ad6ce46b917c72c59b124
parentf3acbc844a105d342a3133789f01eaf713a981d1 (diff)
add usage to readme for easier quickstart
Change-Id: I6210a0f8e9ed746d430b8b71c4898e41bbfd475e
-rw-r--r--README.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/README.md b/README.md
index ad918e9..3720fcb 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,44 @@ $ cd libgfapi-python
```
$ 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)