From 5d48aba7b65dfad09bfc639e3434f03227b8bd50 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Tue, 11 Apr 2017 16:41:33 +0530 Subject: create: support 'auth enable' option This patch add support to enable auth while create. The schematics of authentication setting for/while create, looks like $ gluster-block create block-test/sample-block ha 1 auth enable \ 192.168.0.105 1GiB --json-pretty { "IQN":"iqn.2016-12.org.gluster-block:dc6cca79-f9b7-44f5-acaf-ac81c9cc7c2e", "USERNAME":"dc6cca79-f9b7-44f5-acaf-ac81c9cc7c2e", "PASSWORD":"ae48635a-6902-454c-949a-f2ad0e056086", "PORTAL(S)":[ "192.168.0.105:3260" ], "RESULT":"SUCCESS" } Change-Id: Ib8f5ddd904cb879e0ee05f6a7c3c381c6615a0e4 Fixes: #5 Signed-off-by: Prasanna Kumar Kalever --- cli/gluster-block.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'cli') diff --git a/cli/gluster-block.c b/cli/gluster-block.c index 3020587..a980110 100644 --- a/cli/gluster-block.c +++ b/cli/gluster-block.c @@ -35,7 +35,8 @@ const char *argp_program_version = "" \ "in all cases as published by the Free Software Foundation."; #define GB_CREATE_HELP_STR "gluster-block create "\ - "[ha ] [--json*]" + "[ha ] [auth enable|disable] "\ + " [--json*]" #define GB_DELETE_HELP_STR "gluster-block delete [--json*]" #define GB_MODIFY_HELP_STR "gluster-block modify "\ @@ -182,7 +183,7 @@ glusterBlockHelp(void) " gluster-block [] [--json*]\n" "\n" "commands:\n" - " create [ha ] \n" + " create [ha ] [auth enable|disable] \n" " create block device.\n" "\n" " list \n" @@ -353,6 +354,26 @@ glusterBlockCreate(int argcount, char **options, int json) } } + if (argcount - optind >= 2) { /* atleast 2 needed */ + /* if auth given then collect boolean which is next by 'auth' arg */ + if (!strcmp(options[optind], "auth")) { + optind++; + if(strcmp (options[optind], "enable") == 0) { + cobj.auth_mode = 1; + } else if (strcmp (options[optind], "disable") == 0) { + cobj.auth_mode = 0; + } else { + MSG("%s\n", "argument to 'auth' doesn't seems to be right"); + MSG("%s\n", GB_CREATE_HELP_STR); + LOG("cli", GB_LOG_ERROR, "Create failed while parsing argument " + "to auth for <%s/%s>", + cobj.volume, cobj.block_name); + goto out; + } + optind++; + } + } + if (argcount - optind < 2) { /* left with servers and size so 2 */ MSG("%s\n", "Insufficient arguments for create"); MSG("%s\n", GB_CREATE_HELP_STR); -- cgit