Sometimes we need to have a fallback for gai (get_ip_from_hostname)
but cannot yet rely on configured networks (get_reachable_networks)
from kernel POV (those may not have been configured yet, e.g., on
boot), so the ones configured in /etc/network/interfaces would be
nice too then, as they're the ones that will get configured soon
anyway on boot.
Add a new helper that takes in all those sources and allows to return
a single (first found) or all of those addresses.
Still prioritize the address we get from getaddrinfo, as there the
admin has control through /etc/hosts, DNS and gai.conf and treat the
remaining ones as fallback.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
will be used for the issue banner generators and for some "get
nodeip" calls as fallback for get_ip_from_hostname, which tends to
fail in our CT envs (e.g., PMG)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Return a suitable address directly instead of breaking out of the
loop to do that.
no semantic change intended
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
those fields might be interesting to users. At the moment, this is
only used in the external metrics export.
These fields exist in the kernel since:
* irq - 2.6.0
* softirq - 2.6.0
* steal - 2.6.11
* guest - 2.6.24
* guest_nice - 2.6.33
so they must all exist
also add a 'total' field which simply sums up the (non-guest) fields
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
As that would be weird, the use explicitly did not configure it,
which is OK, and we'd then warn due to *our* fallback to `0`.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
it's an invalid combination that causes the network reload/setup to
fail. unfortunately, this is not caught by ifupdown2 itself, but only
rejected by the kernel with ERANGE over netlink.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Used in qemu-server for avoiding KillMode 'none'. SendSIGKILL is a
boolean, so we need to use dbus_boolean to serialize it.
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
so it is more consistend with the source (it comes from the file
'device') as well as the subsytem_device field
the only place we use that field is in the same file in pci_dev_bind_to_vfio,
which we also change here, so that should not be a breaking change
(in qemu-server we only really use the existance and the has_fl_reset
flag)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
to also get the subsystem_vendor and device, as well as the
iommu group and mediated device support
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
There's also support for ending a task with warnings now, so the logic "status
not 'OK' means error" does not work anymore.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Net::IP doesn't seem to have a function for it and normalizing to the full
quad-form is less then ideal if we inted to output IPv6 addresses returned by
that function at some point.
Instead, use NetAddr::IP, which is already used in pve-network.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
is_ip_in_cidr('fd80:1::10', '127.0.0.1/24') would result in
Use of uninitialized value in numeric eq (==)
as overlaps() returns undef in such a case.
Note that there are (albeit few) existing callers that don't specify $version.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
it is not necessary to include this block in the eval which when it
fails tries to unlink $tmpdest, because in the check for the existing
file $tmpdest is not used.
We support also vlanX, with X being a integer for the VLAN id, as
valid vlan iface name, so support that too here.
and make the dev name check for definedness, even if "0" is currently
not really supported (officially) it is still a valid iface name for
the kernel (which takes any byte).
The VLAN id is in the range of [2, 4094] (inclusive) so defined check
is not required there.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Setting the vlan-id and vlan-raw-device value for vlan devices that
follow the dot notaton (interface.vlan) aligns how dot notation vlan
devices and vlan devices that use the explicit vlan-id and
vlan-raw-device options, available with ifupdown2, are represented in
API return values.
Previously the type for both was 'vlan' but only the latter showed more
details.
Setting these values here should not have any influence on how the
interfaces file is being written as these two values are already
filtered in __write_etc_network_interfaces for dot notation devices.
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
plus some refactoring
* drop worker, cannot be done here (RPCEnv is in pve-access-control)
* actually output the wrong "got" hash on mismatch
* die on existing file with mismatched
* drop double array for passing cmd
* drop `/usr/bin` prefix
* adapt rename error message
* add error handling for unlinking the temp. file
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
adds a common function to download arbitrary files from urls.
code is based on
manager:PVE/API2/Nodes.pm:aplinfo
Security notice: this function does not perform any permission
checking. The callee has to make sure, that only authorized users may
use this function.
Caution: This function is able to download files from internal
networks (which would not be visible/accessible from outside), the
callee needs to ensure that unprivileged (e.g., non root@pam or the
like) can only pass OK URLs (e.g., resolving to public routable IPs)
Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This reverts commit a3777dce67.
With the upcoming release of pmg-api 7.0 we included the changes for
configuring a LISTEN_IP, thus this compatibility code is not needed
anymore.
Quickly tested with current pmg-api master
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>