From 893258063dfe82aad0300c71e4e379a48e1910d1 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Wed, 3 Dec 2014 18:45:50 -0500 Subject: [PATCH] virsh: Add auth options for pool-{create|define}-as Add 3 new optional options for the pool-create-as and pool-define-as command in order to define the 3 elements required in order to add an auth element, such as: --- tools/virsh-pool.c | 28 ++++++++++++++++++++++++++-- tools/virsh.pod | 7 +++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index cf7776c57e..bba7d6870f 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -223,6 +223,18 @@ static const vshCmdOptDef opts_pool_X_as[] = { .type = VSH_OT_STRING, .help = N_("format for underlying storage") }, + {.name = "auth-type", + .type = VSH_OT_STRING, + .help = N_("auth type to be used for underlying storage") + }, + {.name = "auth-username", + .type = VSH_OT_STRING, + .help = N_("auth username to be used for underlying storage") + }, + {.name = "secret-usage", + .type = VSH_OT_STRING, + .help = N_("auth secret usage to be used for underlying storage") + }, {.name = NULL} }; @@ -234,7 +246,8 @@ vshBuildPoolXML(vshControl *ctl, { const char *name = NULL, *type = NULL, *srcHost = NULL, *srcPath = NULL, *srcDev = NULL, *srcName = NULL, *srcFormat = NULL, - *target = NULL; + *target = NULL, *authType = NULL, *authUsername = NULL, + *secretUsage = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) @@ -247,7 +260,10 @@ vshBuildPoolXML(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "source-dev", &srcDev) < 0 || vshCommandOptStringReq(ctl, cmd, "source-name", &srcName) < 0 || vshCommandOptStringReq(ctl, cmd, "source-format", &srcFormat) < 0 || - vshCommandOptStringReq(ctl, cmd, "target", &target) < 0) + vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 || + vshCommandOptStringReq(ctl, cmd, "auth-type", &authType) < 0 || + vshCommandOptStringReq(ctl, cmd, "auth-username", &authUsername) < 0 || + vshCommandOptStringReq(ctl, cmd, "secret-usage", &secretUsage) < 0) goto cleanup; virBufferAsprintf(&buf, "\n", type); @@ -263,6 +279,14 @@ vshBuildPoolXML(vshControl *ctl, virBufferAsprintf(&buf, "\n", srcPath); if (srcDev) virBufferAsprintf(&buf, "\n", srcDev); + if (authType && authUsername && secretUsage) { + virBufferAsprintf(&buf, "\n", + authType, authUsername); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "\n", secretUsage); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + } if (srcFormat) virBufferAsprintf(&buf, "\n", srcFormat); if (srcName) diff --git a/tools/virsh.pod b/tools/virsh.pod index 1b31597326..45dd924fcd 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2959,6 +2959,7 @@ Create and start a pool object from the XML I. =item B I I [I<--print-xml>] [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] [I<--source-name name>] [I<--target path>] [I<--source-format format>] +[I<--auth-type authtype> I<--auth-username username> I<--secret-usage usage>] Create and start a pool object I from the raw parameters. If I<--print-xml> is specified, then print the XML of the pool object @@ -2984,6 +2985,11 @@ the host file system. [I<--source-format format>] provides information about the format of the pool (pool types fs, netfs, disk, logical). +[I<--auth-type authtype> I<--auth-username username> I<--secret-usage usage>] +provides the elements required to generate authentication credentials for +the storage pool. The I is either chap for iscsi I pools or +ceph for rbd I pools. + =item B I Create, but do not start, a pool object from the XML I. @@ -2991,6 +2997,7 @@ Create, but do not start, a pool object from the XML I. =item B I I [I<--print-xml>] [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] [I<--source-name name>] [I<--target path>] [I<--source-format format>] +[I<--auth-type authtype> I<--auth-username username> I<--secret-usage usage>] Create, but do not start, a pool object I from the raw parameters. If I<--print-xml> is specified, then print the XML of the pool object -- 2.39.5