Gd2 exposes REST APIs and CLI is one consumer of these APIs.
+------------+ +--------------------+
| gd2 |------REST APIs---------------------------| restclient --- CLI |
+------------+ +--------------------+
restclient is a Go library available in github.com/gluster/glusterd2/pkg/restclient
To add a CLI subcommand,
- Make sure REST API is available for that task from gd2. For example,
POST /v1/peers
to probe a peer - Add entry in restclient pkg to interact with respective REST API Example,
PeerProbe()
function in$SRC/pkg/restclient/peer.go
- Consume restclient function from CLI code. Example in
$SRC/cli/cmd/peer.go
To test, run make cli
in $SRC
which will generate a binary in $SRC/build
directory.
cd build
./glustercli peer probe hostname
./glustercli --help
./glustercli peer --help