diff options
author | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2017-04-11 16:41:33 +0530 |
---|---|---|
committer | Prasanna Kumar Kalever <pkalever@redhat.com> | 2017-05-02 10:08:30 +0000 |
commit | 5d48aba7b65dfad09bfc639e3434f03227b8bd50 (patch) | |
tree | 3693acc473929c5592e68ffdd1990197cd6dfbed /cli | |
parent | 1ed7bd14303fca5c3dd36a30a88d4d2d053f4334 (diff) |
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 <prasanna.kalever@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r-- | cli/gluster-block.c | 25 |
1 files changed, 23 insertions, 2 deletions
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 <volname/blockname> "\ - "[ha <count>] <HOST1[,HOST2,...]> <size> [--json*]" + "[ha <count>] [auth enable|disable] "\ + "<HOST1[,HOST2,...]> <size> [--json*]" #define GB_DELETE_HELP_STR "gluster-block delete <volname/blockname> [--json*]" #define GB_MODIFY_HELP_STR "gluster-block modify <volname/blockname> "\ @@ -182,7 +183,7 @@ glusterBlockHelp(void) " gluster-block <command> <volname[/blockname]> [<args>] [--json*]\n" "\n" "commands:\n" - " create <volname/blockname> [ha <count>] <host1[,host2,...]> <size>\n" + " create <volname/blockname> [ha <count>] [auth enable|disable] <host1[,host2,...]> <size>\n" " create block device.\n" "\n" " list <volname>\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); |