From 63d3d895a2c00a849440706b3daa7199296b4b33 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Tue, 5 Sep 2017 13:44:15 -0400 Subject: [PATCH] virsh: Add/allow secret-uuid for pool-{define|create}-as https://bugzilla.redhat.com/show_bug.cgi?id=1476775 For the virsh pool-{define|create}-as command, let's allow using --secret-uuid on the command line as an alternative to --secret-usage (added for commit id '8932580'), but ensure that they are mutually exclusive. --- tools/virsh-pool.c | 16 +++++++++++++--- tools/virsh.pod | 12 ++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 558461b3dc..96a623284d 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -109,6 +109,10 @@ .type = VSH_OT_STRING, \ .help = N_("auth secret usage to be used for underlying storage") \ }, \ + {.name = "secret-uuid", \ + .type = VSH_OT_STRING, \ + .help = N_("auth secret UUID to be used for underlying storage") \ + }, \ {.name = "adapter-name", \ .type = VSH_OT_STRING, \ .help = N_("adapter name to be used for underlying storage") \ @@ -302,9 +306,11 @@ virshBuildPoolXML(vshControl *ctl, *srcDev = NULL, *srcName = NULL, *srcFormat = NULL, *target = NULL, *authType = NULL, *authUsername = NULL, *secretUsage = NULL, *adapterName = NULL, *adapterParent = NULL, - *adapterWwnn = NULL, *adapterWwpn = NULL; + *adapterWwnn = NULL, *adapterWwpn = NULL, *secretUUID = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; + VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid"); + if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) goto cleanup; if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) @@ -319,6 +325,7 @@ virshBuildPoolXML(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "auth-type", &authType) < 0 || vshCommandOptStringReq(ctl, cmd, "auth-username", &authUsername) < 0 || vshCommandOptStringReq(ctl, cmd, "secret-usage", &secretUsage) < 0 || + vshCommandOptStringReq(ctl, cmd, "secret-uuid", &secretUUID) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-name", &adapterName) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-wwnn", &adapterWwnn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-wwpn", &adapterWwpn) < 0 || @@ -349,11 +356,14 @@ virshBuildPoolXML(vshControl *ctl, virBufferAsprintf(&buf, "\n", adapterName); } - if (authType && authUsername && secretUsage) { + if (authType && authUsername && (secretUsage || secretUUID)) { virBufferAsprintf(&buf, "\n", authType, authUsername); virBufferAdjustIndent(&buf, 2); - virBufferAsprintf(&buf, "\n", secretUsage); + if (secretUsage) + virBufferAsprintf(&buf, "\n", secretUsage); + else + virBufferAsprintf(&buf, "\n", secretUUID); virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); } diff --git a/tools/virsh.pod b/tools/virsh.pod index b257e25874..00d93781ac 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3703,7 +3703,8 @@ just I<--build> is provided, then B is called with no flags. =item B I I [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>] +[I<--auth-type authtype> I<--auth-username username> +[I<--secret-usage usage> | I<--secret-uuid uuid>]] [[I<--adapter-name name>] | [I<--adapter-wwnn> I<--adapter-wwpn>] [I<--adapter-parent parent>]] [I<--build>] [[I<--overwrite>] | [I<--no-overwrite>]] [I<--print-xml>] @@ -3737,10 +3738,12 @@ 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>] +[I<--auth-type authtype> I<--auth-username username> +[I<--secret-usage usage> | I<--secret-uuid uuid>]] 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. +ceph for rbd I pools. Either the secret I or I value may +be provided, but not both. [I<--adapter-name name>] defines the scsi_hostN adapter name to be used for the scsi_host adapter type pool. @@ -3770,7 +3773,8 @@ from the XML I. =item B I I [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>] +[I<--auth-type authtype> I<--auth-username username> +[I<--secret-usage usage> | I<--secret-uuid uuid>]] [[I<--adapter-name name>] | [I<--adapter-wwnn> I<--adapter-wwpn>] [I<--adapter-parent parent>]] [I<--print-xml>] -- GitLab