mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: add support for '--validate' option in define secret
Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5cb3d4ed6d
commit
ec5561c0bb
@ -6698,13 +6698,15 @@ secret-define
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
secret-define file
|
secret-define file [--validate]
|
||||||
|
|
||||||
Create a secret with the properties specified in *file*, with no associated
|
Create a secret with the properties specified in *file*, with no associated
|
||||||
secret value. If *file* does not specify a UUID, choose one automatically.
|
secret value. If *file* does not specify a UUID, choose one automatically.
|
||||||
If *file* specifies a UUID of an existing secret, replace its properties by
|
If *file* specifies a UUID of an existing secret, replace its properties by
|
||||||
properties defined in *file*, without affecting the secret value.
|
properties defined in *file*, without affecting the secret value.
|
||||||
|
|
||||||
|
Optionally, the format of the input XML file can be validated against an
|
||||||
|
internal RNG schema with *--validate*.
|
||||||
|
|
||||||
secret-dumpxml
|
secret-dumpxml
|
||||||
--------------
|
--------------
|
||||||
|
@ -73,6 +73,10 @@ static const vshCmdInfo info_secret_define[] = {
|
|||||||
|
|
||||||
static const vshCmdOptDef opts_secret_define[] = {
|
static const vshCmdOptDef opts_secret_define[] = {
|
||||||
VIRSH_COMMON_OPT_FILE(N_("file containing secret attributes in XML")),
|
VIRSH_COMMON_OPT_FILE(N_("file containing secret attributes in XML")),
|
||||||
|
{.name = "validate",
|
||||||
|
.type = VSH_OT_BOOL,
|
||||||
|
.help = N_("validate the XML against the schema")
|
||||||
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,15 +88,19 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virSecretPtr res;
|
virSecretPtr res;
|
||||||
char uuid[VIR_UUID_STRING_BUFLEN];
|
char uuid[VIR_UUID_STRING_BUFLEN];
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
unsigned int flags = 0;
|
||||||
virshControl *priv = ctl->privData;
|
virshControl *priv = ctl->privData;
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (vshCommandOptBool(cmd, "validate"))
|
||||||
|
flags |= VIR_SECRET_DEFINE_VALIDATE;
|
||||||
|
|
||||||
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
|
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!(res = virSecretDefineXML(priv->conn, buffer, 0))) {
|
if (!(res = virSecretDefineXML(priv->conn, buffer, flags))) {
|
||||||
vshError(ctl, _("Failed to set attributes from %s"), from);
|
vshError(ctl, _("Failed to set attributes from %s"), from);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user