diff options
author | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2018-03-05 12:31:00 +0530 |
---|---|---|
committer | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2018-03-05 15:13:30 +0530 |
commit | 305e1c5ffead749fd6ea555b52e46d9e64c9bd55 (patch) | |
tree | f18a8295763ab51547bf2a1f28f48e74bb4c3da6 | |
parent | 2c44d5d25adba74f6aa3553bfa33d2909490fde1 (diff) |
info: show failed nodes
$ cat /mnt/block-meta/block
VOLUME: sample
GBID: 9d278e06-b2d1-4050-bd92-c8e8b40a5654
HA: 3
ENTRYCREATE: INPROGRESS
SIZE: 9663676416
ENTRYCREATE: SUCCESS
192.168.0.104: CONFIGSUCCESS
192.168.0.105: CONFIGFAIL
192.168.0.106: CLEANUPFAIL
$ gluster-block info sample/block
NAME: block
VOLUME: sample
GBID: 9d278e06-b2d1-4050-bd92-c8e8b40a5654
SIZE: 9.0 GiB
HA: 3
PASSWORD:
EXPORTED ON: 192.168.0.104
ENCOUNTERED FAILURES ON: 192.168.0.105 192.168.0.106
$ gluster-block info sample/block --json-pretty
{
"NAME":"block",
"VOLUME":"sample",
"GBID":"9d278e06-b2d1-4050-bd92-c8e8b40a5654",
"SIZE":"9.0 GiB",
"HA":3,
"PASSWORD":"",
"EXPORTED ON":[
"192.168.0.104"
],
"ENCOUNTERED FAILURES ON":[
"192.168.0.105",
"192.168.0.106"
]
}
Change-Id: I3d47e75f64719b9eeab661006bf4ccaa629a8408
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
-rw-r--r-- | rpc/block_svc_routines.c | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c index a28e64b..149c7f6 100644 --- a/rpc/block_svc_routines.c +++ b/rpc/block_svc_routines.c @@ -3999,12 +3999,15 @@ blockInfoCliFormatResponse(blockInfoCli *blk, int errCode, char *errMsg, MetaInfo *info, struct blockResponse *reply) { - json_object *json_obj = NULL; - json_object *json_array = NULL; - char *tmp = NULL; - char *out = NULL; - int i = 0; - char *hr_size = NULL; /* Human Readable size */ + json_object *json_obj = NULL; + json_object *json_array1 = NULL; + json_object *json_array2 = NULL; + char *tmp = NULL; + char *tmp2 = NULL; + char *tmp3 = NULL; + char *out = NULL; + int i = 0; + char *hr_size = NULL; /* Human Readable size */ if (!reply) { return; @@ -4040,42 +4043,67 @@ blockInfoCliFormatResponse(blockInfoCli *blk, int errCode, json_object_object_add(json_obj, "HA", json_object_new_int(info->mpath)); json_object_object_add(json_obj, "PASSWORD", GB_JSON_OBJ_TO_STR(info->passwd)); - json_array = json_object_new_array(); + json_array1 = json_object_new_array(); + json_array2 = json_object_new_array(); for (i = 0; i < info->nhosts; i++) { if (blockhostIsValid (info->list[i]->status)) { - json_object_array_add(json_array, GB_JSON_OBJ_TO_STR(info->list[i]->addr)); + json_object_array_add(json_array1, GB_JSON_OBJ_TO_STR(info->list[i]->addr)); + } else { + switch (blockMetaStatusEnumParse(info->list[i]->status)) { + case GB_CONFIG_FAIL: + case GB_CLEANUP_FAIL: + json_object_array_add(json_array2, GB_JSON_OBJ_TO_STR(info->list[i]->addr)); + break; + } } } - json_object_object_add(json_obj, "EXPORTED NODE(S)", json_array); + json_object_object_add(json_obj, "EXPORTED ON", json_array1); + json_object_object_add(json_obj, "ENCOUNTERED FAILURES ON", json_array2); GB_ASPRINTF(&reply->out, "%s\n", json_object_to_json_string_ext(json_obj, mapJsonFlagToJsonCstring(blk->json_resp))); - json_object_put(json_array); + json_object_put(json_array1); + json_object_put(json_array2); json_object_put(json_obj); } else { if (GB_ASPRINTF(&tmp, "NAME: %s\nVOLUME: %s\nGBID: %s\nSIZE: %s\n" - "HA: %zu\nPASSWORD: %s\nEXPORTED NODE(S):", + "HA: %zu\nPASSWORD: %s\nEXPORTED ON:", blk->block_name, info->volume, info->gbid, hr_size, info->mpath, info->passwd) == -1) { goto out; } for (i = 0; i < info->nhosts; i++) { - if (blockhostIsValid (info->list[i]->status)) { - if (GB_ASPRINTF(&out, "%s %s", tmp, info->list[i]->addr) == -1) { - GB_FREE (tmp); + if (blockhostIsValid (info->list[i]->status)) { + if (GB_ASPRINTF(&out, "%s %s", tmp, info->list[i]->addr) == -1) { + GB_FREE (tmp); + goto out; + } + GB_FREE (tmp); + tmp = out; + } else { + switch (blockMetaStatusEnumParse(info->list[i]->status)) { + case GB_CONFIG_FAIL: + case GB_CLEANUP_FAIL: + if (GB_ASPRINTF(&tmp2, "%s %s", tmp3?tmp3:"", info->list[i]->addr) == -1) { + GB_FREE (tmp3); goto out; } - tmp = out; + GB_FREE (tmp3); + tmp3 = tmp2; + break; + } } } - if (GB_ASPRINTF(&reply->out, "%s\n", tmp) == -1) { + if (GB_ASPRINTF(&reply->out, "%s\nENCOUNTERED FAILURES ON:%s\n", tmp, tmp2?tmp2:"") == -1) { GB_FREE (tmp); + GB_FREE (tmp2); goto out; } GB_FREE (tmp); + GB_FREE (tmp2); } out: /*catch all*/ |