]> git.proxmox.com Git - pve-common.git/log
pve-common.git
5 years agotests: test newly added interfaces individually
Wolfgang Bumiller [Tue, 10 Jul 2018 10:27:29 +0000 (12:27 +0200)]
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>
5 years agofixup: don't use exists boolean
Wolfgang Bumiller [Tue, 10 Jul 2018 10:00:14 +0000 (12:00 +0200)]
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>
5 years agofixup: compare MTUs numerically
Wolfgang Bumiller [Tue, 10 Jul 2018 09:55:39 +0000 (11:55 +0200)]
fixup: compare MTUs numerically

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agowhitespace fixup
Wolfgang Bumiller [Tue, 10 Jul 2018 09:55:21 +0000 (11:55 +0200)]
whitespace fixup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agocleanup: whitespace and error message consistency
Wolfgang Bumiller [Tue, 10 Jul 2018 09:53:01 +0000 (11:53 +0200)]
cleanup: whitespace and error message consistency

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoInotify : add mtu option
Alexandre Derumier [Thu, 5 Jul 2018 00:56:34 +0000 (02:56 +0200)]
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)

5 years agoInotify : add check vlan
Alexandre Derumier [Thu, 5 Jul 2018 00:56:33 +0000 (02:56 +0200)]
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

5 years agoInotify : add check_bond
Alexandre Derumier [Thu, 5 Jul 2018 00:56:32 +0000 (02:56 +0200)]
Inotify : add check_bond

verify than bond slaves exist && type is eth

5 years agoInotify : add bridge ports options
Alexandre Derumier [Thu, 5 Jul 2018 00:56:31 +0000 (02:56 +0200)]
Inotify : add bridge ports options

5 years agoInotify : add vxlan interface support
Alexandre Derumier [Thu, 5 Jul 2018 00:56:30 +0000 (02:56 +0200)]
Inotify : add vxlan interface support

5 years agoPVE::RESTHandler::generate_usage_str - new static method to generate usage from ...
Dietmar Maurer [Fri, 6 Jul 2018 07:30:07 +0000 (09:30 +0200)]
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>
5 years agoPVE::CLIFormatter::print_api_result - use print_api_list to print arrays
Dietmar Maurer [Thu, 5 Jul 2018 07:26:27 +0000 (09:26 +0200)]
PVE::CLIFormatter::print_api_result - use print_api_list to print arrays

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoCLIFormatter - implement renderer for timestamps using GMT
Dietmar Maurer [Thu, 5 Jul 2018 06:48:03 +0000 (08:48 +0200)]
CLIFormatter - implement renderer for timestamps using GMT

5 years agoPVE::CLIFormatter::data_to_text - add parameter $options
Dietmar Maurer [Wed, 4 Jul 2018 13:24:52 +0000 (15:24 +0200)]
PVE::CLIFormatter::data_to_text - add parameter $options

