5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-22 21:33:47 +03:00
Commit Graph

882 Commits

Author SHA1 Message Date
Dietmar Maurer
7b2ba123b4 generate_usage_str: do not group sub-commands
Usually, sub commands already form a logical group, so further grouping
just adds confusion (see 'qm' as example)

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-31 10:57:15 +02:00
Dietmar Maurer
90851cec3c print_api_result: fix test for undefined $result_schema 2018-07-31 08:29:45 +02:00
Dietmar Maurer
b51b930d2b print_api_result: allow to pass undefined schema
This is useful if we do not have a fixed schema, for example to
print results from qemu agent commands.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-30 15:53:06 +02:00
Dietmar Maurer
6bc094934b print_api_result_plain: new helper
Usefull to print result without borders an headers.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-30 15:52:53 +02:00
Dietmar Maurer
2ec79c0f95 print_text_table: align numbers to the right side
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-30 15:51:59 +02:00
Dietmar Maurer
b9474c9682 print_text_table: untaint $width
The value of $width depends on possible untainted $data (for example
task logs read from external files).

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-30 15:51:23 +02:00
Dietmar Maurer
6c7fee81f2 bump version to 5.0-38 2018-07-27 10:56:13 +02:00
Dietmar Maurer
5c59d8f99c getopt_usage: always remove $standard_output_options
Tools like pvesh and pveclient pass them as normal arguments. We use
a simply heuristic to test if there is an 'output_format' parameter.
If so, we remove all $standard_output_options and display [FORMAT_OPTIONS]
instead.
2018-07-27 07:48:44 +02:00
Dietmar Maurer
62c66c47fb getopt_usage: do not display $standard_output_options
Instead, simply add [FORMAT_OPTIONS] to the usage string.
2018-07-26 13:58:50 +02:00
Dietmar Maurer
ac6c61bf13 introcude new output format 'yaml' 2018-07-26 12:02:45 +02:00
Dietmar Maurer
b01a09e73f PVE::CLIFormatter - pass terminal option as separate parameter
This simplifies usage, because we can simple omit the $terminal_opts
parameter in most cases (automatically call query_terminal_option) while
still setting $options.
2018-07-26 11:57:15 +02:00
Dietmar Maurer
b99c04ada5 PVE::Certificate - set renderers for unix epoch and 'san' 2018-07-26 11:57:15 +02:00
Dietmar Maurer
ba752c8062 PVE::CLIFormatter - new 'yaml' renderer
Generates nice and readable output for list of string and simple objects.
2018-07-26 11:57:15 +02:00
Dietmar Maurer
2e2a450272 cli: print_text_table: correctly handle sort_key 0 2018-07-26 11:08:52 +02:00
Dietmar Maurer
9da2722861 PVE::CLIHandler - allow to define additional parameters for output formatter
Best shown with a example:

my $test_formatter = sub {
    my ($res, $result_schema, $fmt_param) = @_;
    PVE::CLIFormatter::print_api_result($res, $result_schema, undef, $fmt_param);
};

$cmddef = [ __PACKAGE__, 'test', [], undef, $test_formatter, $PVE::RESTHandler::standard_output_options],
2018-07-26 11:08:52 +02:00
Dietmar Maurer
4cbcd1386f cli: remove all output formatter magic from CLIHandler
- and rename format to 'output-format'

- provide a method to add properties to schema:
	PVE::RESTHandler::add_standard_output_properties

- provide methods to extract output properties:
	PVE::RESTHandler::extract_standard_output_properties()
2018-07-26 11:08:52 +02:00
Dietmar Maurer
bf5e9f8440 PVE::ACME - untaint saved account data
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-26 10:54:17 +02:00
Dominik Csapak
34d8999638 api dump: do not skip indexed params with only one index
We transform indexed parameters (like scsi0 scsi1 ...) to a single
scsi[n]. The check if we should transform did not handle the case
where a parameter was indexed but (currently) only index 0 existed.
Such definitions where simply skipped and seemed then to miss from
places using the API dump, like the api-viewer.

We now only skip those parameters with an index > 0 where the same
parameter with index 0 is defined.

This fixes a missing efidisk0 entry in an API dump[0].

[0]: https://forum.proxmox.com/threads/efidisk0-creation-missing-from-api.45624/

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-07-23 16:11:21 +02:00
Thomas Lamprecht
f4265f248f bump version to 5.0-37
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-07-18 10:48:05 +02:00
Wolfgang Bumiller
afd4f9966a fixup: parameters vs properties typo
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-07-18 10:42:24 +02:00
Thomas Lamprecht
11b30ba490 cli_handler: make standard options opt-in
The new standard options overwrite some already existing options in
already existing CLI tools, which is surely no good, e.g. vzdump
already has an quiet option which now gets overwritten, thus any
backup triggered by CRON always sents out an (additional) email.

Further, they may even only have an effect if the respective CLI
command uses an CLIFormatter print* method to output things.

And for some commands, like 'pvecm status' they may even never make
sense, as they exec an external program which doesn't honors nor gets
those std options...
Also some internal commands, like 'qm mtunnel' will never use it, as
probably even "normal" commands, as it may simply not make sense for
every command..

