Commit Graph

243 Commits

Author SHA1 Message Date
Hannes Laimer
9cba51ac78 datastore: remove datastore from internal cache based on maintenance mode
We keep a DataStore cache, so ChunkStore's and lock files are kept by
the proxy process and don't have to be reopened every time. However,
for specific maintenance modes, e.g. 'offline', our process should not
keep file in that datastore open. This clears the cache entry of a
datastore if it is in a specific maintanance mode and the last task
finished, which also drops any files still open by the process.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
Reviewed-by: Gabriel Goller <g.goller@proxmox.com>
Tested-by: Gabriel Goller <g.goller@proxmox.com>
2024-03-25 16:12:41 +01:00
Wolfgang Bumiller
708d5bdaf9 cargo fmt (import reordering)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-20 11:13:13 +01:00
Dietmar Maurer
2416aea8d4 pbs-api-types: use const_format and new api-types from proxmox-schema
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-03-20 11:09:26 +01:00
Gabriel Goller
e0222ce83c fix #5190: api: OIDC: accept generic URIs for the ACR value
Allow more complex strings for the acr-value when using openid. The
openid documentation only specifies the acr-value *should* be an URI
[0].  Implemented a regex that loosely disallows some of the reserved
URI characters specified in the RFC [1].

Currently values like:
- "urn:mace:incommon:iap:silver"
- "urn:comsolve.nl:idp:contract:rba:location"
do NOT work, although they are correct URI's and common acr tokens.

For Proxmox VE we had to actually make this more strict to align with
each other, as there we accepted any string.

[0]: https://openid.net/specs/openid-connect-core-1_0.html
[1]: https://www.rfc-editor.org/rfc/rfc2396.txt

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-02-08 18:14:30 +01:00
Wolfgang Bumiller
3a45719ecf move api-types tests to api-types and drop vec![] macro
we don't need to allocate here

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-01-10 10:13:45 +01:00
Wolfgang Bumiller
64dec8d6f0 api-types: doc improvements
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-01-10 10:13:45 +01:00
Wolfgang Bumiller
126cf33c76 api-types: impl Display for FilterType
as the previous commit: simply keep the previous Display impl and call
it from out of the new GroupFilter impl

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-01-10 10:13:45 +01:00
Wolfgang Bumiller
4f0dd33704 api-types: factor out FilterType parsing
simply keep the previous FromStr implementation and call it the new
GroupFilter impl

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-01-10 10:13:45 +01:00
Wolfgang Bumiller
bc9509ad14 fixup import grouping
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-01-10 10:13:45 +01:00
Philipp Hufnagl
59c9273698 fix #4315: jobs: modify GroupFilter so include/exclude is tracked
After some discussion I canged the include/exclude behavior to first run
all include filter and after that all exclude filter (rather then
allowing to alternate inbetween). This is done by splitting them into 2
lists, running include first.

A lot of discussion happened how edge cases should be handled and we
came to following conclusion:

no include filter + no exclude filter => include all
some include filter + no exclude filter => filter as always
no include filter +  some exclude filter => include all then exclude

Since a GroupFilter now also features an behavior, the Struct has been
renamed To GroupType (since simply type is a keyword). The new
GroupFilter now has a behaviour as a flag 'is_exclude'.

I considered calling it 'is_include' but a reader later then might not
know what the opposite of 'include' is (do not include?  deactivate?). I
also considered making a new enum 'behaviour' but since there are only 2
values I considered it over engeneered.

Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
2024-01-10 10:13:45 +01:00
Dominik Csapak
c7321e2ea3 tape: move 'eject-before-unload' to a plain changer config option
instead of having it in a property string. For now this should be fine,
and if we need many more such options, we can still move them into a
property string if we want.

Also update the cli command in the docs on how to set it now.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-12-14 10:23:49 +01:00
Dominik Csapak
667ec4a3c2 tape: fix 'eject-before-unload' api type
by converting the bool into an option, otherwise having the options not
set at all will fail the unload while deserializing with
'eject-before-unload is not optional'

Also if we can automatically decide this in the future, we can now
detect if the option was explicitely set or not.

Fixes: 66402cdc ("fix #4904: tape changer: add option to eject before unload")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-12-13 12:14:33 +01:00
Dominik Csapak
66402cdc1b fix #4904: tape changer: add option to eject before unload
some tape libraries need the tape being ejected from the drive before
doing an unload. Since we cannot easily detect if that's the case,
introduce an 'eject_before_unload' option.

