From 2445dd3403b3b6e2e903f6d476ed4076e9a51e29 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Thu, 23 Feb 2017 20:43:07 +0530 Subject: gluster-blockd: parse create and delete outputs The new parsed output of create and delete command will look like: $ gluster-block create sample/sample-block ha 2 ${HOST1} ${HOST2} 1GiB IQN: iqn.2016-12.org.gluster-block:aafea465-9167-4880-b37c-2c36db8562ea PORTAL(S): ${HOST1}:3260 ${HOST2}:3260 RESULT: SUCCESS $ gluster-block delete sample/sample-block SUCCESSFUL ON: ${HOST1} ${HOST2} RESULT: SUCCESS Change-Id: Id98e643c62a898a1f7298b6cfeb6ddfa10397b7f Signed-off-by: Prasanna Kumar Kalever --- utils/utils.c | 18 ++++++++++++++++++ utils/utils.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) (limited to 'utils') diff --git a/utils/utils.c b/utils/utils.c index cb0e96e..7f43bc4 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -72,6 +72,24 @@ blockMetaStatusEnumParse(const char *opt) return i; } +int blockRemoteCreateRespEnumParse(const char *opt) +{ + int i; + + + if (!opt) { + return GB_REMOTE_CREATE_RESP_MAX; + } + + for (i = 0; i < GB_REMOTE_CREATE_RESP_MAX; i++) { + if (strstr(opt, RemoteCreateRespLookup[i])) { + return i; + } + } + + return i; +} + int gbAlloc(void *ptrptr, size_t size, diff --git a/utils/utils.h b/utils/utils.h index f904540..f551e46 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -44,6 +44,8 @@ # define FAILED_DELETING_FILE "failed while deleting block file from gluster volume" # define FAILED_DELETING_META "failed while deleting block meta file from volume" +# define FAILED_DEPENDENCY "failed dependency, check if you have targetcli and tcmu-runner installed" + # define LOCK(x) \ do { \ @@ -296,6 +298,32 @@ static const char *const MetaStatusLookup[] = { [GB_METASTATUS_MAX] = NULL, }; +typedef enum RemoteCreateResp { + GB_BACKEND_RESP = 0, + GB_IQN_RESP = 1, + GB_TPG_NO_RESP = 2, + GB_LUN_NO_RESP = 3, + GB_IP_PORT_RESP = 4, + GB_PORTAL_RESP = 5, + GB_FAILED_RESP = 6, + GB_FAILED_DEPEND = 7, + + GB_REMOTE_CREATE_RESP_MAX +} RemoteCreateResp; + +static const char *const RemoteCreateRespLookup[] = { + [GB_BACKEND_RESP] = "Created user-backed storage object ", + [GB_IQN_RESP] = "Created target ", + [GB_TPG_NO_RESP] = "Created TPG ", + [GB_LUN_NO_RESP] = "Created LUN ", + [GB_IP_PORT_RESP] = "Using default IP port ", + [GB_PORTAL_RESP] = "Created network portal ", + [GB_FAILED_RESP] = "failed to configure on ", + [GB_FAILED_DEPEND] = "check if targetcli and tcmu-runner are installed.", + + [GB_REMOTE_CREATE_RESP_MAX] = NULL, +}; + int glusterBlockCLIOptEnumParse(const char *opt); @@ -303,6 +331,8 @@ int blockMetaKeyEnumParse(const char *opt); int blockMetaStatusEnumParse(const char *opt); +int blockRemoteCreateRespEnumParse(const char *opt); + int gbAlloc(void *ptrptr, size_t size, const char *filename, const char *funcname, size_t linenr); -- cgit