So make it opt-in for now, any CLI command can set std-output-opts to
get them.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-07-18 09:26:53 +02:00
Thomas Lamprecht
7c7bc4623d bump version to 5.0-36
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-07-10 14:06:33 +02:00
Dietmar Maurer
a05db8b5dd print_api_result: skip undefined object values
We use objects to return VM configurations, so we uónly want to display
defined values.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-10 13:52:20 +02:00
Dietmar Maurer
cd6591d38b output format options: remove 'plain', add 'json-pretty'
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-10 13:52:20 +02:00
Dietmar Maurer
f0bcf4d4c6 PVE::CLIFormatter::print_api_result - remove parameter $format
Instead, we pass it within $options.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-10 13:52:20 +02:00
Dietmar Maurer
0adee98536 cli_handler: pass common output options as separate parameter
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-10 13:52:20 +02:00
Dietmar Maurer
352b7a14c8 PVE::CLIFormatter - implement new output options
quiet: dont print anything
noheader: supres headers
noborder: no borders
human-readable: use renderers
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-10 13:52:20 +02:00
Wolfgang Bumiller
ec0f515131 tests: test newly added interfaces individually
And add eth2/3 to /proc/net/dev, that way we don't need to
create them "virtually" (which we shouldn't, for physical
interfaces).

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-07-10 12:34:10 +02:00
Wolfgang Bumiller
fc158d0d9c fixup: don't use exists boolean
The previous condition didn't fail tests because it was
always false. The 'exists' property is not actually usable
when writing the interface file. It is merely a hint that
the interface existed in /proc/net/dev while parsing the
interfaces file and is otherwise actually unused here.

Simply check for the existence of the interface in $ifaces.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-07-10 12:08:04 +02:00
Wolfgang Bumiller
c27ef07ff5 fixup: compare MTUs numerically
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-07-10 11:55:39 +02:00
Wolfgang Bumiller
cebd1c85f0 whitespace fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-07-10 11:55:21 +02:00
Wolfgang Bumiller
94d786b393 cleanup: whitespace and error message consistency
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-07-10 11:53:18 +02:00
Alexandre Derumier
9b053d70de Inotify : add mtu option
also check if mtu value is lower than parent interface

fixme: vxlan interface should be 50bytes lower than outgoing interface
       we need to find which interface is used (unicast/multicast/frr)
2018-07-10 11:38:54 +02:00
Alexandre Derumier
c4e564708b Inotify : add check vlan
verify than parent interface exist
verify than parent interface type is eth,bond,bridge
verify than parent bridge is vlan aware if type bridge
2018-07-10 11:38:54 +02:00
Alexandre Derumier
0115696f6a Inotify : add check_bond
verify than bond slaves exist && type is eth
2018-07-10 11:38:54 +02:00
Alexandre Derumier
9a052564e1 Inotify : add bridge ports options 2018-07-10 11:38:54 +02:00
Alexandre Derumier
95aa8788b8 Inotify : add vxlan interface support 2018-07-10 11:38:54 +02:00
Dietmar Maurer
c03b750906 PVE::RESTHandler::generate_usage_str - new static method to generate usage from $info
This is useful to generate usage information with pveclient, where we do not have
handler classes at all.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-06 10:20:25 +02:00
Dietmar Maurer
c850b99883 PVE::CLIFormatter::print_api_result - use print_api_list to print arrays
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-05 18:33:25 +02:00
Dietmar Maurer
e735d7b015 CLIFormatter - implement renderer for timestamps using GMT 2018-07-05 08:48:03 +02:00
Dietmar Maurer
1c096521f7 PVE::CLIFormatter::data_to_text - add parameter $options
Also pass $options to renderer functions.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-04 17:09:01 +02:00
Dietmar Maurer
5e287f60ae CLIFormatter - implement renderer for timestamps
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-04 17:08:52 +02:00
Dietmar Maurer
57d4415163 PVE::CLIHandler - allow to set LOG ID with $ENV{PVE_LOG_ID}
We use this with 'pvesh'.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-04 11:25:41 +02:00
Dietmar Maurer
ac15655f45 JSONSchema: register new standard option 'pve-output-format'
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-03 13:28:35 +02:00
Dietmar Maurer
c5adc5f9ef PVE::CLIFormatter::extract_properties_to_print - new helper
This improves sort order. We now priorize required values, and list
them before optional values.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-03 13:28:32 +02:00
Dietmar Maurer
f495c8681c CLIFormatter: define some commonly useful rendering functions
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-03 13:28:29 +02:00
Dietmar Maurer
03c1e2a061 JSONSchema: define 'renderer' property
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-07-03 13:28:25 +02:00
Thomas Lamprecht
ef3c37dd28 cli: print_text_table: restore autoformat behavior
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-29 14:50:08 +02:00
Dietmar Maurer
41d554d9cd cli: print_text_table: support multiline data
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Dietmar Maurer
3cd6f2f350 cli: data_to_text: never render undefined values
To make it visible when the API return undefined values.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00