5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-01-20 22:03:33 +03:00

1171 Commits

Author SHA1 Message Date
Dominic Jäger
e37d592413 Add tests for verify_configid
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
2020-10-29 15:20:40 +01:00
Thomas Lamprecht
a7886364a7 sendmail: code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-29 15:20:21 +01:00
Thomas Lamprecht
87ff065c98 network: fix conditional variable declaration
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-23 21:09:23 +02:00
Thomas Lamprecht
329dfb6488 network: cleanup "check bond" code
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-23 21:08:38 +02:00
Alexandre Derumier
000a5a6bcb Inotify: allow bond of bond
for example,some users need to do active-backup bond, on top of 2 lacp bond.
2020-10-23 21:02:00 +02:00
Alexandre Derumier
8387420212 ProcFSTools: add read_pressure
read new /proc/pressure/(cpu,disk,io) introduced in kernel 4.20.

This give more granular informations than loadaverage.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2020-10-13 07:32:42 +02:00
Thomas Lamprecht
d421e5b522 bump version to 6.2-3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-18 17:35:58 +02:00
Fabian Grünbichler
99d02523f6 properly encode YAML via YAML::XS
otherwise we get strange errors when formatting data that was originally
JSON, and can thus contain JSON::true/JSON::false.

one example is the QMP query-blockstats command, which gets called (and
the resulting values returned) by /nodes/NODE/qemu/VMID/status/current

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-18 13:40:55 +02:00
Thomas Lamprecht
09d47f9d47 tools: sync_mountpoint: throw actual error is syncfs fails
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-18 11:59:32 +02:00
Stoiko Ivanov
b260d4e320 sync_mountpoint: open path so that sync works
sync_mountpoint takes a path, gets an open filedescriptor and calls
syncfs(2) on it.
by opening with O_PATH the syncfs call fails with EBADF (see open(2)).

found by running:
```
pkill -f 'pvedaemon worker';
strace -yyttT -s 512 -o /tmp/trace -fp $(pgrep -f pvedaemon$)
```

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-09-18 11:53:50 +02:00
Fabian Grünbichler
00bcefa3f0 d/control: add missing libtimedate-perl to depends
Fixes: b18826ce61e6e2438acc08f05aaa5395bdcd4974

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-17 13:00:35 +02:00
Fabian Grünbichler
e0f86f250c wrap-and-sort d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-17 12:54:52 +02:00
Thomas Lamprecht
bed5b64ca4 d/copyright: update
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-08 18:30:28 +02:00
Thomas Lamprecht
2fc238c263 bump version to 6.2-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-07 10:01:09 +02:00
Thomas Lamprecht
3fe29ce6c9 get_options: allow no arguments if all are optional
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-07 09:59:07 +02:00
Stoiko Ivanov
a24d91ea08 sendmail helper: allow empty display name in from
This patch enables the sendmail helper sub to send emails with a non-existant
display name in the from address. This is used to replace the direct call to
the sendmail binary in pve-manager/PVE/API2/APT.pm.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-09-07 09:40:25 +02:00
Stoiko Ivanov
b18826ce61 sendmail-helper: only send multipart if necessary
PVE::Tools::sendmail currently always sends a multipart/alternative message
irrespective of the actual content of the mail (e.g. a plain-text only mail
need not be sent as multipart message).

Additionally a few small refactorings based on the discussion
in https://lists.proxmox.com/pipermail/pbs-devel/2020-August/000423.html
and commited in 66004f22c6475ceb0146cf2df1f380f9f0274be4 in the
rust proxmox repository git://git.proxmox.com/git/proxmox.git
were carried over.

tested by creating a backup of a VM and setting an e-mail address, having
ha-manager send a mail after fencing as well as sending a few small mails via
'perl -e'

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-09-07 09:40:25 +02:00
Thomas Lamprecht
804bc6219b get_options: allow optional arguments "arg_params" if no ambiguity
If we run out of passed arguments from the user but still had defined
"arg_params" (those params which went after the command in fixed
order without option -- dashes) we always errored out with "not
enough arguments". But, there are situations where the remaining
arg_params are all marked as optional in the schema, so we do not
need to error out in that case.

A prime (future) use case is "pvesm prune-backups". Currently the
usage is:
> pvesm prune-backups storeid --prune-backups keep-last=1,keep-...

Because the "prune-backups" keep retention property is optional as it
can fallback to the one defined in the storage configuration.
With this patch we can make it an argument and allow the following
two usages:

1. As above, but avoiding the extra ugly --prune-backups
> pvesm prune-backups storeid keep-last=1,keep-...

2. Fallback to storage config:
> pvesm prune-backups storeid

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-08-26 21:21:05 +02:00
Thomas Lamprecht
1e49f2e7be bump version to 6.2-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-08-19 12:29:13 +02:00
Thomas Lamprecht
ba104d6760 run command: fix matching \r\n and use non-capturing group for it
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-08-19 08:54:08 +02:00
Dominik Csapak
cb9db10c1a run_command: improve performance for logging and long lines
to call out/err/logfunc with each line, we search for a newline and call
outfunc/logfunc with everything before that

since we do a select/read (with 4096 size) in a loop, this means
that if we have very long lines, we search for a newline in an
ever growing buffer (for which we know does not contain a newline)

so instead, only search the new data for newlines

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-08-19 07:39:39 +02:00
Fabian Grünbichler
8fb28ab914 safe_read_from: bump default size limit to 512k
this is (via file_get_contents and file_copy) used for reading from
pmxcfs, which has a file size limit of 512k. since quite a number of
call sites would need to explicitly override this (and then get updated
if we bump the limit on the pmxcfs side again in the future), making our
default file reader compatible by default seems the better solution.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-08-19 07:38:44 +02:00
Thomas Lamprecht
9025031b10 bump version to 6.1-5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-07 19:27:26 +02:00
Oguz Bektas
216a3f4f13 sendmail: separate 'mailto' list from the rest of the parameters
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2020-07-07 17:07:16 +02:00
Stefan Reiter
d500c0381e JSONSchema: use validator in print_property_string too
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-07-06 10:40:10 +02:00
Stefan Reiter
70fdc0501b JSONSchema: add format validator support and cleanup check_format
Adds a third, optional parameter to register_format that allows specifying
a function that will be called after parsing and can validate the parsed
data. A validator should die on failed validation, and can also change the
parsed object by returning a modified version of it.

This is useful so one can register a format with its hash, thus allowing
documentation to be generated automatically, while still enforcing certain
validation rules.

The validator only needs to be called in parse_property_string, since
check_format always calls parse_property_string if there is a
possibility of a validator existing at all. parse_property_string should
then be called with named formats for best effect, as only then can
validators be used.

Clean up 'check_format' as well (which pretty much amounts to a rewrite).
No existing functionality is intentionally changed.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-07-06 10:40:10 +02:00
Thomas Lamprecht
37c7daf0d4 bump version to 6.1-4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-03 14:17:04 +02:00
Thomas Lamprecht
36b9c07397 follouwp: improve comment detection and refactor slightly
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-06-26 09:55:21 +02:00
Oguz Bektas
e76308e6eb schema: register 'timezone' format and add verification method
/usr/share/zoneinfo/zone.tab has the valid list of time zones.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-06-26 09:50:26 +02:00
Stoiko Ivanov
0bbe789c6a fix #2796: debian/postinst: check for existing /etc/aliases
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-06-15 15:38:34 +02:00
Mira Limbeck
8342b610ea fix #2374: bridge-ports is assumed to be defined
bridge-ports is an optional parameter but was assumed to be defined in
the code. This resulted in 'use of uninitialized value' warnings.

By reordering of the $ports definition before the replace, we get rid of
the 'use of uninitialized value' when no bridge-port is specified.

In the second case we set it to an empty string when it is undefined.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-06-15 14:26:46 +02:00
Thomas Lamprecht
7157e9bd98 bump version to 6.1-3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-06-08 17:37:13 +02:00
Alexandre Derumier
fe2a773cd0 Inotify: write_network_interfaces : always autostart bond slaves interfaces
Currently, bond slaves are mostly working without autostart,
because bond slaves scripts from ifupdown1 && also ifupdown2
 have some kind of hacks to start the slaves.

But if users want to do some tuning on the ifaces, they are not applied.

Also, with ifupdown2 + ovs, this kind of hack is not implemented (yet), so the
slaves of the bond are still down.

Debian/Ubuntu official docs always set "auto ethX" for bond slaves,
it's really more clean like this.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2020-06-08 17:34:57 +02:00
Mike Beattie
ddcdc5eed7 Add cpu core count to /nodes/{id}/status API result
This is useful for when collecting data for Guest OS licensing (Microsoft)
where physical core count matters, not socket or thread count.

The "cpus" value counts threads when Hyperthreading is enabled.

