Commit Graph

7360 Commits

Author SHA1 Message Date
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
Aaron Lauterer
6d336ba433 ui: vm: guest-agent network view: make text in grid selectable
This makes it possible to select any of the IP addresses listed in the
full view window to copy & paste it.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
 [ TL: reworked subject ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-21 17:56:42 +01:00
Wolfgang Bumiller
baf6842a17 ui: user: password change: require a confirmation-password
To hedge against a scenario where an attacker has local or even
physical access to a computer where a user is logged in.

While that general scenario cannot neither get detected nor really
secured against, at least not without requiring re-authentication on
every API call that can have side-effect (i.e., all but GET method),
it still makes sense to ensure that credentials cannot be modified,
which would allow denial of service.

See the related pve-access-control commit 5bcf553 ("user: password
change: require confirmation-password parameter")

Reported-by: Wouter Arts <security@wth-security.nl>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-21 17:08:25 +01:00
Thomas Lamprecht
b120875cc4 ui: parse VM network: support floats without trailing zero
While on simple cases the frontend will translate a `.5` to `0.5` the
backend really doesn't care and takes either.
And it seems that editing from an exiting `0.5` to `.75` will often
cause this to submitted as is.

Independent of how such a value comes into the config, it broke parsing
the network rate property in the UI, where we assumed that there's
always a digit on the left side of the floating point separator.

Simply extend the regex to allow parsing those floats that directly
start with a separator too.

Link: https://forum.proxmox.com/threads/143525/
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-21 10:50:04 +01:00
Dominik Csapak
24d60df3da ui: guest import: add warning for losing efi state
and add a link to recreate the boot entries in ovmf

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ TL: break up String.format to avoid overly long line ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-19 18:16:51 +01:00
Dominik Csapak
6353e9f8c3 ui: guest import: correctly set default scsihw value
we have to set it to '__default__' if we didn't get one from the API

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ TL: fix-up eslint warning ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-19 18:16:21 +01:00
Dominik Csapak
4a855db6fa ui: guest import: auto activate virtio preparation for win + ovmf
it seems on esxi, most windows vms with uefi are automatically
configured with an lsi scsi controller, which we can't currently support
(ovmf driver issue) so automatically activate the sata mapping + virtio
preparation in this case

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-19 18:16:00 +01:00
Dominik Csapak
ffa2f7b4a7 ui: guest import: fix isWindows check
while most of our 'windiows' ostypes start with 'win' not all of them do
(wxp, wvista), so just shorten the condition to 'starts with `w`', this
covers all our windows ostypes, while not including others.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-19 18:16:00 +01:00
Christoph Heiss
da266fdc51 fix #5293: ceph status: fix division-by-zero when calculating usage
Fixes #5293 [0]. This happens when no OSDs are created yet and thus the
total space is 0, which leads to a division-by-zero.

Add a simple check if the total space is greater than 0.

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

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-19 18:16:00 +01:00
Thomas Lamprecht
01200f7d73 bump version to 8.1.6
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:26:40 +01:00
Thomas Lamprecht
0dca5cdabd ui: guest import: avoid view-model race on setting os type
Use the default value of the field also as start value in the
viewModel, as other wise the two-way binding can cause the empty
string to be set to the field's value, not vice-versa.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
202dc899e7 ui: guest import: fine-tune text on labels and button
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
7538d01102 ui: storage browser: add item double-click handler for guest import
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
defff6ad73 ui: import: fix top-padding of CD-ROM label
While it was required before commit ca9dce9e8 ("ui: guest import:
rework windows virtio-scsi preparation") to avoid making this crowded,
after that commit we already got the top-padding from the columnT
here, so no need for adding extra padding to that.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
c07819af96 ui: import: improve grouping of fields with more spacers
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
194eb3a850 ui: import: increase CPU limits to better match ESXi
On ESXi one can have at max 768 vCPUs and that over maximal 128
sockets. Further, by default ESXi will favor adding single-cpu
sockets, so if one just enters "give me 8 vCPUs", it will be 8
single-core sockets.

As we only supported up to 4 sockets in the web UI, which caused this
field to show up as invalid on initial load for such VMs, which is not
nice.

Having that many sockets is rather odd, so for us it doesn't make
sense to allow more than the ESXi limit that, but having more vCPUs
might make sense, so allow up to 1024 for that for now.

Note that QEMU and our API backend doesn't really cares, the kernels
NR_MAX_CPU is the limit there. Albeit it is questionable if using more
vCPU threads as there are host threads has some sense in any setup.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
2d0bf566ef ui: guest import: rework windows virtio-scsi preparation
instead of having a separate iso selector that shows with an enabled
checkbox, just add a CDROM drive when windows is selected and there is
no such drive available yet.
The idea here is that the VM's OS is already fully set up, so a single
CDROM drive is enough to be used for installing VirtIO drivers, unlike
the VM create case, where the first one is already used for the
installation medium.

Also, rename the 'map to sata' checkbox to 'prepare for virtio-scsi'
that also changes the scsi controller to virtio-scsi-single

Additionally, change the positioning of the checkbox/scsihw selector
to be below the disk grid
With that we then only disable prepare-for-virtio checkbox for
non-windows OS types, as the scsi controller on the right looks like
it hangs in the air without any field on the left otherwise.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ TL: rework commit message, squash in some fixes ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
e7ff5c7c73 ui: guest import: style clean-ups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
b4f879fdfd ui: guest import: prevent accidental form field submission on second panel
by overwriting the onGetValues to always return nothing

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
b6ff117554 ui: guest import: add checkbox for virtio drive
similar to what we have in the wizard.

in the case we cannot find a suitable slot (ide0/2, sata0-6), we
continue, but print a warning into the javascript log

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
31da365410 ui: iso selector: make labelWidth and Align configurable
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
8a0dd9d67b ui: guest import: add field for scsi controller
so that one can overwrite it

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
d39e2492de ui: guest import: implement 'map-to-sata' checkbox
this is useful when wanting to change to virtioscsi for windows vms,
since we cannot have multiple different scsi controllers.

we assume here that all assigned sata disks/cds have a continuous range,
so sata0, sata1, etc. without any holes

with that assumption, we can use the maximum sata index and simply put
the scsi ones after that.

when there are too many disks to map correctly to sata, show a warning
with the disk id that contains a tooltip.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
163868e119 ui: guest import: fine-tune paddings and heights in advanced tab
To make the UI appear slightly less crowded

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
226f01cba8 ui: guest import: add value-dependent warning for live-import
Use a similar text than we do for the live-restore warning and make it
use the pmx-hint CSS class.

Note that the CSS class order is important here as ExtJS automatically
uses the last one in the list here to add a XYZ-default and XYZ-after
class, so if the hint one is the last in the string, then layout gets
broken.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
b185bbade5 ui: guest import: add text for guest-is-running warning
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
463b9b8219 ui: guest import: update text for cdrom-image-ignored warning
one can now override this already in the import UI's Advanced tab.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
a5e56799e7 ui: guest import: handle new disk api format
and render the size if we have it (for disks that make sense)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
c52eb4769c ui: guest import: add config tab
that shows the current config. Recalculates whenever one changes to its
tab

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
1c2c2f6943 ui: guest import: move live import checkbox into panel
From the footer-bar, so make it a bit more apparent, and also to add
the 'Experimental' text to it.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
11236006c8 ui: guest import: make window wider
so we have more space to show e.g. columns in the grids

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
b0eeb862e6 ui: guest import: rework to tab panels
instead of putting all options on a single panel, split into 'general'
and 'advanced'

we move all disk/cd/network related grids to the advanced tab, and
introduce a 'default storage' and 'default bridge' selector to the
general tab.

this way, one can import very quickly when the default are fine or
when only the storage/bridge should change, but can still set the
storage/bridges etc. very fine grained.

also we have the possibility to extend the window in the future with
more tabs.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
81c46efcd8 ui: guest import: network grid: allow selecting hardware type
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
27afd69862 ui: guest import: network grid: display 'auto' instead of nothing
when there is not mac address on the source side

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
3c3d007eca ui: guest import: sort grids by id
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
b7583d4581 ui: guest import: add cdrom grid
so that one can already select an iso from here

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
4fb223f75e ui: guest import: add ostype selector
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
03d8d7d23a ui: esxi import: support rendering structured warnings
Render warnings as list to allowing one to better distinguish multiple
ones.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
bb3fa9def4 ui: add wizard to allow importing from ESXi attached as storage
Add a new 'import' panel for storages supporting the 'import'
content type that shows a list of configs to import.

When opening the wizard, we query the meta info from the new
import-metadata API endpoint, and pre-fill the fields and shows
potential warnings or things to watch out for, returned by the API.

For disks and networks we allow to select which one to use and which
storage/bridge to import to.

Additionally, users can opt-in to a live-import, where the VM is
immediately started and storage requests are fetched from the target
on demand while importing the rest in the background.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ TL: some fixes, clean-ups and commit message rewording ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
57d552b506 ui: esxi storage edit: add checkbox for skipping certificate validation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
e5a30c6d9b ui: esxi storage edit: make user and password always editable
Those can change somewhat frequently, e.g., as part of credentials
rotation policies.

Keep the 'server' one for now as is, while it can make sense to change
that too, e.g., from IP to FQDN, it's currently uncommon for PVE to
allow that in the UI, if we should evaluate all storage types for such
things and for that we also should improve the re-mount/activate story
in the storage lib.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
ddbddff766 ui: allow adding the esxi storage type
also change the icon to 'fa-cloud-download', hide the 'unknown' status
in the tree, and hide the Summary info from the storage browser

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
3dd9c5c808 ui: content view: fix use of external static tbar declaration
when using a declarative `tbar` when instantiating a ContentView,
it is a reference and gets pushed into every time.

instead, copy the given tbar into a local variable and use that

this fixes an issue that we push the same components (e.g. search) into
the toolbar whenever we open a view with a new ContentView
(when using declarative tbar)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Dominik Csapak
1826922d49 ui: content view: use modern simplified object delcaration
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
62580ab8c9 ui: storage content view: allow to define handler for item double-click
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:17:43 +01:00
Thomas Lamprecht
60e01c6ac2 bump version to 8.1.5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-14 15:13:30 +01:00
Thomas Lamprecht
385f48fb21 d/control: bump versioned dependency for libpve-access-control
to ensure the newly checked Sys.AccessNetwork privilege is available.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-28 15:53:51 +01:00
Thomas Lamprecht
846defd88c ui: storage: enable download-url button with Sys.AccessNetwork capability
Now that the new Sys.AccessNetwork privilege got added to
access-control and the storage download and manager query API
endpoints, the UI should reflect that change and allow opening the
dialogue to download an image from URL also for the users that are
allowed to do so through the new privilege.

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
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