Redirecting stdout is not a feasible approach, as that also affects
all run_commands and other command executions/forks done by the API
handler, and thus breaks parsing outputs of such command executions
in the API handlers.
We plan to add a `--result-fd` option instead, allowing users to pass
their own file, open FD or named pipe to the pvesh, so that they can
process the output in streaming or in full afterward afterwards.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
otherwise, print/warn statements by the API endpoint are included in the
output, which breaks JSON parsing in case of output-format == json*.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Based to the suggestion of Wolfgang, in regard to `split_list()`,
I converted the `split_list()` to `split(/\0/, $param->{$key});`
this will split the `$param->{$key}` null characters and push each
element to the `$args` array along with the key value.
changes since v1:
* get rid of the `use PVE::Tools qw(split_list);` since not need it anymore.
* replace the split_list to split(/\0/).
Signed-off-by: Moayad Almalat <m.almalat@proxmox.com>
When a property description already contained an option, no standard
output options at all would be added to it, e.g. '/nodes/NODE/vzdump'
already defines its own 'quiet'. Now all not yet defined options are
added to the description, this is done by using the fact that we can
pass a explicit list of std options to add to
add_standard_output_properties, so we filter all already defined ones
out and just pass that as list.
Fixes
pvesh create /nodes/NODE/vzdump -vmid ID -storage STORAGE
issued from a different node and
pvesh create /nodes/NODE/vzdump -vmid ID -storage STORAGE --output-format json
and maybe other calls.
Reported here: https://forum.proxmox.com/threads/output-format-error-with-pvesh-create.47711/
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
When a remote node not return a json, we got and error.
This is fixing this:
pvesh set /nodes/localname/network
UPID:kvmformation2:0034937B:09352894:5E41106C:srvreload:networking:root@pam:
pvesh set /nodes/remotenode/network
JSON text must be an object or array (but found number, string, true, false or null, use allow_nonref to allow this) at /usr/share/perl5/PVE/CLI/pvesh.pm line 125.
This patch simply return raw result if it's not a json
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Checks that the handler for the API call even exists before verifying the
parameter schema. By this the reported error message is more descriptive.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Do not add/extract standard options if the method itself defined properties
using the same names (like 'quiet').
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Most of those API calls return simple strings, so it does not really matter.
Nethertheless, some calls return complex data structures and we want to set
output format for them.