5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-24 01:33:48 +03:00
Commit Graph

852 Commits

Author SHA1 Message Date
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
Dietmar Maurer
4ac8500023 PVE::CLIFormatter::query_terminal_options - new helper
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Dietmar Maurer
43b104c416 cli: print_api_result: add/use new encoding option
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Dietmar Maurer
eb1c51c2e8 CLIFormatter: implement tables with utf8 borders
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Dietmar Maurer
0c22b00ccd CLIFormatter: pass options as hash
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Dietmar Maurer
cde31da01a cli: print_text_table: allow to limit output width
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Dietmar Maurer
84142f1d20 cli: data_to_text: pass property info
So that we can display defaults, render boolean nicely, or call arbitrary render
functions ...

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Dietmar Maurer
b521204225 PVE::JSONSchema::register_renderer - allow to register renderers by name
We want to use those renderer to format CLI output nicely.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Dietmar Maurer
2a174d2ab0 cli: print_api_result: use print_api_list to print objects
In order to draw the new asciiart border ...

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Dietmar Maurer
793ad69ba5 cli: print_text_table: allow to draw ascii art borders
format can now be:

plain => what we had with 'text' before
text => print with borders (default)
json

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-29 14:39:48 +02:00
Thomas Lamprecht
4c99c559f3 trivial: fixup: no double semicolons
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-29 12:40:07 +02:00
Thomas Lamprecht
aea06195b7 foolowup: improve/add comments and spacing
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-29 11:58:05 +02:00
Stoiko Ivanov
e97f807c38 fix #1819: fork_worker: ensure sync'ed workers control terminal
Use setpgid + tcsetpgrp instead of setsid if $sync (invocation via
cli), thus keeping /dev/tty - ssh-copy-id/ssh need it to read the
password, and putting the child in the forground. Further, ignore
SIGTTOU in child process (otherwise it gets stopped upon tcsetpgrp)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-29 11:36:01 +02:00
Dietmar Maurer
f53ad23ac9 PVE/CLIFormatter.pm - new class to generate/format CLI output
Moved code from CLIHandler.pm into this file.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-28 09:44:43 +02:00
Thomas Lamprecht
b2285cf8eb bump version to 5.0-35 2018-06-27 15:34:14 +02:00
Thomas Lamprecht
194ed9bbbd d/control: break pve-manager < 5.2-5 and pmg-api < 5.0-74 2018-06-27 15:34:14 +02:00
Thomas Lamprecht
968bcf45be rest/cli: rename param mapping related variable to shorter versions
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-27 13:02:53 +02:00
Dominik Csapak
4842b65105 remove read_password_func from cli handler
we have a param_mapping now, with which we can impement that

e.g. instead of using:

sub read_password {
    # read password
}

we can do:

sub param_mapping {
    my ($name) = @_;

    my $password_map = ['password', sub{
	# read password
    }, '<password', 1];

    my $mapping = {
	'apicall1' => [$password_map],
	'apicall2' => [$password_map],
	...
    };

    return $mapping->{$name};
}

this has the advantage that we can use different subs for different
api calls (e.g. pveum passwd vs pveum ticket)

if a CLIHandler implemenation still has a read_password sub and no
param_mapping, we generate one for them with read_password as the
sub for the standard mapping 'pve-password'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-06-27 12:37:20 +02:00
Dietmar Maurer
3c3d1e07c8 cli: print_text_table: another fix for poperties without schema
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-27 12:35:55 +02:00
Thomas Lamprecht
ead1edfffd cli: print_text_table: die if no property info not needed anymore
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-27 11:49:52 +02:00
Dietmar Maurer
ffe4449cd5 cli: print_text_table: fix for poperties without schema
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-27 11:46:29 +02:00
Thomas Lamprecht
8379465981 cli: print_text_table: followup code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-27 11:28:40 +02:00
Thomas Lamprecht
9ac6416ec8 cli: print_text_table: default to autosort on
we more often want to sort by the leftmost valid column than not.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-27 11:23:31 +02:00
Thomas Lamprecht
fa7d20bf9f cli: print_api_result: simplify props_to_print code
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-27 11:00:55 +02:00
Dietmar Maurer
8dd3280b55 PVE::CLIHandler::print_text_table - cleanup, directly use json schema data
This way we can access all type information and can use that to sort
numeric columns correctly.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-27 11:00:29 +02:00
Dietmar Maurer
505786f6a4 PVE::CLIHandler::print_text_table - add option $sort_key
Now, we do not change the ordering by default.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-27 11:00:23 +02:00
Stoiko Ivanov
16f2033235 PVE::CLIHandler::data_to_text: return '' for undef
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2018-06-27 11:00:19 +02:00
Dietmar Maurer
c1e843677d PVE::CLIHandler::print_api_result - add $props_to_print parameter
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-27 11:00:12 +02:00
Stoiko Ivanov
db5b22d16a PVE::CLIHandler::print_api_list: update comment
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2018-06-25 12:09:59 +02:00
Stoiko Ivanov
9b8f2f8f6e PVE::CLIHandler::print_api_list - use all occuring properties
print_api_list falls back to the union of all properties occuring in data, if
none are provided explicitly, and the API method contains no returns property.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2018-06-25 12:09:42 +02:00
Stoiko Ivanov
e05f7cdd0c PVE::CLIHandler::print_text_table - fix sorting
Sort only if at least one column contains no undefined values.
Sort according to the left-most such column.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2018-06-25 12:09:14 +02:00