5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-01-09 05:17:35 +03:00
Commit Graph

685 Commits

Author SHA1 Message Date
Wolfgang Bumiller
3feb2c7661 tests: remove acquire-lock newline termination
Not needed anymore.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2017-11-10 11:29:54 +01:00
Thomas Lamprecht
91bae4c070 lock_file_full: add missing trailing newline
When we do not instantly get the lock we print a respective message
to stderr. This shows also up in the task logs, and if it's the last
message before a 'Task OK' the UI gets confused an shows the task as
erroneous.

Keep the message as its a good feedback for the user to see why an op
seems to do nothing, so simply add a trailing newline.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-11-10 11:28:21 +01:00
Dietmar Maurer
62a8f27b99 JSONSchema.pm - add a 'download' attribute
To mark methods which downloads file content to the client.
2017-11-08 09:42:58 +01:00
Fabian Grünbichler
b50791668c bump version to 5.0-20 2017-10-17 15:08:57 +02:00
Philip Abernethy
3ef20687db cli: whitespace cleanup 2017-10-17 13:27:21 +02:00
Philip Abernethy
367f04c577 cli: code cleanup
Removes obsolete subroutine and unused Dumper
2017-10-17 13:27:21 +02:00
Wolfgang Bumiller
a2d049afde tools: more general run_fork_with_timeout + run_fork 2017-10-13 13:21:44 +02:00
Fabian Grünbichler
b308c8d429 build: reformat debian/control
using wrap-and-sort -abt
2017-10-04 11:07:01 +02:00
Dietmar Maurer
66c14ef0f6 bump version to 5.0-19 2017-10-03 12:55:17 +02:00
Dietmar Maurer
335a2219ce PVE/Subscription.pm - check if we have a key 2017-10-03 12:55:17 +02:00
Dietmar Maurer
554cce0c4c PVE/Subscription.pm - avoid warn, and return error message instead 2017-10-03 12:55:17 +02:00
Dietmar Maurer
2f1cb7ef3b PVE::Subscription - new class to simplify subscription management 2017-09-29 09:17:01 +02:00
Alexandre Derumier
a9b02ee637 ProcFSTools:read_proc_mounts: increase read size
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2017-09-26 10:47:56 +02:00
Wolfgang Bumiller
e8c13610c4 tools: df: handle a failing df
This function assumed df() will work or hang, but it can
also actually fail and return undef which results in
warnings - let's silence those.
2017-09-12 14:00:45 +02:00
Wolfgang Bumiller
45d51061bc bump version to 5.0-18 2017-09-12 13:43:55 +02:00
Thomas Lamprecht
f2c72fc3ba run_fork_with_timeout: allow returning complex structures
Encode the result or the error in JSON. This way complex objects or
exceptions may be passed to the parent in a generic way.

This allows to remove the second pipe 'pipe_err'.

Allow also to return undef without any warnings to our caller.
This avoids a "use of uninitialized variable ..." warning

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-12 13:37:56 +02:00
Emmanuel Kasper
a4f181a37e Use double hyphens when prefixing command options in the documentation
This makes our man pages follow the GNU long option recommandations
where non-single character options are prefixed with a double hyphen
(https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html)

The benefit for PVE is that our documentation looks more similar to what
a user with previous Linux knowledge is used to.

Our bash autocompletion helper only completes options using double hyphens too.
2017-09-12 12:18:50 +02:00
Thomas Lamprecht
8e677e74e7 Tools: add convert_size for generic byte conversion
We often need to convert between file sizes, for formatting output,
but also code-internal. Some methods expect kilobytes, some gigabytes
and sometimes we need bytes.

While conversion from smaller to bigger units can be simply done with
a left-shift, the opposite conversion may need more attention -
depending on the used context.

If we allocate disks this is quite critical. For example, if we need
to allocate a disk with size 1023 bytes using the
PVE::Storage::vdisk_alloc method (which expects kilobytes) a
right shift by 10 (<=> division by 1024) would result in "0", which
obviously fails.

Thus we round up the converted value if a remainder was lost on the
transformation in this new method. This behaviour is opt-out, to be
on the safe side.