Instead of just adding a bool flag to the config, add a new 'options'
property string where we can put such niche options similar to how we
handle the datastore tuning options.

Extend the LtoTapeHandle with 'medium_present' which just uses a
TEST UNIT READY command to check for present medium, so we don't
try to eject an already ejected tape.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-12-12 14:36:19 +01:00
Dominik Csapak
d555c3839b tape: changer: save whole LtoTapeDrive config in MtxMediaChanger
we'll need more info from there in the future, so derive clone for it
and save the whole config instead of adding an additional field.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-12-12 14:36:08 +01:00
Dominik Csapak
70706fc9f6 tape: derive PartialEq and PartialOrd for TapeDensity
so that we can compare more easily

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-12-12 13:24:58 +01:00
Gabriel Goller
cbb478fa19 status: use Option on avail/used datastore attrs
Instead of returning -1 if we can't get the attributes, we use an
Option which will not be serialized on `None`.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2023-12-11 13:09:13 +01:00
Wolfgang Bumiller
1e3ed74be5 api-types: add a missing serde(default)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-12-06 15:53:57 +01:00
Thomas Lamprecht
6685122c3b tree-wide: fix various typos
found with codespell

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-29 18:32:07 +01:00
Gabriel Goller
de99031e49 node: status: declutter kernel-version
Return a struct with all the components of the kernel version like it
has been done in pve. Also return the legacy `kversion` to keep
backwards compat.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-29 15:31:35 +01:00
Gabriel Goller
1656c53486 node: status: added bootmode
Added field that shows the bootmode of the node. The bootmode is either
Legacy Bios, EFI, or EFI (Secure Boot). To detect the mode we use the
exact same method as in pve: We check if the `/sys/firmware/efi` folder
exists, then check if the `SecureBoot-xx...` file in the `efivars`
directory has the SecureBoot flag enabled.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-29 15:31:35 +01:00
Markus Frank
1ec643ce92 api types: add regex, format & schema for partition names
The new regex is similar to BLOCKDEVICE_NAME_REGEX but also allows
numbers at the end of the device name (also allows partitions names).
For nvme partitions it also allows the letter p and a number.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
2023-11-28 18:24:12 +01:00
Thomas Lamprecht
6c5248fbc6 tree-wide: run cargo fmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-27 15:37:35 +01:00
Maximiliano Sandoval R
dfe17914cf fix-3211: manager: Document --notify argument
Signed-off-by: Maximiliano Sandoval R <m.sandoval@proxmox.com>
2023-11-27 15:33:51 +01:00
Hannes Laimer
4ec733279b api: make Remote for SyncJob optional
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Tested-by: Gabriel Goller <g.goller@proxmox.com>
2023-11-25 17:07:42 +01:00
Dietmar Maurer
d1f438f51e pbs-api-types: derive Clone and PartialEq for BackupContent, SnapshotVerifyState, SnapshotListItem and GroupListItem
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-11-23 09:53:30 +01:00
Dietmar Maurer
e050aa187b PruneJobConfig: remove stale optional flag from the API macro.
The property is not optional - it is defined as "String".

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-11-16 17:47:38 +01:00
Dietmar Maurer
65c9e40695 pbs-api-types: derive Clone and PartialEq for job config/status types (for GUI)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-11-15 16:37:44 +01:00
Fabian Grünbichler
07f321ddb4 apt: use apt changelog for changelog fetching
support for it got added to Proxmox repositories, so there is no need to use
custom logic and manual fetching for this anymore.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-11-14 08:43:47 +01:00
Dietmar Maurer
3d342e13d3 DatastoreTuning: fix serde attributes
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-11-12 12:02:19 +01:00
Dietmar Maurer
ded3a88888 DatastoteNotify: fix serde attributes
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-11-12 11:25:09 +01:00
Dietmar Maurer
3b7a6b25c1 TrafficControlCurrentRate: derive Clone and PartalEq (for GUI)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-15 11:09:42 +02:00
Dietmar Maurer
1a1870ba86 move TrafficControlCurrentRate to pbs-api-types
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-15 11:07:58 +02:00
Dietmar Maurer
13984bd1bc TrafficControlRule: derive Clone and PartialEq (for GUI) 2023-10-15 09:25:26 +02:00
Dietmar Maurer
247ae35019 Interface: add missing serde skip_serializing_if to bond_xmit_hash_policy
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-12 12:39:18 +02:00
Dietmar Maurer
8192c9ea56 Interface: fix deserialize (add default)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-11 11:38:01 +02:00
Dietmar Maurer
9c73fcf3cf Interface: derive Clone + PartialEq (for GUI)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-11 11:37:15 +02:00
Dietmar Maurer
4a33ad1ca5 move MetricServerInfo definition to pbs-api-types
And derive Clone, Eq and Ord so that we can sort the list in the GUI.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-09 08:19:08 +02:00
Dietmar Maurer
6d33fb6fe3 pbs-api-types: move node status types from src/api2/types/mod.rs
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-09-28 08:13:30 +02:00
Dietmar Maurer
ac5e632f2f AclListItem: derive Clone and PartialEq
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-09-02 16:24:45 +02:00
Dietmar Maurer
fb1c262f9c TaskListItem: derive Clone and PartialEq 2023-08-30 13:34:51 +02:00
Stefan Sterz
a24d24cf9e fix: api-types: add support for lto 9 tape density
lto 9 tapes have a new density code which leads to these tapes not
being recognized properly. add the new density code and TapeDensity to
improve lto 9 support. since the documentation states that we support
lto 5 and above this constitutes a bug fix for lto 9 support.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-08-11 08:52:50 +02:00
Christoph Heiss
5a76907b06 api-types: drop unused leftover file
Commit d97ff8ae ("use new auth api crate") moved all auth-related code
into it's own crate inside the `proxmox` repo, including this file. Thus
drop it here, it's not even included in the compile.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-08-08 12:00:09 +02:00
Wolfgang Bumiller
7b449954bb api-types: set serde defaults for UserWithTokens
since `totp_locked` is not wrapped in an `Option` we need to
explicitly tell serde about its default

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-01 09:12:43 +02:00
Wolfgang Bumiller
9b85fdc71d api: include tfa lock status in user list
Like in PVE.
This means that /access/users is now a 'protected' call to
get access to 'tfa.cfg'.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-26 19:47:16 +02:00
Stefan Sterz
5210f3b532 access: ldap check connection on creation and change
this commit makes the ldap realm endpoints check whether a new or
updated configuration works correctly. it uses the new
`check_connection` function to make sure that a configuration can be
successfully used to connect to and query an ldap directory.

