Commit Graph

49 Commits

Author SHA1 Message Date
Lukas Wagner
4c40d7cbed api: notification: make the 'mail-to-root' target visible to any user
Since the target does not require Mapping.Use, it should also be
visible and testable by all users.

Short explanation why the 'mail-to-root' is exempt from priv checks:

To ensure backwards compatibility, the 'mail-to-root' target does not
require the `Mapping.Use` privs. This is needed due to the fact that
this target is used as a fallback in case no other target is
configured for an event. For instance, the /node/<name>/apt/update API
call only requires Sys.Modify for the node, but it can also send a
notification. If we were to require Mapping.Use, we could break the
apt/update API compat in the case that a notification shall be sent,
but without any configured notification target (which will then
default to 'mail-to-root').

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-16 11:11:24 +02:00
Lukas Wagner
1ba1988dcf api: notification: disallow removing targets if they are used
Check notification targets configured in datacenter.cfg and jobs.cfg,
failing if the group/endpoint to be removed is still in use there.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-16 11:11:08 +02:00
Lukas Wagner
7e6efd3905 api: notification: allow to test targets
This API call allows the user to test a notification target.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-16 11:11:06 +02:00
Lukas Wagner
e678a5dbfa api: notification: allow fetching notification targets
The API call returns all entities that can be used as notification
targets (endpoints, groups). Only targets for which the user has
appropriate permissions are returned.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-16 11:10:53 +02:00
Lukas Wagner
56977d48a9 api: notification: add api routes for filters
The Perl part of the API methods primarily defines the API schema,
checks for any needed priviledges and then calls the actual Rust
implementation exposed via perlmod. Any errors returned by the Rust
code are translated into PVE::Exception, so that the API call fails
with the correct HTTP error code.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-16 11:10:51 +02:00
Lukas Wagner
aed4eff9cf api: notification: add api routes for gotify endpoints
The Perl part of the API methods primarily defines the API schema,
checks for any needed priviledges and then calls the actual Rust
implementation exposed via perlmod. Any errors returned by the Rust
code are translated into PVE::Exception, so that the API call fails
with the correct HTTP error code.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-16 11:10:50 +02:00
Lukas Wagner
c2c3125126 api: notification: add api routes for sendmail endpoints
The Perl part of the API methods primarily defines the API schema,
checks for any needed priviledges and then calls the actual Rust
implementation exposed via perlmod. Any errors returned by the Rust
code are translated into PVE::Exception, so that the API call fails
with the correct HTTP error code.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-16 11:10:49 +02:00
Lukas Wagner
95c2dc1bc9 api: notification: add api routes for groups
The Perl part of the API methods primarily defines the API schema,
checks for any needed priviledges and then calls the actual Rust
implementation exposed via perlmod. Any errors returned by the Rust
code are translated into PVE::Exception, so that the API call fails
with the correct HTTP error code.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-16 11:10:47 +02:00
Lukas Wagner
b6fa29f3f5 api: prepare api handler module for notification config
This commit adds a new Perl module, PVE::API2::Cluster::Notification.
The module will contain all API handlers for the new notification
subsystem.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-16 11:10:15 +02:00
Dominik Csapak
d958b1306f api: resource usb mapping: add missing proxyto_callback
i have added it to the pci api call, but forgot to add it for usb
otherwise adding a mapped usb device only works on the node where the
gui is connected to

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-06-21 12:51:47 +02:00
Thomas Lamprecht
dd6433ff1c api: mappings: cleanup perl imports
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 08:30:53 +02:00
Thomas Lamprecht
b74e71f2c2 api: cluster jobs: fix perl module not ending with a true value
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 08:30:53 +02:00
Thomas Lamprecht
ebed76a242 api: PCI mappings: code/style cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 08:30:53 +02:00
Thomas Lamprecht
3a8bf3b613 api: PCI mappings: rename errors to checks in response
as it contains warnings too, so having it named errors might be
confusing.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 08:30:53 +02:00
Thomas Lamprecht
d4830b941f api: PCI mappings: complete return schema
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 08:30:53 +02:00
Dominik Csapak
797bcf9aa2 api: add resource map api endpoints for PCI and USB
this adds the typical section config crud API calls for
USB and PCI resource mapping to /cluster/mapping/{TYPE}