Also pass $options to renderer functions.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoCLIFormatter - implement renderer for timestamps
Dietmar Maurer [Wed, 4 Jul 2018 11:28:27 +0000 (13:28 +0200)]
CLIFormatter - implement renderer for timestamps

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoPVE::CLIHandler - allow to set LOG ID with $ENV{PVE_LOG_ID}
Dietmar Maurer [Wed, 4 Jul 2018 08:52:26 +0000 (10:52 +0200)]
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>
5 years agoJSONSchema: register new standard option 'pve-output-format'
Dietmar Maurer [Mon, 2 Jul 2018 11:34:16 +0000 (13:34 +0200)]
JSONSchema: register new standard option 'pve-output-format'

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoPVE::CLIFormatter::extract_properties_to_print - new helper
Dietmar Maurer [Mon, 2 Jul 2018 11:34:15 +0000 (13:34 +0200)]
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>
5 years agoCLIFormatter: define some commonly useful rendering functions
Dietmar Maurer [Tue, 3 Jul 2018 11:11:01 +0000 (13:11 +0200)]
CLIFormatter: define some commonly useful rendering functions

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoJSONSchema: define 'renderer' property
Dietmar Maurer [Mon, 2 Jul 2018 11:34:13 +0000 (13:34 +0200)]
JSONSchema: define 'renderer' property

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agocli: print_text_table: restore autoformat behavior
Thomas Lamprecht [Fri, 29 Jun 2018 12:50:08 +0000 (14:50 +0200)]
cli: print_text_table: restore autoformat behavior

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agocli: print_text_table: support multiline data
Dietmar Maurer [Fri, 29 Jun 2018 11:15:26 +0000 (13:15 +0200)]
cli: print_text_table: support multiline data

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agocli: data_to_text: never render undefined values
Dietmar Maurer [Fri, 29 Jun 2018 11:15:25 +0000 (13:15 +0200)]
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>
5 years agoPVE::CLIFormatter::query_terminal_options - new helper
Dietmar Maurer [Fri, 29 Jun 2018 11:15:24 +0000 (13:15 +0200)]
PVE::CLIFormatter::query_terminal_options - new helper

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agocli: print_api_result: add/use new encoding option
Dietmar Maurer [Fri, 29 Jun 2018 11:15:23 +0000 (13:15 +0200)]
cli: print_api_result: add/use new encoding option

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoCLIFormatter: implement tables with utf8 borders
Dietmar Maurer [Fri, 29 Jun 2018 11:15:22 +0000 (13:15 +0200)]
CLIFormatter: implement tables with utf8 borders

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoCLIFormatter: pass options as hash
Dietmar Maurer [Fri, 29 Jun 2018 11:15:21 +0000 (13:15 +0200)]
CLIFormatter: pass options as hash

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agocli: print_text_table: allow to limit output width
Dietmar Maurer [Fri, 29 Jun 2018 11:15:20 +0000 (13:15 +0200)]
cli: print_text_table: allow to limit output width

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agocli: data_to_text: pass property info
Dietmar Maurer [Fri, 29 Jun 2018 11:15:19 +0000 (13:15 +0200)]
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>
5 years agoPVE::JSONSchema::register_renderer - allow to register renderers by name
Dietmar Maurer [Fri, 29 Jun 2018 11:15:18 +0000 (13:15 +0200)]
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>
5 years agocli: print_api_result: use print_api_list to print objects
Dietmar Maurer [Fri, 29 Jun 2018 11:15:17 +0000 (13:15 +0200)]
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>
5 years agocli: print_text_table: allow to draw ascii art borders
Dietmar Maurer [Fri, 29 Jun 2018 11:15:16 +0000 (13:15 +0200)]
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>
5 years agotrivial: fixup: no double semicolons
Thomas Lamprecht [Fri, 29 Jun 2018 10:40:07 +0000 (12:40 +0200)]
trivial: fixup: no double semicolons

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agofoolowup: improve/add comments and spacing
Thomas Lamprecht [Fri, 29 Jun 2018 09:57:49 +0000 (11:57 +0200)]
foolowup: improve/add comments and spacing

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agofix #1819: fork_worker: ensure sync'ed workers control terminal
Stoiko Ivanov [Fri, 29 Jun 2018 09:21:18 +0000 (11:21 +0200)]
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>
5 years agoPVE/CLIFormatter.pm - new class to generate/format CLI output
Dietmar Maurer [Thu, 28 Jun 2018 07:39:42 +0000 (09:39 +0200)]
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>
5 years agobump version to 5.0-35
Thomas Lamprecht [Wed, 27 Jun 2018 10:35:38 +0000 (12:35 +0200)]
bump version to 5.0-35

5 years agod/control: break pve-manager < 5.2-5 and pmg-api < 5.0-74
Thomas Lamprecht [Wed, 27 Jun 2018 13:33:41 +0000 (15:33 +0200)]
d/control: break pve-manager < 5.2-5 and pmg-api < 5.0-74

