summaryrefslogtreecommitdiffstats
path: root/rpc/rpcl
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-03-22 12:43:20 +0530
committerPranith Kumar K <pkarampu@redhat.com>2017-04-28 11:43:02 +0530
commit7e29a1a2496a922457bdeb02332e9b78c97b4d81 (patch)
tree2e3090df6519e98718ddfc58ae0e23ddcaa5140a /rpc/rpcl
parentbd772be0685479c2fe27e15a3289384a56cf4c31 (diff)
gluster-block: support json response
This is how cli response looks like, on supplying '--json*' flag to cmd-args: $ gluster-block create block-test/sample-block1 ha 1 localhost.localdomain 1GiB --json (or) $ gluster-block create block-test/sample-block2 ha 1 localhost.localdomain 1GiB --json-spaced { "IQN": "iqn.2016-12.org.gluster-block:681af106-85f1-4a02-a122-57c80903458c", \ "PORTAL(S)": [ "localhost.localdomain:3260" ], "RESULT": "SUCCESS" } $ gluster-block create block-test/sample-block3 ha 1 localhost.localdomain 1GiB --json-plain {"IQN":"iqn.2016-12.org.gluster-block:0fdf6647-57f2-477f-8dd4-54a3de06e410",\ "PORTAL(S)":["localhost.localdomain:3260"],"RESULT":"SUCCESS"} $ gluster-block create block-test/sample-block4 ha 1 localhost.localdomain 1GiB --json-pretty { "IQN":"iqn.2016-12.org.gluster-block:e92ca4a0-5325-4c4b-a407-9e75790e4c7f", "PORTAL(S)":[ "localhost.localdomain:3260" ], "RESULT":"SUCCESS" } Change-Id: Ie51039e3dee0b3357d2347b4087e0fbe299aa29e Fixes: #3 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Diffstat (limited to 'rpc/rpcl')
-rw-r--r--rpc/rpcl/block.x39
1 files changed, 27 insertions, 12 deletions
diff --git a/rpc/rpcl/block.x b/rpc/rpcl/block.x
index 4d840ff..5d9c2a5 100644
--- a/rpc/rpcl/block.x
+++ b/rpc/rpcl/block.x
@@ -3,6 +3,17 @@
%#include "rpc-pragmas.h"
#endif
+enum JsonResponseFormat {
+ GB_JSON_NONE = 0,
+
+ GB_JSON_PLAIN = 1,
+ GB_JSON_SPACED = 2,
+ GB_JSON_PRETTY = 3,
+ GB_JSON_DEFAULT = 4,
+
+ GB_JSON_MAX
+};
+
struct blockCreate {
char ipaddr[255];
char volume[255];
@@ -17,11 +28,13 @@ struct blockCreateCli {
u_int mpath; /* HA request count */
char block_name[255];
string block_hosts<>;
+ enum JsonResponseFormat json_resp;
};
struct blockDeleteCli {
char block_name[255];
char volume[255];
+ enum JsonResponseFormat json_resp;
};
struct blockDelete {
@@ -30,22 +43,31 @@ struct blockDelete {
};
struct blockInfoCli {
- char block_name[255];
- char volume[255];
+ char block_name[255];
+ char volume[255];
+ enum JsonResponseFormat json_resp;
};
struct blockListCli {
- char volume[255];
- u_quad_t offset; /* dentry d_name offset */
+ char volume[255];
+ u_quad_t offset; /* dentry d_name offset */
+ enum JsonResponseFormat json_resp;
};
struct blockResponse {
int exit; /* exit code of the command */
- string out<>; /* json output */
+ string out<>; /* output; TODO: return respective objects */
u_quad_t offset; /* dentry d_name offset */
opaque xdata<>; /* future reserve */
};
+program GLUSTER_BLOCK {
+ version GLUSTER_BLOCK_VERS {
+ blockResponse BLOCK_CREATE(blockCreate) = 1;
+ blockResponse BLOCK_DELETE(blockDelete) = 2;
+ } = 1;
+} = 21215311; /* B2 L12 O15 C3 K11 */
+
program GLUSTER_BLOCK_CLI {
version GLUSTER_BLOCK_CLI_VERS {
blockResponse BLOCK_CREATE_CLI(blockCreateCli) = 1;
@@ -54,10 +76,3 @@ program GLUSTER_BLOCK_CLI {
blockResponse BLOCK_DELETE_CLI(blockDeleteCli) = 4;
} = 1;
} = 212153113; /* B2 L12 O15 C3 K11 C3 */
-
-program GLUSTER_BLOCK {
- version GLUSTER_BLOCK_VERS {
- blockResponse BLOCK_CREATE(blockCreate) = 1;
- blockResponse BLOCK_DELETE(blockDelete) = 2;
- } = 1;
-} = 21215311; /* B2 L12 O15 C3 K11 */