the only special thing that this series does is the list call
for both has a special 'check-node' parameter that uses the
'proxyto_callback' to reroute the api call to the given node
so that it can check the validity of the mapping for that node

in the future when we e.g. broadcast the lspci output via pmxcfs
we drop the proxyto_callback and directly use the info from
pmxcfs (or we drop the parameter and always check all nodes)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-06-16 16:25:42 +02:00
Dominik Csapak
9802297517 api: add realm-sync crud api to /cluster/jobs
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ T: fix-up realm sync module namespace, moved to PVE::API2::Jobs ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-07 11:38:34 +02:00
Thomas Lamprecht
147d67c495 makefile: convert to use simple parenthesis
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-29 18:24:00 +02:00
Thomas Lamprecht
08d251ef2b api: ceph metadata: rename instance placeholder to id in return schema
It's a bit more commonly used for such identifier

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-16 16:32:16 +01:00
Aaron Lauterer
ee6ec73ba9 api: ceph: metadata: update return schema
This API endpoint returns a big nested schema. This patch adds a mostly
complete description.

For the actual service instance return schema, we include commonly used
and important properties. It will usually return more. What exactly
depends on the Ceph service type.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-01-16 14:32:00 +01:00
Aaron Lauterer
b62ba85ad7 api: ceph: update return schemas
to include a more complete description of the returned data.
Sort properties in alphabetical order if the list is longer.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-01-16 14:32:00 +01:00
Thomas Lamprecht
63d389bc51 api: backup info: make "name" property truly optional in response struct
avoid returning a nullish/undef value if not specified

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-15 14:07:39 +01:00
Thomas Lamprecht
fc9991245f api: backup info: code/style cleanup/rework/modernization
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-15 14:07:39 +01:00
Thomas Lamprecht
730d5a0f42 api: backup info: drop querying rrd_dump, not used
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-15 14:07:39 +01:00
Thomas Lamprecht
0d3f86f2a4 api: backup info: rework get_included_vmids code style
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-15 14:07:39 +01:00
Dominik Csapak
e5f94bc198 schedule-analyze: fix schedules with limited runs
When a schedule only has a limited amount of runs it can happen
(e.g. 2022-10-01 8:00/30), $next will be undef after the last run.
Exit early in that case.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-05-04 07:10:13 +02:00
Dominik Csapak
5964deeae3 api: metrics: use complete config for testing the connection
not only the given parameters, e.g. at the moment, the gui will
never send a 'verify-certificate' parameter, even if set in the config

by using the complete resulting config, we test the actual settings.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-11-15 16:17:51 +01:00
Thomas Lamprecht
c20699493a api: cluster: add jobs sub-directory index and set its permissions
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-11 21:02:03 +01:00
Thomas Lamprecht
584a57ea3c calendar event simulator: rename number parameter to iterations
in sync with the same option of `systemd-analyze calendar` and number
is so generic.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-11 20:53:13 +01:00
Dominik Csapak
e190bc2cc8 api: cluster: add jobs/schedule-analyze api call
a simple api call to simulate calendar event triggers
takes a schedule, an optional number (default 10), an optional starttime
(default 'now') and returns a list with unix timestamps, as well as
humanly readable utc timestamps.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-11-11 18:35:52 +01:00
Dominik Csapak
305921b1ab api/backup: handle new vzdump jobs
in addition to listing the vzdump.cron jobs, also list from the
jobs.cfg file.

updates/creations go into the new jobs.cfg only now
and on update, starttime+dow get converted to a schedule
this transformation is straight forward, since 'dow'
is already in a compatible format (e.g. 'mon,tue') and we simply
append the starttime (if any)

id on creation is optional for now (for api compat), but will
be autogenerated (uuid). on update, we simply take the id from before
(the ids of the other entries in vzdump.cron will change but they would
anyway)

as long as we have the vzdump.cron file, we must lock both
vzdump.cron and jobs.cfg, since we often update both

