mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
virsh: add support for '--validate' option in create network port
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
652147d0e1
commit
6779fca41c
@ -5452,10 +5452,12 @@ net-port-create
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
net-port-create network file
|
net-port-create network file [--validate]
|
||||||
|
|
||||||
Allocate a new network port reserving resources based on the
|
Allocate a new network port reserving resources based on the
|
||||||
port description.
|
port description.
|
||||||
|
Optionally, the format of the input XML file can be validated against an
|
||||||
|
internal RNG schema with *--validate*.
|
||||||
|
|
||||||
|
|
||||||
net-port-dumpxml
|
net-port-dumpxml
|
||||||
|
@ -1492,6 +1492,10 @@ static const vshCmdInfo info_network_port_create[] = {
|
|||||||
static const vshCmdOptDef opts_network_port_create[] = {
|
static const vshCmdOptDef opts_network_port_create[] = {
|
||||||
VIRSH_COMMON_OPT_NETWORK_FULL(VIR_CONNECT_LIST_NETWORKS_ACTIVE),
|
VIRSH_COMMON_OPT_NETWORK_FULL(VIR_CONNECT_LIST_NETWORKS_ACTIVE),
|
||||||
VIRSH_COMMON_OPT_FILE(N_("file containing an XML network port description")),
|
VIRSH_COMMON_OPT_FILE(N_("file containing an XML network port description")),
|
||||||
|
{.name = "validate",
|
||||||
|
.type = VSH_OT_BOOL,
|
||||||
|
.help = N_("validate the XML against the schema")
|
||||||
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1503,6 +1507,7 @@ cmdNetworkPortCreate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
virNetworkPtr network = NULL;
|
virNetworkPtr network = NULL;
|
||||||
|
unsigned int flags = 0;
|
||||||
|
|
||||||
network = virshCommandOptNetwork(ctl, cmd, NULL);
|
network = virshCommandOptNetwork(ctl, cmd, NULL);
|
||||||
if (network == NULL)
|
if (network == NULL)
|
||||||
@ -1511,12 +1516,15 @@ cmdNetworkPortCreate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (vshCommandOptBool(cmd, "validate"))
|
||||||
|
flags |= VIR_NETWORK_PORT_CREATE_VALIDATE;
|
||||||
|
|
||||||
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
|
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
|
||||||
vshSaveLibvirtError();
|
vshSaveLibvirtError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
port = virNetworkPortCreateXML(network, buffer, 0);
|
port = virNetworkPortCreateXML(network, buffer, flags);
|
||||||
|
|
||||||
if (port != NULL) {
|
if (port != NULL) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
Loading…
Reference in New Issue
Block a user