From 450f7e89116ed104f092dd1a709c0f057150a4f7 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Wed, 7 Feb 2018 21:40:13 +0530 Subject: create: support [storage ] option $ gluster-block help gluster-block (0.3) usage: gluster-block [] [--json*] commands: create [ha ] [auth ] [prealloc ] [storage ] create block device [defaults: ha 1, auth disable, prealloc no, size in bytes] [...] supported JSON formats: --json|--json-plain|--json-spaced|--json-pretty Fixes: #18 Change-Id: I5d9b4abb58596bd2297cffb294c6d31f752d53e9 Signed-off-by: Prasanna Kumar Kalever --- utils/utils.c | 20 ++++++++++++++++++++ utils/utils.h | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) (limited to 'utils') diff --git a/utils/utils.c b/utils/utils.c index 13d61cc..3f52134 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -49,6 +49,26 @@ glusterBlockCLIOptEnumParse(const char *opt) } +int +glusterBlockCLICreateOptEnumParse(const char *opt) +{ + int i; + + + if (!opt) { + return GB_CLI_CREATE_OPT_MAX; + } + + for (i = 0; i < GB_CLI_CREATE_OPT_MAX; i++) { + if (!strcmp(opt, gbCliCreateOptLookup[i])) { + return i; + } + } + + return i; +} + + int glusterBlockDaemonOptEnumParse(const char *opt) { diff --git a/utils/utils.h b/utils/utils.h index 3362c10..905b9dd 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -374,6 +374,26 @@ static const char *const gbCliCmdlineOptLookup[] = { [GB_CLI_OPT_MAX] = NULL, }; +typedef enum gbCliCreateOptions { + GB_CLI_CREATE_UNKNOWN = 0, + GB_CLI_CREATE_HA = 1, + GB_CLI_CREATE_AUTH = 2, + GB_CLI_CREATE_PREALLOC = 3, + GB_CLI_CREATE_STORAGE = 4, + + GB_CLI_CREATE_OPT_MAX +} gbCliCreateOptions; + +static const char *const gbCliCreateOptLookup[] = { + [GB_CLI_CREATE_UNKNOWN] = "NONE", + [GB_CLI_CREATE_HA] = "ha", + [GB_CLI_CREATE_AUTH] = "auth", + [GB_CLI_CREATE_PREALLOC] = "prealloc", + [GB_CLI_CREATE_STORAGE] = "storage", + + [GB_CLI_CREATE_OPT_MAX] = NULL, +}; + typedef enum gbDaemonCmdlineOption { GB_DAEMON_UNKNOWN = 0, GB_DAEMON_HELP = 1, @@ -509,6 +529,8 @@ static const char *const RemoteCreateRespLookup[] = { int glusterBlockCLIOptEnumParse(const char *opt); +int glusterBlockCLICreateOptEnumParse(const char *opt); + int glusterBlockDaemonOptEnumParse(const char *opt); int blockLogLevelEnumParse(const char *opt); -- cgit