From d723907c8eaa25f107c7fadd79ca5f9bc6596edf Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Wed, 2 Aug 2017 23:42:29 +0530 Subject: gluster-block: support force delete option $ gluster-block help gluster-block (0.2.1) usage: gluster-block [] [--json*] commands: [...] delete [force] delete block device. [...] Change-Id: I64ac01ec148e2e1d4d0ba0d4c5560df9334d58f5 Signed-off-by: Prasanna Kumar Kalever --- cli/gluster-block.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'cli') diff --git a/cli/gluster-block.c b/cli/gluster-block.c index 21ad44f..04f081f 100644 --- a/cli/gluster-block.c +++ b/cli/gluster-block.c @@ -20,7 +20,7 @@ "[prealloc ] "\ " [--json*]" -# define GB_DELETE_HELP_STR "gluster-block delete [--json*]" +# define GB_DELETE_HELP_STR "gluster-block delete [force] [--json*]" # define GB_MODIFY_HELP_STR "gluster-block modify "\ " [--json*]" # define GB_INFO_HELP_STR "gluster-block info [--json*]" @@ -202,7 +202,7 @@ glusterBlockHelp(void) " info \n" " details about block device.\n" "\n" - " delete \n" + " delete [force]\n" " delete block device.\n" "\n" " modify \n" @@ -458,7 +458,20 @@ glusterBlockDelete(int argcount, char **options, int json) int ret = -1; - GB_ARGCHECK_OR_RETURN(argcount, 3, "delete", GB_DELETE_HELP_STR); + if (argcount < 3 || argcount > 4) { + MSG("Inadequate arguments for delete:\n%s\n", GB_DELETE_HELP_STR); + return -1; + } + + if (argcount == 4) { + if (strcmp(options[3], "force")) { + MSG("unknown option '%s' for delete:\n%s\n", options[3], GB_DELETE_HELP_STR); + return -1; + } else { + cobj.force = true; + } + } + cobj.json_resp = json; if (glusterBlockParseVolumeBlock (options[2], cobj.volume, @@ -518,7 +531,7 @@ glusterBlockParseArgs(int count, char **options) opt = glusterBlockCLIOptEnumParse(options[1]); if (!opt || opt >= GB_CLI_OPT_MAX) { - MSG("unknown option: %s\n", options[1]); + MSG("Unknown option: %s\n", options[1]); return -1; } -- cgit