mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
cmdNetworkUpdate: Prefer VSH_EXCLUSIVE_OPTIONS over if-else tree
We have macros that check and reject mutually exclusive parameters to our commands. Use those instead of if-else tree. At the same time, the variable @current becomes useless therefore it is dropped. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ef766337ff
commit
6dce0b3016
@ -904,12 +904,14 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
int command, section, parentIndex = -1;
|
int command, section, parentIndex = -1;
|
||||||
const char *xml = NULL;
|
const char *xml = NULL;
|
||||||
char *xmlFromFile = NULL;
|
char *xmlFromFile = NULL;
|
||||||
bool current = vshCommandOptBool(cmd, "current");
|
|
||||||
bool config = vshCommandOptBool(cmd, "config");
|
bool config = vshCommandOptBool(cmd, "config");
|
||||||
bool live = vshCommandOptBool(cmd, "live");
|
bool live = vshCommandOptBool(cmd, "live");
|
||||||
unsigned int flags = 0;
|
unsigned int flags = VIR_NETWORK_UPDATE_AFFECT_CURRENT;
|
||||||
const char *affected;
|
const char *affected;
|
||||||
|
|
||||||
|
VSH_EXCLUSIVE_OPTIONS("current", "live");
|
||||||
|
VSH_EXCLUSIVE_OPTIONS("current", "config");
|
||||||
|
|
||||||
if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
|
if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -962,18 +964,10 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
|
|||||||
xml = xmlFromFile;
|
xml = xmlFromFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current) {
|
if (config)
|
||||||
if (live || config) {
|
flags |= VIR_NETWORK_UPDATE_AFFECT_CONFIG;
|
||||||
vshError(ctl, "%s", _("--current must be specified exclusively"));
|
if (live)
|
||||||
goto cleanup;
|
flags |= VIR_NETWORK_UPDATE_AFFECT_LIVE;
|
||||||
}
|
|
||||||
flags |= VIR_NETWORK_UPDATE_AFFECT_CURRENT;
|
|
||||||
} else {
|
|
||||||
if (config)
|
|
||||||
flags |= VIR_NETWORK_UPDATE_AFFECT_CONFIG;
|
|
||||||
if (live)
|
|
||||||
flags |= VIR_NETWORK_UPDATE_AFFECT_LIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virNetworkUpdate(network, command,
|
if (virNetworkUpdate(network, command,
|
||||||
section, parentIndex, xml, flags) < 0) {
|
section, parentIndex, xml, flags) < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user