[pve-devel] [PATCH manager 1/2] add clustername to the static index files
Dominik Csapak
d.csapak at proxmox.com
Wed Jun 21 11:51:46 CEST 2017
this can be used to show the cluster we are on
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/Service/pveproxy.pm | 7 +++++++
www/index.html.tpl | 1 +
2 files changed, 8 insertions(+)
diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
index 0904127f..1516e233 100755
--- a/PVE/Service/pveproxy.pm
+++ b/PVE/Service/pveproxy.pm
@@ -5,6 +5,7 @@ use warnings;
use PVE::SafeSyslog;
use PVE::Daemon;
+use PVE::Cluster;
use HTTP::Response;
use Encode;
use URI;
@@ -171,6 +172,11 @@ sub get_index {
my $username;
my $token = 'null';
+ # get the cluster name
+ PVE::Cluster::cfs_update();
+ my $clinfo = PVE::Cluster::get_clinfo();
+ my $clustername = $clinfo->{cluster}->{name} // '';
+
if (my $cookie = $r->header('Cookie')) {
if (my $newlang = ($cookie =~ /(?:^|\s)PVELangCookie=([^;]*)/)[0]) {
if ($newlang =~ m/^[a-z]{2,3}(_[A-Z]{2,3})?$/) {
@@ -208,6 +214,7 @@ sub get_index {
console => $args->{console},
nodename => $nodename,
debug => $server->{debug},
+ clustername => $clustername,
};
# by default, load the normal index
diff --git a/www/index.html.tpl b/www/index.html.tpl
index 9abe09ef..f65a4fad 100644
--- a/www/index.html.tpl
+++ b/www/index.html.tpl
@@ -30,6 +30,7 @@
if (typeof(PVE) === 'undefined') PVE = {};
PVE.UserName = '[% username %]'
PVE.CSRFPreventionToken = '[% token %]';
+ PVE.Clustername = '[% clustername %]';
Ext.History.fieldid = 'x-history-field';
Ext.onReady(function() { Ext.create('PVE.StdWorkspace');});
</script>
--
2.11.0
More information about the pve-devel
mailing list