doing so allows us to remove the ldap domain regex. instead of relying
on a regex to make sure that a given distinguished name (dn) could be
correct, we simply let the ldap directory tell us whether it accepts
it. this should also aid with usability as a dn that looks correct
could still be invalid.

this also implicitly removes unauthenticated binds, since the new
`check_connection` function does not support those. it will simply
bail out of the check if a `bind_dn` but no password is configured.
therefore, this is a breaking change.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-06-26 16:08:24 +02:00
Lukas Wagner
08f8a3e5aa api-types: client: datastore: tools: use proxmox-human-bytes crate
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-06-26 13:56:45 +02:00
Stefan Hanreich
9b67352abc partial fix #3701: sync job: pull: add transfer-last parameter
Specifying the transfer-last parameter limits the amount of backups
that get synced via the pull command/sync job. The parameter specifies
how many of the N latest backups should get pulled/synced. All other
backups will get skipped.

This is particularly useful in situations where the sync target has
less disk space than the source. Syncing all backups from the source
is not possible if there is not enough disk space on the target.
Additionally this can be used for limiting the amount of data
transferred, reducing load on the network.

The newest backup will always get re-synced, regardless of the setting
of the transfer-last parameter.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-04-24 15:18:51 +02:00
Dominik Csapak
1b5cd72d79 api types: fix non-capturing group syntax
a non capturing group is '(?:)' not '(:?)' so fix that.
None of these regexes are used where would use capturing groups.
DATASTORE_MAP_REGEX and TAPE_RESTORE_SNAPSHOT_REGEX are only used
as api types and BLOCKDEVICE_NAME_REGEX is only used once outside of the
api and there we also don't look at the capturing groups.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-04-06 07:28:58 +02:00
Thomas Lamprecht
6477df8f89 api-types: anchor datastore-map regex
Fixes: 4c4e5c2b ("api2/tape/restore: enable restore mapping of datastores")
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-29 11:58:59 +02:00
Lukas Wagner
072b0e9cf9 api-types: ldap: properly anchor DN regex
Otherwise, a substring match is enough to fulfill the constraint.

Fixes: c001aca0 ("api-types: ldap: add verification regex for LDAP DNs")
Reported-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-03-29 11:29:10 +02:00