[pve-devel] [PATCH pve-manager 1/1] httpserver: add rewrite uri for /nodes/(qemu/lxc)/<vmid>
Alexandre Derumier
aderumier at odiso.com
Wed May 31 13:19:52 CEST 2023
If nodename is not defined, we search the nodename
and rewrite uri to /nodes/<nodename>/(qemu|lxc)/<vmid
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/HTTPServer.pm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/PVE/HTTPServer.pm b/PVE/HTTPServer.pm
index dabdf7f3..b43611e1 100755
--- a/PVE/HTTPServer.pm
+++ b/PVE/HTTPServer.pm
@@ -46,6 +46,21 @@ sub verify_spice_connect_url {
return ($vmid, $node, $port);
}
+sub rewrite_uri {
+ my ($self, $uri) = @_;
+
+ my $base_uri = $self->{base_uri};
+ if($uri =~ m/^(\Q$base_uri\E\/+([a-z][a-z0-9]+)\/nodes\/)((qemu|lxc)\/(\d+)(.*))/) {
+ PVE::Cluster::cfs_update();
+ my $vmid = $5;
+ my $vmlist = PVE::Cluster::get_vmlist();
+ my $nodename = $vmlist->{ids}->{$vmid}->{node};
+ return $uri if !$nodename;
+ $uri = "$1$nodename/$3";
+ }
+ return $uri;
+}
+
sub generate_csrf_prevention_token {
my ($username) = @_;
return PVE::AccessControl::assemble_csrf_prevention_token($username);
--
2.30.2
More information about the pve-devel
mailing list