The method can be used in a clear way, as it gives information about
the source and target unit size, unlike "$var *= 1024", which doesn't
gives direct information at all, if not commented or derived
somewhere from its context.

For example:
 > my $size = convert_unit($value, 'gb' => 'kb');
is more clear than:
 > my $size = $value*1024*1024;

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-11 11:12:41 +02:00
Thomas Lamprecht
eead1ccaa5 run_fork_with_timeout: do not overwrite global signal handlers
perls 'local' must be either used in front of each $SIG{...}
assignments or they must be put in a list, else it affects only the
first variable and the rest are *not* in local context.

This may cause weird behaviour where daemons seemingly do not get
terminating signals delivered correctly and thus may not shutdown
gracefully anymore.

As we only send SIGINT to processes if a manual stop action gets
triggered just catch this one here.

As this is a general method which allows to pass an arbitrary code
payload we cannot sanely handle all signals here, so remove trapping
all other besides SIGINT, if those need to be trapped that should be
done by the caller on a case by case basis.

Fixes: #1495

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-07 10:27:29 +02:00
Fabian Grünbichler
cea9c7b430 bump version to 5.0-17 2017-09-06 09:37:01 +02:00
Fabian Grünbichler
57e46a44ba build: drop -rfakeroot 2017-09-06 09:36:49 +02:00
Fabian Grünbichler
2131eb50a4 build: use 'git rev-parse' for GITVERSION 2017-09-06 09:36:41 +02:00
Fabian Grünbichler
77096a6fa4 rename variable
to prevent confusion of rendered type text vs. original type
property

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2017-09-01 13:45:41 +02:00
Fabian Grünbichler
fbb0ec640a api: fix rendering of filepath/string parameters
25d9bda941 broke this check,
but it is a better idea to check against the actual type
rather then the rendered type text anyway.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2017-09-01 13:45:41 +02:00
Thomas Lamprecht
2d38b8a1b9 tools: add pipe_socket_to_command
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-08-21 16:07:30 +02:00
Wolfgang Bumiller
1b71e56485 JSONSchema: add parse_boolean helper 2017-08-18 12:37:16 +02:00
Thomas Lamprecht
9a42d8a201 restenv: catch broadcast_tasklist errors gracefully
Don't die because the tasklist could not be broadcasted, just log the
error.
Else we may hinder all task to run with a quite confusing error (i.e.
"ipcc_send_rec: file to big").

This may happen if there are a lot currently running tasks at once.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-08-18 10:39:36 +02:00
Thomas Lamprecht
08b0c7c800 restenv: remove unused variable 'ctime'
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-08-18 10:21:50 +02:00
Thomas Lamprecht
ad7962b47e restenv: remove unnecessary if
we return early from this function if the $rest_env singleton doesn't
evaluates to true yet, so this check is useless here.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-08-18 10:21:50 +02:00
Wolfgang Bumiller
b1dc435ef6 bump version to 5.0-16 2017-06-30 09:18:17 +02:00
Emmanuel Kasper
72fba9114b Add run_fork_with_timeout utility
This runs subroutine in a forked process
and kills it after a timeout
2017-06-29 15:16:03 +02:00
Dietmar Maurer
61a967bf1f bump version to 5.0-15 2017-06-27 11:26:56 +02:00
Thomas Lamprecht
9a41a7b7c9 use more reliable checks in wait_for_vnc_port
We run into problems where this method returned to early, even if the
port wasn't actually ready yet. The reason for this is that we
checked /proc/net/tcp which does not guarantees and always up to date
state of only those ports which are actuall available, i.e. a port
could linger around (time-wait state) or appear even if it wasn't
accepting connections yet (as stated in the kernel docs:
/proc/net/tcp is seen as obsolete by the kernel devs).

Use the `ss` tool from the iproute2 package, it uses netlink to get
the current state and has switches where we can direct it to really
only get the state of those sockets which interest us currently.
I.e., we tell it to get only listening TCP sockets from the requested
port.