5 years agorest/cli: rename param mapping related variable to shorter versions
Thomas Lamprecht [Wed, 27 Jun 2018 11:02:36 +0000 (13:02 +0200)]
rest/cli: rename param mapping related variable to shorter versions

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoremove read_password_func from cli handler
Dominik Csapak [Thu, 21 Jun 2018 12:36:52 +0000 (14:36 +0200)]
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>
5 years agocli: print_text_table: another fix for poperties without schema
Dietmar Maurer [Wed, 27 Jun 2018 10:01:40 +0000 (12:01 +0200)]
cli: print_text_table: another fix for poperties without schema

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agocli: print_text_table: die if no property info not needed anymore
Thomas Lamprecht [Wed, 27 Jun 2018 09:49:52 +0000 (11:49 +0200)]
cli: print_text_table: die if no property info not needed anymore

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agocli: print_text_table: fix for poperties without schema
Dietmar Maurer [Wed, 27 Jun 2018 09:44:49 +0000 (11:44 +0200)]
cli: print_text_table: fix for poperties without schema

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agocli: print_text_table: followup code cleanup
Thomas Lamprecht [Wed, 27 Jun 2018 09:28:36 +0000 (11:28 +0200)]
cli: print_text_table: followup code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agocli: print_text_table: default to autosort on
Thomas Lamprecht [Wed, 27 Jun 2018 09:23:25 +0000 (11:23 +0200)]
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>
5 years agocli: print_api_result: simplify props_to_print code
Thomas Lamprecht [Tue, 26 Jun 2018 13:55:26 +0000 (15:55 +0200)]
cli: print_api_result: simplify props_to_print code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoPVE::CLIHandler::print_text_table - cleanup, directly use json schema data
Dietmar Maurer [Wed, 27 Jun 2018 08:50:11 +0000 (10:50 +0200)]
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>
5 years agoPVE::CLIHandler::print_text_table - add option $sort_key
Dietmar Maurer [Wed, 27 Jun 2018 08:50:10 +0000 (10:50 +0200)]
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>
5 years agoPVE::CLIHandler::data_to_text: return '' for undef
Stoiko Ivanov [Tue, 26 Jun 2018 09:33:46 +0000 (11:33 +0200)]
PVE::CLIHandler::data_to_text: return '' for undef

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agoPVE::CLIHandler::print_api_result - add $props_to_print parameter
Dietmar Maurer [Mon, 25 Jun 2018 12:42:18 +0000 (14:42 +0200)]
PVE::CLIHandler::print_api_result - add $props_to_print parameter

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoPVE::CLIHandler::print_api_list: update comment
Stoiko Ivanov [Fri, 22 Jun 2018 18:21:08 +0000 (20:21 +0200)]
PVE::CLIHandler::print_api_list: update comment

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agoPVE::CLIHandler::print_api_list - use all occuring properties
Stoiko Ivanov [Fri, 22 Jun 2018 18:21:07 +0000 (20:21 +0200)]
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>
5 years agoPVE::CLIHandler::print_text_table - fix sorting
Stoiko Ivanov [Fri, 22 Jun 2018 18:21:06 +0000 (20:21 +0200)]
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>
5 years agocleanup: rename $returninfo to $result_schema
Dietmar Maurer [Fri, 22 Jun 2018 05:37:09 +0000 (07:37 +0200)]
cleanup: rename $returninfo to $result_schema

5 years agoPVE::CLIHandler::print_api_list - improve format check
Dietmar Maurer [Fri, 22 Jun 2018 05:18:41 +0000 (07:18 +0200)]
PVE::CLIHandler::print_api_list - improve format check

We can only print lists of objects.

5 years agoPVE::CLIHandler::print_api_list - reorder arguments
Dietmar Maurer [Fri, 22 Jun 2018 05:14:04 +0000 (07:14 +0200)]
PVE::CLIHandler::print_api_list - reorder arguments

Move optional argument to the end.

5 years agoPVE::CLIHandler::print_api_list - allow to pass empty $props_to_print
Dietmar Maurer [Fri, 22 Jun 2018 05:12:42 +0000 (07:12 +0200)]
PVE::CLIHandler::print_api_list - allow to pass empty $props_to_print

5 years agoPVE::CLIHandler - new helper print_api_result
Dietmar Maurer [Fri, 22 Jun 2018 05:05:23 +0000 (07:05 +0200)]
PVE::CLIHandler - new helper print_api_result

Allow to print complex object/array by simply converting them to JSON.

Note: Our API almost always return simply values.

5 years agocli: print table: remove only-once-used default variable
Thomas Lamprecht [Wed, 20 Jun 2018 12:12:18 +0000 (14:12 +0200)]
cli: print table: remove only-once-used default variable

5 years agocli: print_text_table: ensure default is not undefined
Stoiko Ivanov [Wed, 20 Jun 2018 11:28:36 +0000 (13:28 +0200)]
cli: print_text_table: ensure default is not undefined

