Skip to content

REST API

Kiran Mova edited this page Jan 31, 2020 · 1 revision

Command to get replicas from controller

curl http://<controlIp>:9501/v1/replicas

Command to get status from a replica

curl http://<ReplicaIp>:9502/v1/replicas

Command to get the volume information

curl http://<controlIp>:9501/v1/volumes

Command to list snapshots

curl http://<ReplicaIp>:9502/v1/replicas

The chain key has the snapshot list

Create snapshot

curl -H "Content-Type: application/json" -X POST -d '{"name":"<Snapshot name>"}' http://192.168.43.174:9501/v1/volumes/<Volume ID>?action=snapshot

Revert to snapshot

curl -H "Content-Type: application/json" -X POST -d '{"name":"<Snapshot name>"}' http://192.168.43.174:9501/v1/volumes/<Volume ID>?action=revert

Delete the volume / purge replica files (Delete all the contents)

curl -X POST http://CONTROLLER_IP:9501/v1/delete

# OUTPUT

{
  "actions": {},
  "links": {
    "self": "http://172.18.0.2:9501/v1/delete"
  },
  "replicas": [
    {
      "msg": "Replica deleted successfully",
      "replica": "tcp://172.18.0.3:9502"
    },
    {
      "msg": "Replica deleted successfully",
      "replica": "tcp://172.18.0.4:9502"
    }
  ],
  "type": "delete"
}

# OUTPUT (if all the replicas are not up)

{
  "actions": {},
  "links": {
    "self": "http://172.18.0.2:9501/v1/delete"
  },
  "replicas": [
    {
      "error": "Replication factor: 2 is not equal to replica count: 1",
      "msg": "Error deleting replica",
      "replica": ""
    }
  ],
  "type": "delete"
}

# OUTPUT (if the RF condition met but replica goes down while delete operation)

{
  "actions": {},
  "links": {
    "self": "http://172.18.0.2:9501/v1/delete"
  },
  "replicas": [
    {
      "msg": "Replica deleted successfully",
      "replica": "tcp://172.18.0.4:9502"
    },
    {
      "error": {
        "Err": {},
        "Op": "Get",
        "URL": "http://172.18.0.3:9502/v1/replicas/1"
      },
      "msg": "Error deleting replica",
      "replica": "tcp://172.18.0.3:9502"
    }
  ],
  "type": "delete"
}

Note: Please ensure that all the replicas are up before making delete request to controller. RF: Replication Factor, which is being used as env var in controller.