Signed-off-by: Mike Beattie <mike@ethernal.org>
2020-06-06 19:47:20 +02:00
Alexandre Derumier
aa91ae3d1b network: vlan-aware bridge: fix pvid when trunks is defined
Currently, when a trunks is defined, the vlan tag is not used
for pvid with vlan-aware bridge. (It's ok with ovs switch)

example:

net0: e1000=BA:90:68:B8:CF:F5,bridge=vmbr1,tag=2,trunks=2-11

before
------
tap100i0	 2-11

after
-----
tap100i0	 2 PVID Egress Untagged
	 3-11

No regression for other configurations:

net0: e1000=BA:90:68:B8:CF:F5,bridge=vmbr1

before
------
tap100i0	 1 PVID Egress Untagged
	 2-4094

after
-----
tap100i0	 1 PVID Egress Untagged
	 2-4094

net0: e1000=BA:90:68:B8:CF:F5,bridge=vmbr1,tag=2

before
------
tap100i0	 2 PVID Egress Untagged

after
-----
tap100i0	 2 PVID Egress Untagged

net0: e1000=BA:90:68:B8:CF:F5,bridge=vmbr1,trunks=2-11

before
------
tap100i0	 1 PVID Egress Untagged
	 2-11

after
-----
tap100i0	 1 PVID Egress Untagged
	 2-11

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2020-06-03 14:38:17 +02:00
Alexandre Derumier
1b6ad61c61 read_bridge_mtu: public method instead private 2020-05-11 17:14:24 +02:00
Thomas Lamprecht
fdda9da4ab bump version to 6.1-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-09 21:01:10 +02:00
Thomas Lamprecht
0777906df2 network: bridge add IF: do not add all VLANs if $trunks are passed
fixes commit 89ea13ef6b1555f92309da5c298e16579163eaf4 and
restores old behavior, the "if !$trunks" post-if was a bit suble, it
did not guard the die, but the system command previously - the die
was || (ORd) to the command, bad code style to begin with..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-09 20:55:25 +02:00
Thomas Lamprecht
2c3ecf299f bump version to 6.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-06 12:14:42 +02:00
Fabian Grünbichler
16cecc0dcc network: fix adding vlan tags to bridge
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-05-06 12:03:31 +02:00
Stoiko Ivanov
9c1ccaf922 ProcFSTools: fix read_meminfo without KSM
on kernel configs where KSM is not enabled (e.g. an openstack instance at
OVH) the file /sys/kernel/mm/ksm/pages_sharing does not exist.
In that case there is no memory shared so assuming 0 is reasonable.

While this is not the case with our shipped kernel, and thus will probably
not happen on a PVE installation, PMG can run quite happily with a different
kernel (the reporter had this on an openstack instance at OVH).

a quick grep through our codebase showed only the API2::Nodes::Nodeinfo::status
call as user of the memshared property.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-05-05 18:25:57 +02:00
Fabian Ebner
890d25d963 print_text_table: handle undefined values in comparision
by introducing a safe_compare helper. Fixes warnings, e.g.
pvesh get /nodes/<NODE>/network
would print "use of uninitialized"-warnings if there are inactive
network interfaces, because for those, 'active' is undef.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Tested-by: Oguz Bektas <o.bektas@proxmox.com>
2020-05-04 18:20:39 +02:00
Stefan Reiter
87e31b2358 fix #2696: avoid 'undefined value' warning in 'pvesh help unknown'
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-05-04 18:05:50 +02:00
Fabian Grünbichler
938dedc285 bump version to 6.0-20
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-05-02 18:42:42 +02:00
Thomas Lamprecht
79ac628b9e JSONSchema: allow to import parse_property_string
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-02 18:42:42 +02:00
Fabian Grünbichler
d0c43c2121 build: remove ACME modules
from Makefile as well

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-30 12:17:06 +02:00
Wolfgang Link
12b0d5a959 Move the code to proxmox-acme and add a dependency on it.
Signed-off-by: Wolfgang Link <w.link@proxmox.com>
2020-04-30 12:17:06 +02:00
Thomas Lamprecht
7db4e5d763 section config: use croak so that the error is from the callers POV
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-29 14:51:59 +02:00
Dominik Csapak
6b0c18d4db JSONSchema: extend pve-configid regex by '-'
we use this format for all 'delete' options but we have some options
that have a '-' in the name (e.g. 'sync-defaults-options') that cannot
be deleted if it is not included

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-23 07:50:24 +02:00
Fabian Grünbichler
89ea13ef6b network: replace system() with run_command()
easier to read and extend, and safer as well.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-08 15:03:11 +02:00