Default to printing '', if no default is provided for a column.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agoINotify: write network: don't duplicate bridge-vids
Wolfgang Bumiller [Wed, 20 Jun 2018 08:27:08 +0000 (10:27 +0200)]
INotify: write network: don't duplicate bridge-vids

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoInotify : write network config : remove allow- ovs with ifupdown2
Alexandre Derumier [Wed, 20 Jun 2018 05:36:57 +0000 (07:36 +0200)]
Inotify : write network config : remove allow- ovs with ifupdown2

5 years agoInotify : write network config : add bridge-vids
Alexandre Derumier [Wed, 20 Jun 2018 05:36:56 +0000 (07:36 +0200)]
Inotify : write network config : add bridge-vids

default is 2-4094 if user don't have specified.

mandatory for ifupdown2 and compatible with
current promox ifupdown bridgevlanport script

5 years agoInotify : write network config : use modern syntax for options
Alexandre Derumier [Wed, 20 Jun 2018 05:36:55 +0000 (07:36 +0200)]
Inotify : write network config : use modern syntax for options

-replace options with '_'  with '-'
-use 'bond-slaves' instead 'slaves'

5 years agoInotify : read network config : allow alternative options names
Alexandre Derumier [Wed, 20 Jun 2018 05:36:54 +0000 (07:36 +0200)]
Inotify : read network config : allow alternative options names

5 years agofixup: don't standard mapping code in mid of cmd helpers
Thomas Lamprecht [Tue, 19 Jun 2018 10:18:29 +0000 (12:18 +0200)]
fixup: don't standard mapping code in mid of cmd helpers

as it teared code which belongs together apart

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoCLIHandler: add standard mapping for password parameter
Dominik Csapak [Fri, 15 Jun 2018 13:28:44 +0000 (15:28 +0200)]
CLIHandler: add standard mapping for password parameter

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
5 years agoCLIHandler: add standard_mappings
Dominik Csapak [Fri, 15 Jun 2018 13:28:43 +0000 (15:28 +0200)]
CLIHandler: add standard_mappings

so we can reuse often used parameter mappings

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
5 years agoadd the possibility to use a hash for parameter mapping
Dominik Csapak [Fri, 15 Jun 2018 13:28:42 +0000 (15:28 +0200)]
add the possibility to use a hash for parameter mapping

instead of writing:
['name', sub {...}, 'description', 1]

one can now use:
{
    name => 'name',
    func => sub { ... },
    desc => 'desc',
    interactive => 1,
}

which makes it more obvious what is what
(and allows later patches to easily override some things)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
5 years agoprint_api_list: we only handle API results of type 'array'
Thomas Lamprecht [Mon, 18 Jun 2018 10:31:50 +0000 (12:31 +0200)]
print_api_list: we only handle API results of type 'array'

...for now at least

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoimprove and fix some whitespace errors
Thomas Lamprecht [Mon, 18 Jun 2018 10:19:08 +0000 (12:19 +0200)]
improve and fix some whitespace errors

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoreword print_text_table and print_api_list documentation
Thomas Lamprecht [Mon, 18 Jun 2018 09:55:40 +0000 (11:55 +0200)]
reword print_text_table and print_api_list documentation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoadd print_api_list, adapt handle_cmd
Stoiko Ivanov [Mon, 18 Jun 2018 08:18:02 +0000 (10:18 +0200)]
add print_api_list, adapt handle_cmd

print_api_list takes an array of columns to print, the data, and the returns
definitions of the API, and prints the data by using print_text_table.

handle_cmd and handle_simple_cmd call the output sub with the returns definitons.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agoadd print_text_table, print_entry to CLIHandler
Stoiko Ivanov [Mon, 18 Jun 2018 08:18:01 +0000 (10:18 +0200)]
add print_text_table, print_entry to CLIHandler

These two function could serve as a generic output sub for various CLI
utilities
 * print_text_table prints an array of objects in a tabular fashion,
   the formating is passed as an array containg hashes with titles, maximal
   lengths and default values. This way we can stay extensible, by adding other
   keys to the formatting options
 * print_entry prints out a single entry, handling array-refs as properties

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agoadd print_width property to JSONSchema definition
Stoiko Ivanov [Mon, 18 Jun 2018 08:18:00 +0000 (10:18 +0200)]
add print_width property to JSONSchema definition

used to define the maximal width of the respective column in the CLI

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agobuildsys: depend on check target instead of manual calling it
Thomas Lamprecht [Mon, 18 Jun 2018 06:37:33 +0000 (08:37 +0200)]
buildsys: depend on check target instead of manual calling it

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agobuildsys: refactor distclean and clean target
Thomas Lamprecht [Mon, 18 Jun 2018 06:34:59 +0000 (08:34 +0200)]
buildsys: refactor distclean and clean target