we also change the backupinfo api call to read the jobs.cfg too

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-11-10 16:11:00 +01:00
Dominik Csapak
d3eed3b4a8 api: ceph: fix getting ceph versions
Since commit: 8a3a300b ("ceph services: drop broadcasting legacy
version pmxcfs KV")

The 'ceph-version' kv is not broadcasted anymore, so we should not
query it, instead use get_ceph_versions

Also drop the other legacy keys for the versions

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-10 14:36:22 +01:00
Thomas Lamprecht
df6f4b1874 move BackupInfo module into Cluster
no semantic change regarding API or the like intended

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-02 12:50:49 +02:00
Dominik Csapak
27bc5e8e02 status/plugin: extend with add/update/delete hooks
like we do in it for the storage section configs

we will need this to store the token for influxdbs http api

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-01-28 17:32:23 +01:00
Dominik Csapak
161d904f13 api: cluster/metricserver: prevent simultaneosly setting and deleting of property
like we do in other apis of section configs (e.g. storage)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-01-28 17:32:23 +01:00
Dominik Csapak
dadba141a8 api: metrics/server: test connection on add/update
just a basic check, but better than not checking at all

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-11-25 14:55:25 +01:00
Thomas Lamprecht
22ad422ac9 api: cluster/ceph: allow version metadata call on non-ceph nodes
the information comes only from the key value store in the pmxcfs, so
we do not actually require ceph to be installed.

So only check if ceph is locally initialized and create the rados
connection after the early return when only versions scope is set.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-11-22 17:59:36 +01:00
Thomas Lamprecht
d57f8d9482 ui/api: metrics: move server to subpath, post to path with ID
We actually wanted to use that scheme for more new API paths, lets
see if it is really fitting starting with this.

Use the new widget-toolkit submitUrl helper to add the ID on create.

And unify the edit/create window creation, which may fit better in a
separate commit, it's quite small and was to cumbersome to untangle,
so just go against my one rules here... :(

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-11-21 20:53:05 +01:00
Thomas Lamprecht
9dedf1e2d5 api: drop Config from MetricServer module name
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-11-21 20:39:33 +01:00
Dominik Csapak
19e3a7f2a4 api2/cluster: add 'metricserver' api endpoints
modeled after our typical api endpoints for sectionschema configs

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-11-21 20:39:33 +01:00
Alwin Antreich
e25dda254c Make PVE6 compatible with supported ceph versions
Luminous, Nautilus and Octopus. In Octopus the mon_status was dropped.
Also the ceph status was cleaned up and doesn't provide the mgrmap and
monmap.

The rados queries used in the ceph status API endpoints (cluster / node)
were factored out and merged to one place.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
2020-06-03 14:23:38 +02:00
Dominik Csapak
4602218730 ceph: add 'scope' parameter to metadata api call
so that we can choose to only include the versions and not all metadata
this is done to avoid having a seperate 'versions' api call

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-01 17:15:41 +02:00
Dominik Csapak
0496138e44 ceph: factor out get/broadcast ceph versions to ceph::services
which also removes some dead code
(the my $local_last_version variable was never used)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-01 17:15:41 +02:00
Thomas Lamprecht
6fba05b2b6 api/ceph: skip merging metadata if hostname is undefined
It's a bit hard to figure out the exact constellation required for
this to happen, but we saw it in live systems when one node was dead
in a three node cluster.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-21 10:57:50 +01:00
Thomas Lamprecht
ae253364d5 ceph/api: cleanup comment on extra line
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-21 10:57:21 +01:00
Thomas Lamprecht
1aaca6fde7 api: ceph/metadata: add structured node versions
include the version as string and as parts, as we do the split
already. Also include the build commit, so if we re-release a ceph
version, we can differ here too.

Use node as key, to make the new entry a bit more general, could be
easily expanded with other infos, if required.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-15 18:36:37 +01:00
Thomas Lamprecht
6dd2846577 ceph: add perl flag GET and PUT call
use PUT for setting or unsetting, as POST/DELETE (like the old node
specific API used) makes no sense. One does not creates or deletes
the flag, they are always here. One just updates their value

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-23 17:15:37 +02:00
Thomas Lamprecht
1225095df1 ceph: move flag API endpoints to node-agnostic /cluster/ceph path
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-23 17:15:37 +02:00
Thomas Lamprecht
78ad23f8f0 api/cluster: move ceph calls into sub- directory/module
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-23 15:28:18 +02:00