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

901 Commits

Author SHA1 Message Date
Dietmar Maurer
2edb0abbb9 PVE::CLIHandler::print_api_list - improve format check
We can only print lists of objects.
2018-06-22 07:32:33 +02:00
Dietmar Maurer
8587474c36 PVE::CLIHandler::print_api_list - reorder arguments
Move optional argument to the end.
2018-06-22 07:14:04 +02:00
Dietmar Maurer
eb04f1e26c PVE::CLIHandler::print_api_list - allow to pass empty $props_to_print 2018-06-22 07:12:42 +02:00
Dietmar Maurer
340c98629c 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.
2018-06-22 07:05:23 +02:00
Thomas Lamprecht
ba49de85b9 cli: print table: remove only-once-used default variable 2018-06-20 14:12:18 +02:00
Stoiko Ivanov
eb3dae233f 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>
2018-06-20 14:01:31 +02:00
Wolfgang Bumiller
f6c4a56381 INotify: write network: don't duplicate bridge-vids
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-06-20 10:27:08 +02:00
Alexandre Derumier
b7c4f37851 Inotify : write network config : remove allow- ovs with ifupdown2 2018-06-20 10:11:48 +02:00
Alexandre Derumier
95d0e63377 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
2018-06-20 10:11:48 +02:00
Alexandre Derumier
1accc6da65 Inotify : write network config : use modern syntax for options
-replace options with '_'  with '-'
-use 'bond-slaves' instead 'slaves'
2018-06-20 10:11:48 +02:00
Alexandre Derumier
1b1fb9f70c Inotify : read network config : allow alternative options names 2018-06-20 10:11:48 +02:00
Thomas Lamprecht
37f010e7c6 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>
2018-06-19 12:33:26 +02:00
Dominik Csapak
0da61ab3c3 CLIHandler: add standard mapping for password parameter
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-06-19 11:56:00 +02:00
Dominik Csapak
57d5edee2f CLIHandler: add standard_mappings
so we can reuse often used parameter mappings

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-06-19 11:56:00 +02:00
Dominik Csapak
a1c7eddaf1 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>
2018-06-19 11:56:00 +02:00
Thomas Lamprecht
305fc1e12a print_api_list: we only handle API results of type 'array'
...for now at least

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-18 12:35:04 +02:00
Thomas Lamprecht
85b9def289 improve and fix some whitespace errors
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-18 12:34:58 +02:00
Thomas Lamprecht
acd6f38373 reword print_text_table and print_api_list documentation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-18 12:34:55 +02:00
Stoiko Ivanov
a604bf2214 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>
2018-06-18 11:24:03 +02:00
Stoiko Ivanov
8042c2cc62 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>
2018-06-18 11:24:03 +02:00
Stoiko Ivanov
f8d4eff923 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>
2018-06-18 11:24:03 +02:00
Thomas Lamprecht
a73f417f10 buildsys: depend on check target instead of manual calling it
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-18 08:57:25 +02:00
Thomas Lamprecht
82ad3144ff 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>
2018-06-18 08:57:25 +02:00
Thomas Lamprecht
dbaa6e520a buildsys: introduce BUILDDIR variable
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-18 08:57:25 +02:00
Thomas Lamprecht
f943f4d13e 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>
2018-06-18 08:57:25 +02:00
Thomas Lamprecht
008c3bb2d4 bump version to 5.0-34 2018-06-15 12:06:42 +02:00
Thomas Lamprecht
8461a4875a d/control: record that we now break qemu-server << 5.0-29
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-15 12:06:42 +02:00
Thomas Lamprecht
eae436871c 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>
2018-06-15 12:06:42 +02:00
Wolfgang Bumiller
f024a872c4 add PVE::SystemD module
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-06-15 11:33:17 +02:00
Wolfgang Bumiller
5a94ed9d9e Perl::Cricit fixups
- fix variable declared in conditional statement
- add newlines to die/warn statements

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-06-14 11:41:41 +02:00
Thomas Lamprecht
a76b691d13 bump version to 5.0-33 2018-06-14 09:26:12 +02:00
Dietmar Maurer
2c48a66569 fix regex quoting in $print_bash_completion
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-14 09:09:10 +02:00
Wolfgang Bumiller
ea5a508493 cli: use exists() for alias check
should be faster

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-06-14 09:02:47 +02:00
Thomas Lamprecht
131f316b5c 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>
2018-06-14 08:58:54 +02:00
Thomas Lamprecht
0b79680694 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>
2018-06-14 08:58:54 +02:00
Thomas Lamprecht
24ccf353c7 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>
2018-06-13 08:31:25 +02:00
Dietmar Maurer
57c0d0c69c 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>
2018-06-13 08:16:45 +02:00
Dominik Csapak
ac927fbcfd 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>
2018-06-12 14:59:16 +02:00
Dietmar Maurer
6142051558 CLIHandler.pm: fix command line completion for simple commands
You can simply test behavior using 'qmrestore' ...

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-06-12 11:01:39 +02:00
Dietmar Maurer
1e5ecf7bf8 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>
2018-06-12 11:01:31 +02:00
Wolfgang Bumiller
5082a17b81 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>
2018-06-08 06:27:10 +02:00
Wolfgang Bumiller
0ed806982c cleanup: fix variable typo
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-06-08 06:27:06 +02:00
Dietmar Maurer
ff2bf45fab fix getopt when invoking without arguments 2018-06-07 07:09:59 +02:00
Wolfgang Bumiller
893ec6f259 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>
2018-06-04 12:55:57 +02:00
Thomas Lamprecht
d86dc5eeaf bump version to 5.0-32 2018-05-29 08:28:29 +02:00
Wolfgang Bumiller
8733bb8078 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>
2018-05-18 15:01:58 +02:00
Dietmar Maurer
903ea3fff3 api_dump_remove_refs: prepare API tree for use with to_json($tree)
We want to use this with the extractapi.pl helper (pve-docs, pve-api-client).
2018-05-18 10:13:00 +02:00
Thomas Lamprecht
02548f7bb6 bump version to 5.0-31 2018-05-04 12:57:25 +02:00
Fabian Grünbichler
55ffa426f3 build: install ACME files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2018-04-30 13:06:52 +02:00
Fabian Grünbichler
f6a70fbfdf acme: add challenge plugins
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2018-04-30 13:06:52 +02:00