remove the cleanup of the not produced ${PACKAGE}-*.tar.gz file.
This is here since the import from SVN, but is not needed since quite
a time.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agobuildsys: introduce BUILDDIR variable
Thomas Lamprecht [Mon, 18 Jun 2018 06:32:24 +0000 (08:32 +0200)]
buildsys: introduce BUILDDIR variable

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agobuildsys: remove useless variable definitions
Thomas Lamprecht [Mon, 18 Jun 2018 06:10:33 +0000 (08:10 +0200)]
buildsys: remove useless variable definitions

the used ones are in src/Makefile, so remove those left over, else
one could get confused why there on two places and why changes here
had no effect.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agobump version to 5.0-34
Thomas Lamprecht [Fri, 15 Jun 2018 10:06:16 +0000 (12:06 +0200)]
bump version to 5.0-34

5 years agod/control: record that we now break qemu-server << 5.0-29
Thomas Lamprecht [Fri, 15 Jun 2018 10:02:08 +0000 (12:02 +0200)]
d/control: record that we now break qemu-server << 5.0-29

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agorename splitted out systemd module to 'Systemd'
Thomas Lamprecht [Fri, 15 Jun 2018 09:57:42 +0000 (11:57 +0200)]
rename splitted out systemd module to 'Systemd'

see:
https://www.freedesktop.org/wiki/Software/systemd/#spelling

We keep the initial upercase 'S' as it's standard for perl module
and perl critic complains otherwise.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoadd PVE::SystemD module
Wolfgang Bumiller [Fri, 15 Jun 2018 09:00:52 +0000 (11:00 +0200)]
add PVE::SystemD module

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agoPerl::Cricit fixups
Wolfgang Bumiller [Thu, 14 Jun 2018 08:10:03 +0000 (10:10 +0200)]
Perl::Cricit fixups

- fix variable declared in conditional statement
- add newlines to die/warn statements

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agobump version to 5.0-33
Thomas Lamprecht [Thu, 14 Jun 2018 07:26:12 +0000 (09:26 +0200)]
bump version to 5.0-33

5 years agofix regex quoting in $print_bash_completion
Dietmar Maurer [Thu, 14 Jun 2018 07:04:47 +0000 (09:04 +0200)]
fix regex quoting in $print_bash_completion

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agocli: use exists() for alias check
Wolfgang Bumiller [Thu, 14 Jun 2018 07:02:46 +0000 (09:02 +0200)]
cli: use exists() for alias check

should be faster

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agocli: only show subcommand specific usage if command incomplete
Thomas Lamprecht [Wed, 13 Jun 2018 07:37:51 +0000 (09:37 +0200)]
cli: only show subcommand specific usage if command incomplete

before:
$ pveum acl
ERROR: incomplete command 'pveum acl'
USAGE: pveum <COMMAND> [ARGS] [OPTIONS]
       pveum acl delete <path> --roles <string> [OPTIONS]
       pveum acl modify <path> --roles <string> [OPTIONS]

       pveum group add <groupid> [OPTIONS]
       pveum group delete <groupid>
       pveum group modify <groupid> [OPTIONS]

       pveum role add <roleid> [OPTIONS]
       pveum role delete <roleid>
       pveum role modify <roleid> --privs <string> [OPTIONS]

       pveum user add <userid> [OPTIONS]
       pveum user delete <userid>
       pveum user modify <userid> [OPTIONS]

       pveum passwd <userid>
       pveum ticket <username> [OPTIONS]

       pveum help [<extra-args>] [OPTIONS]

after:
$ pveum acl
ERROR: incomplete command 'pveum acl'
USAGE: pveum <COMMAND> [ARGS] [OPTIONS]
       pveum acl delete <path> --roles <string> [OPTIONS]
       pveum acl modify <path> --roles <string> [OPTIONS]

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agocli: filter out aliases when trying to expand command
Thomas Lamprecht [Wed, 13 Jun 2018 07:37:50 +0000 (09:37 +0200)]
cli: filter out aliases when trying to expand command

