Commit Graph

1156 Commits

Author SHA1 Message Date
Thomas Lamprecht
a3fe9c5410 api: notifications: require powerful privileges for target management
These allow one to indirectly access resources from the POV of the
Proxmox VE cluster nodes. While gotify is relatively harmless, smtp
could already cause more problems to admins that are not aware of the
implications of allowing users to add targets while having some open
smtp relay that is only accessible from networks the PVE nodes can
access but not the user that can talk with PVE's API. The webhook one
is then pretty much free-form and might cause some adverse effects in
environments that are only loosely guarded, and while that might point
at general security problems, it's likely that admins will still place
the blame at our projects.

So while the former should not be problematic, the new not yet fully
released webhooks could have some impact. That said, it currently
requires Mapping.Modify, which is a intermediate powerful level priv,
so it's not like any user could use this. Still, hedging for the
safer side here seems the better choice for now, we still can open
this up if there's user feedback and we deem it safe enough doing so.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-19 19:28:20 +01:00
Aaron Lauterer
ddb95697e1 fix #3893: api: network: add bridge_vids parameter
The API itself allows several list separators. The network configuration
for bridge_vids expects a space separated list. We therefore convert it
initially to a space separated list.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2024-11-15 18:58:25 +01:00
Dominik Csapak
993d05abc6 api/ui: include the node ha status in resources call and show as icon
we already have the information parsed, so it's cheap, and we already
have a mechanism in place that adds 'ha-<hastate>' as a css class, so
let's reuse that.

I chose a blue wrench, as wrenches are associated with 'maintenance',
and because the state is different than 'online' and 'offline', but
don't make it yellow since it's not really a 'failure' state.

Users mentioned in the forum that this would be nice:
https://forum.proxmox.com/threads/125768/

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-11-13 15:26:42 +01:00
Lukas Wagner
9cc1dde4ea api: add routes for webhook notification endpoints
These just call the API implementation via the perl-rs bindings.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
2024-11-11 21:59:01 +01:00
Lukas Wagner
d99b5f6eb9 api: notifications: use get_targets impl from proxmox-notify
The get_targets API endpoint is now implemented in Rust.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
2024-11-11 21:59:01 +01:00
Wolfgang Bumiller
4de7a1f0ea api: unify type documentation across resources return type
Stick to the pattern
single: "(for type 'foo')"
multiple: "(for types 'foo', 'bar'(...) and 'last-type')"

Also adapt line-wrapping accordingly (for a 100 column limit) and fix
some minor typos (and one phrasing) while at it.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-10-30 11:43:47 +01:00
Dominik Csapak
7f215f4e41 api: tasks: fix return type of 'starttime'
starttime is parsed from a upid with perls `hex` which always returns an
integer

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-10-30 11:31:06 +01:00
Dominik Csapak
8ab4f8a21a api: cluster resources: add lock and tags to return schema
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-10-30 11:31:04 +01:00
Thomas Lamprecht
ccf9e2f2a3 api: pci hardware: code/indentation style clean-ups
The endpoint name is mostly used for calling the API methods as first
class perl method through autoloader, but manager is a leaf node
w.r.t. dependencies and there is no existing call for either of the
two.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-30 10:45:19 +01:00
Dominik Csapak
8b33297c6e api/ui: improve mdev listing for pci mappings
Currently, when we have a PCI resource mapping, we manually check only
the available models for the first PCI entry. This often works, but not
always, since one could have completely different devices in one
mapping, or with the new NVIDIA sysfs api we don't get the generally
available models.

To improve this, extend the parameter for the PCI ID to accept both,
PCI IDs or named mappings, and for the latter mappings, iterate over
all local PCI devices in it and extract the mdev types.

Rename also the parameter to better reflect what it accepts. While the
this is changing a API parameter, it's not a breaking change in this
specific case because the parameter is derived from the URL path, and
any attempt to include the parameter with a name manually is not
possible and  will result in an error:

  duplicate parameter (already defined in URI) with conflicting values!