The only drawback is that we loop on a run_command, which is slower
than just reading a file. A single loop needs about 1ms here vs the
60µs on the /proc/net/tcp read. But this isn't a api call which is
used highly frequently but rather once per noVNC console open.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-06-27 11:22:55 +02:00
Dietmar Maurer
701270450e bump version to 5.0-14 2017-06-22 08:26:17 +02:00
Dominik Csapak
05477bfe8e add the parsing error message to the format
so that one can see its error when using the api/gui

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-06-13 11:36:31 +02:00
Dominik Csapak
e2c29de775 add ability to have multiple timespecs for hours and minutes
so things like: 2,4:0 will work

also add regression tests for this

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-06-13 11:36:20 +02:00
Dominik Csapak
a5ffa49fda trim event and check if empty
give a meaningful error if it is empty and disallow it instead of having
an implicit default (the default should be set by the component using
the calendarevent, not the calendarevent itself)

also add regression tests

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-06-13 11:36:11 +02:00
Fabian Grünbichler
3dabe28a23 add and use physical NIC regexp
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2017-06-08 15:00:49 +02:00
Dietmar Maurer
4ed6974a55 get_ip_from_hostname: improve error message
And do not generate multi-line error message.
2017-06-02 16:27:09 +02:00
Dominik Csapak
057c619ab2 calendarevent: check range for start also without repetition
else an event like "61" never finishes when calculating the next event

also add regression tests for this and other range checks

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-06-02 09:30:55 +02:00
Dietmar Maurer
d31335c674 bump version to 5.0-13 2017-05-31 09:08:07 +02:00
Dominik Csapak
a4200306fe calendarevent: change sorting of hours and minutes to numeric
otherwise the numbers are sorted like this:
[1,10,11 .. 19, 2, 20, ..]
which would lead to the wrong next time

also add regression tests for this and mixed forms like:
20..22:*/30

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-05-31 08:37:19 +02:00
Wolfgang Bumiller
a0ecb15991 tools: next_unused_port: use IPPROTO_TCP explicitly
Otherwise perl tries to bind+listen on a UDP socket if the
TCP socket fails - which is a waste since we're looking for
TCP ports.
Additionall since UDP doesn't support listen(), perl will
return EOPNOTSUPP instead of, say, EADDRINUSE. (We don't
care about the error in this code though.)
2017-05-31 07:34:14 +02:00
Wolfgang Bumiller
c14960cc1d tools: unused ports: optional address parameter
While it should be impossible to bind to a wildcard address
when the port is in use by any other address there's one
case where this is allowed, and that's when the port is in
use by an ipv6 address while trying to bind to an ipv4
wildcard.
This currently happens when qemu finds ::1 for the
'localhost' we pass to qemu's spice address while we're
resolving the local nodename via IPv4.
2017-05-31 07:32:17 +02:00
Dietmar Maurer
031efdd022 PVE::JSONSchema - add proxyto_callback property 2017-05-31 07:25:52 +02:00
Dietmar Maurer
752743e717 Revert "JSONSchema.pm: register new standard option pve-replicate"
This reverts commit b6501c2fd9.

No longer required, because we use a separate SectionConfig file to
store replication config.
2017-05-31 07:25:52 +02:00
Fabian Grünbichler
7ef316c824 Merge branch 'master' of pve-git:pve/pve-common 2017-05-29 13:57:03 +02:00
Thomas Lamprecht
c8e94d4bb5 swap raw syscall numbers with syscall.ph for easier porting
Raw syscall numbers were not platform independent, so replace them
with the helpers provided from the syscall.ph perl bits helper.

This makes reading the code easier as a nice side effect.

As syscall.ph is not an ordinary module and makes problems when it is
required by multiple modules we make a own module PVE::Syscall which
loads it and allows to export the necessary constants in a sane way.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-05-24 11:24:34 +02:00
Fabian Grünbichler
eb9924760d bump version to 5.0-12 2017-05-18 15:44:42 +02:00
Wolfgang Bumiller
1cffb285c5 fix #1388: cpuset: sort members numerically 2017-05-18 09:06:42 +02:00