we do not complete them in bash copletion either and their just there
for backward compatibillity, so filter them out.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agogenerate_usage_str: show short usage help for unknown commands
Thomas Lamprecht [Wed, 13 Jun 2018 06:30:35 +0000 (08:30 +0200)]
generate_usage_str: show short usage help for unknown commands

followup for previous commit to show the full short usage string for
the CLI tool in the case of an unknown command

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agogenerate_usage_str: do no generate help for unknown commands
Dietmar Maurer [Wed, 13 Jun 2018 06:00:22 +0000 (08:00 +0200)]
generate_usage_str: do no generate help for unknown commands

Before:

...
USAGE: pvesm aaa zfsscan

With this patch applied:

no such command 'aaa'

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoadd a generalized 'read and confirm password' sub
Dominik Csapak [Tue, 12 Jun 2018 10:33:47 +0000 (12:33 +0200)]
add a generalized 'read and confirm password' sub

to use everywhere we read two passwords and compare them

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
5 years agoCLIHandler.pm: fix command line completion for simple commands
Dietmar Maurer [Tue, 12 Jun 2018 08:57:45 +0000 (10:57 +0200)]
CLIHandler.pm: fix command line completion for simple commands

You can simply test behavior using 'qmrestore' ...

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agoapi_dump: add $raw_dump options
Dietmar Maurer [Mon, 11 Jun 2018 09:23:19 +0000 (11:23 +0200)]
api_dump: add $raw_dump options

Allow to return the original tree with all refs. We use this
with our new pveclient which needs the full api definition.
Keeping refs makes it possible to store the tree more efficiently.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
5 years agobash completion: complete fully specified command
Wolfgang Bumiller [Thu, 7 Jun 2018 09:59:02 +0000 (11:59 +0200)]
bash completion: complete fully specified command

This contains 2 functional changes:

First: resolve_cmd no longer keeps a hash of which arguments
were expanded. This information is not required and not used
properly: For one it would conflict if the same word
appeared twice in a longer subcommand, and secondly we lose
the information when recursing into an alias anyway. And
lastly, we do not support tab completing multiple parameters
simultaneously anyway (as in, `pveum u a<tab>` does not
become `pveum user add`).
So now we simply return the expanded version of the last
command or undef if it was unknown in place of the hash we
returned previously.

The second change is how we use the new returned value:
Previously if resolve_cmd() returned a new subcommand in
$def we skipped over finishing the last word. Of course, if
the command was already fully specified (but no space put
after it), we already considered it complete and returned
the new $def.
This condition can be detected as in this case the $prev
command equals the $cur command. (Additionally, the $cur
command is either '' (after the space) or also the $prev
command (before the space), but checking this would only be
required when the same word can actually appear multiple
times in a row in a sub command chain...)
This case now takes precedence over looking through the
nested $def, so that bash will put the space after a full
command which requires another subcommand to be added.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agocleanup: fix variable typo
Wolfgang Bumiller [Thu, 7 Jun 2018 09:59:01 +0000 (11:59 +0200)]
cleanup: fix variable typo

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agofix getopt when invoking without arguments
Dietmar Maurer [Wed, 6 Jun 2018 04:24:32 +0000 (06:24 +0200)]
fix getopt when invoking without arguments

5 years agotools: unbless errors in run_fork_with_timeout
Wolfgang Bumiller [Mon, 4 Jun 2018 08:39:34 +0000 (10:39 +0200)]
tools: unbless errors in run_fork_with_timeout

We cannot properly encode blessed objects as json, so
instead, we should stringify them. This happened for
instance if a VM's systemd scope wasn't cleaned up as we
got an error as a Net::DBus::Error object causing a
"malformed json string" error to appear instead of the
actual message.

Additionally, add a 'must_stringify' helper: The above error
object implements a '""' operator for stringification (as
all error should), but in theory that could die as well, in
which case we just return a generic error string we'll
hopefully never see...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agobump version to 5.0-32
Thomas Lamprecht [Tue, 29 May 2018 06:28:29 +0000 (08:28 +0200)]
bump version to 5.0-32

5 years agofix #1766: compare task starttime numerically
Wolfgang Bumiller [Wed, 16 May 2018 06:54:55 +0000 (08:54 +0200)]
fix #1766: compare task starttime numerically

Not only because <=> is correct, but using 'cmp' also has
the side effect that it adds a string version to the
variable and the API's json output turns into a string as
well, and this only happens once a task has completed
(while it's an integer while it's still running...)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>