Since we cannot reach the API handler without giving the parameter
already via the URL, there is no way to give it via name.

Accepting named mappings directly in this API endpoint also vastly
simplifies the UI code, since we now only have to give the mapping to
the selector instead of an (arbitrarily selected) PCI id from that
mapping.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ TL: also split pciid into pci-id for readability and reword message
   slightly ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-30 10:38:46 +01:00
Wolfgang Bumiller
08490df02f api: cluster resources: add more missing descriptions
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-10-25 10:24:13 +02:00
Thomas Lamprecht
30d8da901f api: cluster resources: reword description of some properties
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-24 16:43:03 +02:00
Dominik Csapak
5c6331cf4c api: cluster/resources: add missing return properties
used the same description as for the guests.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ TL: avoid having netin twice, change to netout once ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-24 16:43:03 +02:00
Dominik Csapak
38050aee61 api: subscription: add return schema for 'GET' api
This was missing, but it mostly well defined since we're using the rust
bindings here. I copied most descriptions over from the PBS api, except
the ones only existing here (like sockets and level)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-24 16:43:03 +02:00
Fabian Grünbichler
6fc3134f3c fix #5753: api: add 'pstart' member to task status return schema
using the definition already used in the task index API schema in the same
module.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-10-04 16:25:16 +02:00
Thomas Lamprecht
750def79c4 api: subscription update: use new module for getting available ceph releases
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-04 16:23:35 +02:00
Thomas Lamprecht
abbf6dedb9 api: subscription update: report error if removing ceph-auth file fails
Print a warning if the file could not deleted (if it was actually
existed)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-10-04 16:23:35 +02:00
Thomas Lamprecht
3520ed6af1 api subscription: sort and group use statements
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-09-26 12:11:52 +02:00
Fabian Grünbichler
69698ccc63 download handling: adapt to method schema field rename
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-09-23 10:53:25 +02:00
Fabian Grünbichler
7641dcb6d9 api: annotate download endpoints
both the task and system log API endpoints support downloading the log data.

annotate the API method schema accordingly to allow passing the newly
introduced checks in the API handler that limit download functionality to
annotated endpoints.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-09-23 10:53:25 +02:00
Fabian Grünbichler
ad984948f9 fix #5731: vzdump jobs: fix execution of converted jobs
jobs converted from vzdump.cron have an ID of the format

$digest:$counter

where $digest is the hash of the vzdump.cron file, and $counter is the
position of the job within the crontab.

while the section config schema pretends jobs.cfg's section IDs are
of type pve-configid, that is not enforced anywhere, and the API
endpoints managing such jobs allowed arbitrary strings in the past.

the ':' character is not allowed by `pve-configid`, but it is by the
section config parsers and the Job API.

convert the API schema to use the unification of previous definition
used by the job API, and what the section config parser accepts.

Fixes: f5a97f1f5 (api: jobs: vzdump: pass job 'job-id' parameter)
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-09-20 17:44:26 +02:00
Fabian Grünbichler
bab934c4fa vzdump jobs: make job ID a standard option
and put it into PVE::VZDump because there is a cycle between

PVE::Jobs::VZDump, PVE::API2::VZDump and PVE::API2::Backups

that prevents any of those containing it for now.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-09-20 17:44:00 +02:00
Lukas Wagner
073b53ae71 metrics: add /cluster/metrics/export endpoint
This new endpoint returns node, storage and guest metrics in JSON
format. The endpoint supports history/max-age parameters, allowing
the caller to query the recent metric history as recorded by the
PVE::PullMetric module.

The returned data format is quite simple, being an array of
metric records, including a value, a metric name, an id to identify
the object (e.g. qemu/100, node/foo), a timestamp and a type
('gauge', 'derive', ...). The latter property makes the format
self-describing and aids the metric collector in choosing a
representation for storing the metric data.

    [
        ...
        {
            "metric": "cpu_avg1",
            "value": 0.12,
            "timestamp": 170053205,
            "id": "node/foo",
            "type": "gauge"
        },
        ...
    ]

