提交 63d3d895 编写于 作者: J John Ferlan

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 '89325806'), but ensure that they are mutually
 exclusive.
上级 d957e236
...@@ -109,6 +109,10 @@ ...@@ -109,6 +109,10 @@
.type = VSH_OT_STRING, \ .type = VSH_OT_STRING, \
.help = N_("auth secret usage to be used for underlying storage") \ .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", \ {.name = "adapter-name", \
.type = VSH_OT_STRING, \ .type = VSH_OT_STRING, \
.help = N_("adapter name to be used for underlying storage") \ .help = N_("adapter name to be used for underlying storage") \
...@@ -302,9 +306,11 @@ virshBuildPoolXML(vshControl *ctl, ...@@ -302,9 +306,11 @@ virshBuildPoolXML(vshControl *ctl,
*srcDev = NULL, *srcName = NULL, *srcFormat = NULL, *srcDev = NULL, *srcName = NULL, *srcFormat = NULL,
*target = NULL, *authType = NULL, *authUsername = NULL, *target = NULL, *authType = NULL, *authUsername = NULL,
*secretUsage = NULL, *adapterName = NULL, *adapterParent = NULL, *secretUsage = NULL, *adapterName = NULL, *adapterParent = NULL,
*adapterWwnn = NULL, *adapterWwpn = NULL; *adapterWwnn = NULL, *adapterWwpn = NULL, *secretUUID = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid");
if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0)
goto cleanup; goto cleanup;
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
...@@ -319,6 +325,7 @@ virshBuildPoolXML(vshControl *ctl, ...@@ -319,6 +325,7 @@ virshBuildPoolXML(vshControl *ctl,
vshCommandOptStringReq(ctl, cmd, "auth-type", &authType) < 0 || vshCommandOptStringReq(ctl, cmd, "auth-type", &authType) < 0 ||
vshCommandOptStringReq(ctl, cmd, "auth-username", &authUsername) < 0 || vshCommandOptStringReq(ctl, cmd, "auth-username", &authUsername) < 0 ||
vshCommandOptStringReq(ctl, cmd, "secret-usage", &secretUsage) < 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-name", &adapterName) < 0 ||
vshCommandOptStringReq(ctl, cmd, "adapter-wwnn", &adapterWwnn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-wwnn", &adapterWwnn) < 0 ||
vshCommandOptStringReq(ctl, cmd, "adapter-wwpn", &adapterWwpn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-wwpn", &adapterWwpn) < 0 ||
...@@ -349,11 +356,14 @@ virshBuildPoolXML(vshControl *ctl, ...@@ -349,11 +356,14 @@ virshBuildPoolXML(vshControl *ctl,
virBufferAsprintf(&buf, "<adapter type='scsi_host' name='%s'/>\n", virBufferAsprintf(&buf, "<adapter type='scsi_host' name='%s'/>\n",
adapterName); adapterName);
} }
if (authType && authUsername && secretUsage) { if (authType && authUsername && (secretUsage || secretUUID)) {
virBufferAsprintf(&buf, "<auth type='%s' username='%s'>\n", virBufferAsprintf(&buf, "<auth type='%s' username='%s'>\n",
authType, authUsername); authType, authUsername);
virBufferAdjustIndent(&buf, 2); virBufferAdjustIndent(&buf, 2);
virBufferAsprintf(&buf, "<secret usage='%s'/>\n", secretUsage); if (secretUsage)
virBufferAsprintf(&buf, "<secret usage='%s'/>\n", secretUsage);
else
virBufferAsprintf(&buf, "<secret uuid='%s'/>\n", secretUUID);
virBufferAdjustIndent(&buf, -2); virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</auth>\n"); virBufferAddLit(&buf, "</auth>\n");
} }
......
...@@ -3703,7 +3703,8 @@ just I<--build> is provided, then B<pool-build> is called with no flags. ...@@ -3703,7 +3703,8 @@ just I<--build> is provided, then B<pool-build> is called with no flags.
=item B<pool-create-as> I<name> I<type> =item B<pool-create-as> I<name> I<type>
[I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>]
[I<--source-name name>] [I<--target path>] [I<--source-format format>] [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-name name>] | [I<--adapter-wwnn> I<--adapter-wwpn>]
[I<--adapter-parent parent>]] [I<--adapter-parent parent>]]
[I<--build>] [[I<--overwrite>] | [I<--no-overwrite>]] [I<--print-xml>] [I<--build>] [[I<--overwrite>] | [I<--no-overwrite>]] [I<--print-xml>]
...@@ -3737,10 +3738,12 @@ the host file system. ...@@ -3737,10 +3738,12 @@ the host file system.
[I<--source-format format>] provides information about the format of the [I<--source-format format>] provides information about the format of the
pool (pool types fs, netfs, disk, logical). 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 provides the elements required to generate authentication credentials for
the storage pool. The I<authtype> is either chap for iscsi I<type> pools or the storage pool. The I<authtype> is either chap for iscsi I<type> pools or
ceph for rbd I<type> pools. ceph for rbd I<type> pools. Either the secret I<usage> or I<uuid> value may
be provided, but not both.
[I<--adapter-name name>] defines the scsi_hostN adapter name to be used for [I<--adapter-name name>] defines the scsi_hostN adapter name to be used for
the scsi_host adapter type pool. the scsi_host adapter type pool.
...@@ -3770,7 +3773,8 @@ from the XML I<file>. ...@@ -3770,7 +3773,8 @@ from the XML I<file>.
=item B<pool-define-as> I<name> I<type> =item B<pool-define-as> I<name> I<type>
[I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>]
[I<--source-name name>] [I<--target path>] [I<--source-format format>] [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-name name>] | [I<--adapter-wwnn> I<--adapter-wwpn>]
[I<--adapter-parent parent>]] [I<--print-xml>] [I<--adapter-parent parent>]] [I<--print-xml>]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册