mkdir -p $GOPATH/src/github.com/gluster
cd $GOPATH/src/github.com/gluster
git clone https://github.com/gluster/gluster-block-restapi.git
cd gluster-block-restapi
PREFIX=/usr make
PREFIX=/usr make install
Enable and run glusterblockrestd
by running,
systemctl enable glusterblockrestd
systemctl start glusterblockrestd
Server port and other settings can be configured by updating the following config file.
/etc/gluster-block-restapi/config.toml
Curl example to create a gluster block volume
curl -i -XPOST http://localhost:8081/v1/blockvolumes/block-test/sample-block \
-d '{"ha": 3, "size": 1073741824, "hosts": ["192.168.1.11", "192.168.1.12", "192.168.1.13"]}'
Python example to create a gluster block volume
import requests
req = {
"ha": 3,
"hosts": ["192.168.1.11", "192.168.1.12", "192.168.1.13"],
"size": 1073741824
}
resp = requests.post("http://localhost:8081/v1/blockvolumes/block-test/sample-block",
data=req)
if resp.status_code == 200:
print("[ OK] Block volume created successfully")
print(resp.content)
else:
print("[ERROR] Block volume create failed")
print(resp.content)