Some experiments were made in regards to making the format
more 'efficient', e.g. by grouping based on timestamps/ids, resulting
in a much more nested/complicated data format. While that
certainly reduces the size of the raw JSON response by quite a bit,
after GZIP compression the differences are negligible (the
simple, flat data format as described above compresses by a factor
of 25 for large clusters!). Also, the slightly increased CPU load
of compressing the larger amount of data when e.g. polling once a
minute is so small that it's indistinguishable from noise in relation
to a usual hypervisor workload. Thus the simpler, format was
chosen. One benefit of this format is that it is more or less already
the exact same format as the one Prometheus uses, but in JSON format -
so adding a Prometheus metric scraping endpoint should not be much
work at all.

The API endpoint collects metrics for the whole cluster by calling
the same endpoint for all cluster nodes. To avoid endless request
recursion, the 'local-only' request parameter is provided. If this
parameter is set, the endpoint implementation will only return metrics
for the local node, avoiding a loop.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
[WB: remove unused $start_time leftover from benchmarks]
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 14:18:48 +02:00
Lukas Wagner
7d004d69f0 api: notification: add API for getting known metadata fields/values
This new API route returns known notification metadata fields and
a list of known possible values. This will be used by the UI to
provide suggestions when adding/modifying match rules.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
2024-07-22 19:34:58 +02:00
Lukas Wagner
f5a97f1f5d api: jobs: vzdump: pass job 'job-id' parameter
This allows us to access the backup job id in the send_notification
function, where we can set it as metadata for the notification.
The 'job-id' parameter can only be used by 'root@pam' to prevent
abuse. This has the side effect that manually triggered backup jobs
cannot have the 'job-id' parameter at the moment. To mitigate that,
manually triggered backup jobs could be changed so that they
are not performed by a direct API call by the UI, but by requesting
pvescheduler to execute the job in the near future (similar to how
manually triggered replication jobs work).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
 [ TL: fleece in d/control bump for guest-common now that the version
   is known ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-07-22 19:23:18 +02:00
Aaron Lauterer
9477cb4b76 api: ceph mds: avoid creating MDS when ID starts with number
Ceph MDS IDs cannot start with a number [0].

[0] https://docs.ceph.com/en/latest/man/8/ceph-mds/

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
2024-07-22 18:44:38 +02:00
Maximiliano Sandoval
641cc888b5 ceph: osd: fix canot typo
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-07-22 18:28:18 +02:00
Maximiliano Sandoval
d76c2b0f9e fix typos in comments
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-07-22 18:28:18 +02:00
Thomas Lamprecht
6d4c9cade7 api: node status: fix description of current-kernel schema entry
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-07-15 09:44:25 +02:00
Lukas Wagner
d915b69907 api: replication: include 'hostname' field for notifications
The field contains the hostname of the host (without any domain part)
which sends the notification. This field can be used in match-field
match rules.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-07-04 14:57:08 +02:00
Lukas Wagner
2952bfe413 vzdump: apt: notification: do not include domain in 'hostname' field
- The man page warns about the usage of `hostname -f`, since a host
   may have multiple domains (or none at all)
 - The fallback PVE::INotify::nodename() already only returned the
   hostname without the domain part
 - Fencing notifications didn't include the domain part anyway

This may result in soft-breakage for any users who have already relied
on the domain being present. If there is need for it, it could include
a fqdn metadata field.

The hostname property used for rendering the notification template
is unaffected for now.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-07-04 14:57:08 +02:00
Lukas Wagner
431ae86b08 api: replication: add 'job-id' to notification metadata
This allows users to create notification match rules for specific
replication jobs, if they so desire.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-07-04 14:57:08 +02:00
Lukas Wagner
fede7e87e4 notifications: use named templates instead of in-code templates
This commit adapts notification sending for
    - package update
    - replication
    - backups

to use named templates (installed in /usr/share/pve-manager/templates)
instead of passing template strings defined in code to the
notification stack.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
2024-06-03 14:16:35 +02:00
Mira Limbeck
fc6acae04b api: add proxmox-firewall to versions pkg list
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2024-05-21 15:58:55 +02:00
Fiona Ebner
77266e2961 api: backup/vzdump: add permission check for fleecing storage
Similar to how Datastore.AllocateSpace is required for the backup
storage, it should also be required for the fleecing storage.

Removing a fleecing storage from a job does not require more
permissions than for modifying the job.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-04-19 15:57:28 +02:00
Lukas Wagner
3941bc7f43 api: notifications: add 'smtp' to target index
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-04-19 12:33:52 +02:00
Fabian Grünbichler
23d1d28307 vnc: use SSH command helper
to benefit from future improvements there, like pinning the known host key.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-04-19 09:09:44 +02:00
Thomas Lamprecht
34d63c2ba8 api: apt versions: track optional pve-esxi-import-tools package
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-18 22:15:17 +02:00
Alexander Zeidler
8aeed8d1e8 api: apt versions: track optional amd64/intel-microcode packages
Signed-off-by: Alexander Zeidler <a.zeidler@proxmox.com>
2024-04-18 22:14:15 +02:00
Max Carrara
11edd5d88d fix #4759: ceph: configure ceph-crash.service and its key
Due to Ceph dropping privileges when running the 'ceph-crash' daemon
[0], it is necessary to allow the daemon to authenticate with its
cluster in a safe manner.

In order to avoid exposing sensitive keyrings or somehow escalating
its privileges again, 'ceph-crash' is therefore provided with its own
keyring in the '/etc/pve/ceph' directory. This directory, due to being
on 'pmxcfs', may be read by members of the 'www-data' group, which
'ceph-crash' is made part of [1].

Expected Configuration
----------------------

 1. A keyring file named '/etc/pve/ceph/ceph.client.crash.keyring'
    exists
 2. A section named 'client.crash' exists in '/etc/pve/ceph.conf'
 3. The 'client.crash' section has a key named 'keyring' which
    references the keyring file as '/etc/pve/ceph/$cluster.$name.keyring'
 4. The 'client.crash' section has *no* key named 'key'

New Clusters
------------

The keyring file is created and the conf file is updated after the first
monitor has been created (when calling `pveceph mon create`).

Existing Clusters
-----------------

A new helper script creates and configures the 'client.crash' keyring in
`postinst`, if:
 * Ceph is installed
 * Ceph is initialized ('/etc/pve/ceph.conf' and '/etc/pve/ceph' exist)
 * Connection to RADOS is successful

If the above conditions are met, the helper script ensures that the
existing configuration matches the expected configuration mentioned
above.

The configuration is not changed if it is already as expected.

The helper script may be called again manually if the `postinst` hook
fails. It is installed to '/usr/share/pve-manager/helpers/pve-init-ceph-crash'.

Existing `client.crash` Key
---------------------------

If a key named 'client.crash' already exists within the cluster, it is
reused and not regenerated.

[0]: https://github.com/ceph/ceph/pull/48713
[1]: https://git.proxmox.com/?p=ceph.git;a=commitdiff;h=f72c698a55905d93e9a0b7b95674616547deba8a

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
2024-04-11 10:42:11 +02:00
Max Carrara
a51a28e3cd ceph: introduce '/etc/pve/ceph'
This commit adds the '/etc/pve/ceph' directory to our overall expected
Ceph configuration.

This directory is meant to store cluster-wide, non-private
configuration files used by Ceph applications and services that are
executed with lower privileges, such as 'ceph-crash.service'.

The existence of the directory is now also checked for when checking
whether Ceph is configured correctly. This makes it easier for our
other tooling to rely on the directory's existence, reducing the
number of otherwise needless frequent checking.

* For new clusters: `pveceph init` now creates '/etc/pve/ceph' when
  called.

* For existing clusters: The 'postinst' hook this commit adds ensures
  that '/etc/pve/ceph' is created when updating.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
2024-04-11 10:42:11 +02:00
Thomas Lamprecht
f2be47a4c5 node: wake-on-lan: document defaults and small style clean-up
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-28 17:52:25 +01:00
Christian Ebner
a967ff655f fix #5255: node: wol: configurable broadcast address
Allows to configure a custom broadcast address to use when sending a
wake on lan packet to wake a remote node.

Default behaviour remains to fallback to 255.255.255.255.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-03-28 17:27:47 +01:00
Christian Ebner
869c155c6a fix #5255: node: wol: add optional bind interface
Allows to optionally configure a local interface name to which to
bind to when sending a wake on lan packet to wake a remote node.

Default behaviour remains to send the packet via the interface for
the default gateway.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-03-28 17:27:47 +01:00
Christian Ebner
3f83a0332e node: config: make wakeonlan a property string
Moves the wakeonlan property to be a property string, with current mac
address as default key. This allows to later add further optional
properties such as bind-interface and broadcast-address.

Adds the `get_wakeonlan_config` helper function to parse the string
when read from the node config.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-03-28 17:27:47 +01:00
Max Carrara
50ae86b758 api: ceph monitor: rework some code style to modern
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
 [ TL: also improve if-expression wrapping ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-21 18:12:39 +01:00
Max Carrara
bacedc4e9b fix #5198: ceph: mon: fix mon existence check in mon removal assertion
The Ceph monitor removal assertion contains a condition that checks
whether the given mon ID actually exists and thus may be removed.

The first part of the condition checks whether the hash returned by
`get_services_info` [0] contains the key "mon.$monid". However, the
hash's keys are never prefixed with "mon.", which makes this check
incorrect.

This is fixed by just using "$monid" directly.

The second part checks whether the mon hashes returned by
Ceph contain the "name" key before comparing the key with the given
mon ID. This key existence check is also incorrect; in particular:
  * If the lookup `$_->{name}` evaluates to e.g. "foo", the check
    passes, because "foo" is truthy. [1]
  * If the lookup `$_->{name}` evaluates to "0", the check fails,
    because "0" is falsy (due to it being equivalent to the number 0,
    according to Perl [1]).

This is solved by using the inbuilt `defined()` instead of relying on
Perl's definition of truthiness.

[0]: https://git.proxmox.com/?p=pve-manager.git;a=blob;f=PVE/Ceph/Services.pm;h=e0f31e8eb6bc9b3777b3d0d548497276efaa5c41;hb=HEAD#l112
[1]: https://perldoc.perl.org/perldata#Scalar-values

Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=5198
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-03-21 18:09:30 +01:00
Thomas Lamprecht
6cf1a48d45 api: nodes: allow usage of query url metadata with Sys.AccessNetwork
This was restricted to Sys.Modify + Sys.Audit on the whole cluster to
ensure that only trusted users get access to a method that can scan
the (local) network from the POV of the Proxmox VE node, even if only
through HTTP HEAD requests.

Nowadays there's enough user interest [0] to warrant a separate access
privilege to cover such an use case, and while most of the requests
are for the download-url storage API endpoint, this method here is not
only a bit less powerful than the storage one, it's rather tied to the
latter anyway (e.g. for querying the metadata of a URL in the web UI
for name and size before downloading it to a storage).

For backwards compatibility keep the old check and add the new
privilege as alternative to fulfill the permission requirements of
that API endpoint.

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=5254

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Hannes Duerr <h.duerr@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-02-28 15:53:28 +01:00
Thomas Lamprecht
4467a5d2f2 api: node status: document boot-info and current-kernel in return schema
I recently added the same info to PMG and added them to the return
schema, so copying them over here comes for free, and while far from
complete but better than nothing.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-26 16:55:13 +01:00
Hannes Duerr
e308895fc7 add missing library packages
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
2024-01-12 16:48:24 +01:00