From 15af3fb6eb8cd4d714c5b8b90afd8bcca7efcafb Mon Sep 17 00:00:00 2001
From: SimonFair <39065407+SimonFair@users.noreply.github.com>
Date: Fri, 31 May 2024 15:10:24 +0100
Subject: [PATCH 1/7] Fix zfs dir create if parent is a dir rather than
dataset.
---
emhttp/plugins/dynamix/include/Helpers.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/emhttp/plugins/dynamix/include/Helpers.php b/emhttp/plugins/dynamix/include/Helpers.php
index 15c536538..1788b97bf 100644
--- a/emhttp/plugins/dynamix/include/Helpers.php
+++ b/emhttp/plugins/dynamix/include/Helpers.php
@@ -285,12 +285,14 @@ function my_mkdir($dirname,$permissions = 0777,$recursive = false,$own = "nobody
$parent = str_replace('/mnt/user/', "/mnt/$realdisk/", $parent);
}
}
- $fstype = trim(shell_exec(" stat -f -c '%T' $parent"));
+ $fstype = trim(shell_exec(" stat -f -c '%T' $parent"));
$rtncode = false;
switch ($fstype) {
case "zfs":
$zfsdataset = trim(shell_exec("zfs list -H -o name $parent")) ;
- $zfsdataset .= str_replace($parent,"",$dirname);
+ if (strpos($zfsdataset,'/') !== false) $zfsdataset .= str_replace($parent,"",$dirname); else {
+ $zfsdataset .= str_replace("/mnt/$zfsdataset","",$dirname);
+ }
if ($recursive) $rtncode=exec("zfs create -p \"$zfsdataset\"");else $rtncode=exec("zfs create \"$zfsdataset\"");
if (!$rtncode) mkdir($dirname, $permissions, $recursive); else chmod($zfsdataset,$permissions);
break;
From e61132fe69806bfb920e7ea953462195b403d3b5 Mon Sep 17 00:00:00 2001
From: SimonFair <39065407+SimonFair@users.noreply.github.com>
Date: Sat, 1 Jun 2024 15:25:30 +0100
Subject: [PATCH 2/7] Create WebUI option for VMs
---
.../dynamix.vm.manager/include/VMMachines.php | 3 +-
.../dynamix.vm.manager/include/VMajax.php | 40 +++++++++++++++++++
.../javascript/vmmanager.js | 30 +++++++++++++-
.../templates/Custom.form.php | 16 ++++++++
.../plugins/dynamix/include/DashboardApps.php | 5 ++-
5 files changed, 89 insertions(+), 5 deletions(-)
diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
index 75ffcb60c..f09ea2a00 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
@@ -72,6 +72,7 @@ foreach ($vms as $vm) {
$diskdesc = 'Current physical size: '.$lv->get_disk_capacity($res, true)."\nDefault snapshot type: $fstype";
}
$arrValidDiskBuses = getValidDiskBuses();
+ $WebUI = $webGui = html_entity_decode($arrConfig['template']['webui']);
$vmrcport = $lv->domain_get_vnc_port($res);
$autoport = $lv->domain_get_vmrc_autoport($res);
$vmrcurl = '';
@@ -109,7 +110,7 @@ foreach ($vms as $vm) {
}
unset($dom);
if (!isset($domain_cfg["CONSOLE"])) $vmrcconsole = "web" ; else $vmrcconsole = $domain_cfg["CONSOLE"] ;
- $menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,addslashes($vmrcurl),strtoupper($vmrcprotocol),addslashes($log),addslashes($fstype), $vmrcconsole,false);
+ $menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s', '%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,addslashes($vmrcurl),strtoupper($vmrcprotocol),addslashes($log),addslashes($fstype), $vmrcconsole,false,addslashes(str_replace('"',"'",$WebUI)));
$kvm[] = "kvm.push({id:'$uuid',state:'$state'});";
switch ($state) {
case 'running':
diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMajax.php b/emhttp/plugins/dynamix.vm.manager/include/VMajax.php
index 828962754..f4b2118a8 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/VMajax.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/VMajax.php
@@ -146,6 +146,46 @@ case 'domain-consoleRV':
file_put_contents($vvfile,$vvarray) ;
$arrResponse['vvfile'] = $vvfile;
break;
+
+case 'domain-openWebUI':
+ requireLibvirt();
+ $dom = $lv->get_domain_by_name($domName);
+ $WebUI = unscript(_var($_REQUEST,'vmrcurl'));
+ $gastate = getgastate($dom);
+ if ($gastate == "connected") {
+ $ip = $lv->domain_interface_addresses($dom, 1);
+ #$arrResponse['other'] = "Connected $WebUI";
+ $gastate = getgastate($dom);
+ if ($gastate == "connected") {
+ $myIP=null;
+ $ip = $lv->domain_interface_addresses($dom, 1);
+ if ($ip != false) {
+ $duplicates = []; // hide duplicate interface names
+ foreach ($ip as $arrIP) {
+ $ipname = $arrIP["name"];
+ if (preg_match('/^(lo|Loopback)/',$ipname)) continue; // omit loopback interface
+ $iplist = $arrIP["addrs"];
+ foreach ($iplist as $arraddr) {
+ $myIP= $arraddr["addr"];
+ if (preg_match('/^f[c-f]/',$ipaddrval)) continue; // omit ipv6 private addresses
+ if (!in_array($ipnamemac,$duplicates)) $duplicates[] = $ipnamemac; else $ipnamemac = "";
+ break 2;
+ }
+ }
+ }
+ }
+ }
+ if (strpos($WebUI,"[IP]") && $myIP == NULL) $arrResponse['error'] = "No IP, guest agent not installed?";
+ $WebUI = preg_replace("%\[IP\]%", $myIP, $WebUI);
+ $WebUI = preg_replace("%\[VMNAME\]%", $domName, $WebUI);
+ if (preg_match("%\[PORT:(\d+)\]%", $WebUI, $matches)) {
+ $ConfigPort = $matches[1] ?? '';
+ $WebUI = preg_replace("%\[PORT:\d+\]%", $ConfigPort, $WebUI);
+ }
+
+ $arrResponse['vmrcurl'] = $WebUI;
+ break;
+
case 'domain-pause':
requireLibvirt();
diff --git a/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js b/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
index 2fe7de263..66e36095c 100644
--- a/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
+++ b/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
@@ -2,6 +2,10 @@ function displayconsole(url) {
window.open(url, '_blank', 'scrollbars=yes,resizable=yes');
}
+function displayWebUI(url) {
+ window.open(url, '', 'scrollbars=yes,resizable=yes');
+}
+
function downloadFile(source) {
var a = document.createElement('a');
a.setAttribute('href',source);
@@ -62,7 +66,24 @@ function ajaxVMDispatchconsoleRV(params, spin){
}
},'json');
}
-function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, fstype="QEMU",console="web",usage=false){
+function ajaxVMDispatchWebUI(params, spin){
+ if (spin) $('#vm-'+params['uuid']).parent().find('i').removeClass('fa-play fa-square fa-pause').addClass('fa-refresh fa-spin');
+ $.post("/plugins/dynamix.vm.manager/include/VMajax.php", params, function(data) {
+ if (data.error) {
+ swal({
+ title:_("Execution error"), html:true,
+ text:data.error, type:"error",
+ confirmButtonText:_('Ok')
+ },function(){
+ if (spin) setTimeout(spin+'()',500); else location=window.location.href;
+ });
+ } else {
+ if (spin) setTimeout(spin+'()',500); else location=window.location.href;
+ setTimeout('displayWebUI("'+data.vmrcurl+'")',500) ;
+ }
+ },'json');
+}
+function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, fstype="QEMU",console="web",usage=false,webui=""){
var opts = [];
var path = location.pathname;
var x = path.indexOf("?");
@@ -81,7 +102,12 @@ function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, f
ajaxVMDispatchconsoleRV({action:"domain-consoleRV", uuid:uuid, vmrcurl:vmrcurl}, "loadlist") ;
}});
}
-
+ if (webui != "") {
+ opts.push({text:_("Open WebUI") , icon:"fa-globe", action:function(e) {
+ e.preventDefault();
+ ajaxVMDispatchWebUI({action:"domain-openWebUI", uuid:uuid, vmrcurl:webui}, "loadlist") ;
+ }});
+ }
opts.push({divider:true});
}
context.settings({right:false,above:false});
diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
index e49a40246..a60910877 100644
--- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
+++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
@@ -357,6 +357,22 @@
+
+
+
+ Specify a URL that for menu to start. Substution variables are
+ [IP] IP address, this will take the first IP on the VM. Guest Agent must be installed for this to work.
+ [PORT:XX] Port Number in XX.
+ [VMNAME] VM Name will have spaces replaced with -
+
+
+
+
diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php
index 73a4c83a1..0c7fc87ab 100644
--- a/emhttp/plugins/dynamix/include/DashboardApps.php
+++ b/emhttp/plugins/dynamix/include/DashboardApps.php
@@ -119,7 +119,8 @@ if ($_POST['vms']) {
if (empty($template)) $template = 'Custom';
$log = (is_file("/var/log/libvirt/qemu/$vm.log") ? "libvirt/qemu/$vm.log" : '');
if (!isset($domain_cfg["CONSOLE"])) $vmrcconsole = "web" ; else $vmrcconsole = $domain_cfg["CONSOLE"] ;
- $menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vmrcurl), strtoupper($vmrcprotocol), addslashes($log),addslashes($fstype), $vmrcconsole);
+ $WebUI = html_entity_decode($arrConfig["template"]["webui"]);
+ $menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vmrcurl), strtoupper($vmrcprotocol), addslashes($log),addslashes($fstype), $vmrcconsole,false,addslashes(str_replace('"',"'",$WebUI)));
$icon = $lv->domain_get_icon_url($res);
switch ($state) {
case 'running':
@@ -144,7 +145,7 @@ if ($_POST['vms']) {
echo "$image $vm"._($status)." ";
if ($state == "running") {
#Build VM Usage array.
- $menuusage = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vmrcurl), strtoupper($vmrcprotocol), addslashes($log),addslashes($fstype), $vmrcconsole,true);
+ $menuusage = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vmrcurl), strtoupper($vmrcprotocol), addslashes($log),addslashes($fstype), $vmrcconsole,true,addslashes(str_replace('"',"'",$WebUI)));
$vmusagehtml[] = "$image $vm"._($status)." ";
$vmusagehtml[] = ""._("Loading").".... ";
$vmusagehtml[] = ""._("Loading").".... ";
From 91bc84a97aa458664bb64f5de7d5063ce414f265 Mon Sep 17 00:00:00 2001
From: SimonFair <39065407+SimonFair@users.noreply.github.com>
Date: Sat, 1 Jun 2024 15:41:23 +0100
Subject: [PATCH 3/7] Replace spaces in VM names
---
emhttp/plugins/dynamix.vm.manager/include/VMajax.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMajax.php b/emhttp/plugins/dynamix.vm.manager/include/VMajax.php
index f4b2118a8..e589f1c7d 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/VMajax.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/VMajax.php
@@ -177,7 +177,8 @@ case 'domain-openWebUI':
}
if (strpos($WebUI,"[IP]") && $myIP == NULL) $arrResponse['error'] = "No IP, guest agent not installed?";
$WebUI = preg_replace("%\[IP\]%", $myIP, $WebUI);
- $WebUI = preg_replace("%\[VMNAME\]%", $domName, $WebUI);
+ $vmnamehypen = str_replace(" ","-",$domName);
+ $WebUI = preg_replace("%\[VMNAME\]%", $vmnamehypen, $WebUI);
if (preg_match("%\[PORT:(\d+)\]%", $WebUI, $matches)) {
$ConfigPort = $matches[1] ?? '';
$WebUI = preg_replace("%\[PORT:\d+\]%", $ConfigPort, $WebUI);
From b35ce1134471fa0acf50fa82a733043beb809632 Mon Sep 17 00:00:00 2001
From: SimonFair <39065407+SimonFair@users.noreply.github.com>
Date: Sun, 2 Jun 2024 15:06:11 +0100
Subject: [PATCH 4/7] Change get VM IP to a function.
---
.../dynamix.vm.manager/include/VMajax.php | 40 +++++++------------
.../include/libvirt_helpers.php | 26 ++++++++++++
2 files changed, 41 insertions(+), 25 deletions(-)
diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMajax.php b/emhttp/plugins/dynamix.vm.manager/include/VMajax.php
index e589f1c7d..f8ac42c14 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/VMajax.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/VMajax.php
@@ -128,6 +128,20 @@ case 'domain-start-consoleRV':
$arrResponse['vvfile'] = $vvfile;
break;
+case 'domain-consoleRDP':
+ requireLibvirt();
+ $dom = $lv->get_domain_by_name($domName);
+ $rdpvarray = array() ;
+ $myIP=get_vm_ip($dom);
+ if ($myIP == NULL) {$arrResponse['error'] = "No IP, guest agent not installed?"; break; }
+ $rdparray[] = "full address:s: $myIP\n";
+ #$rdparray[] = "administrative session:1\n";
+ if (!is_dir("/mnt/user/system/remoteviewer")) mkdir("/mnt/user/system/remoteviewer") ;
+ $rdpfile = "/mnt/user/system/remoteviewer/rv"._var($_SERVER,'HTTP_HOST').".$port.rdp" ;
+ file_put_contents($rdpfile,$rdparray) ;
+ $arrResponse['vvfile'] = $rdpfile;
+ break;
+
case 'domain-consoleRV':
requireLibvirt();
$dom = $lv->get_domain_by_name($domName);
@@ -151,30 +165,7 @@ case 'domain-openWebUI':
requireLibvirt();
$dom = $lv->get_domain_by_name($domName);
$WebUI = unscript(_var($_REQUEST,'vmrcurl'));
- $gastate = getgastate($dom);
- if ($gastate == "connected") {
- $ip = $lv->domain_interface_addresses($dom, 1);
- #$arrResponse['other'] = "Connected $WebUI";
- $gastate = getgastate($dom);
- if ($gastate == "connected") {
- $myIP=null;
- $ip = $lv->domain_interface_addresses($dom, 1);
- if ($ip != false) {
- $duplicates = []; // hide duplicate interface names
- foreach ($ip as $arrIP) {
- $ipname = $arrIP["name"];
- if (preg_match('/^(lo|Loopback)/',$ipname)) continue; // omit loopback interface
- $iplist = $arrIP["addrs"];
- foreach ($iplist as $arraddr) {
- $myIP= $arraddr["addr"];
- if (preg_match('/^f[c-f]/',$ipaddrval)) continue; // omit ipv6 private addresses
- if (!in_array($ipnamemac,$duplicates)) $duplicates[] = $ipnamemac; else $ipnamemac = "";
- break 2;
- }
- }
- }
- }
- }
+ $myIP = get_vm_ip($dom);
if (strpos($WebUI,"[IP]") && $myIP == NULL) $arrResponse['error'] = "No IP, guest agent not installed?";
$WebUI = preg_replace("%\[IP\]%", $myIP, $WebUI);
$vmnamehypen = str_replace(" ","-",$domName);
@@ -183,7 +174,6 @@ case 'domain-openWebUI':
$ConfigPort = $matches[1] ?? '';
$WebUI = preg_replace("%\[PORT:\d+\]%", $ConfigPort, $WebUI);
}
-
$arrResponse['vmrcurl'] = $WebUI;
break;
diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
index a9901f231..e8f31708e 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
@@ -2763,4 +2763,30 @@ function qemu_log($vm,$m) {
file_put_contents("/var/log/libvirt/qemu/$vm.log",$m."\n",FILE_APPEND);
}
+function get_vm_ip($dom) {
+ global $lv;
+ $myIP=null;
+ $gastate = getgastate($dom);
+ if ($gastate == "connected") {
+ $ip = $lv->domain_interface_addresses($dom, 1);
+ $gastate = getgastate($dom);
+ if ($gastate == "connected") {
+ $ip = $lv->domain_interface_addresses($dom, 1);
+ if ($ip != false) {
+ foreach ($ip as $arrIP) {
+ $ipname = $arrIP["name"];
+ if (preg_match('/^(lo|Loopback)/',$ipname)) continue; // omit loopback interface
+ $iplist = $arrIP["addrs"];
+ foreach ($iplist as $arraddr) {
+ $myIP= $arraddr["addr"];
+ if (preg_match('/^f[c-f]/',$myIP)) continue; // omit ipv6 private addresses
+ break 2;
+ }
+ }
+ }
+ }
+ }
+ return $myIP;
+}
+
?>
From b2916424be4bd9978d918f493caaa8d9673555ad Mon Sep 17 00:00:00 2001
From: SimonFair <39065407+SimonFair@users.noreply.github.com>
Date: Sun, 2 Jun 2024 15:06:58 +0100
Subject: [PATCH 5/7] Add rdp menu option.
---
emhttp/languages/en_US/helptext.txt | 4 ++++
emhttp/plugins/dynamix.vm.manager/VMSettings.page | 8 ++++++++
.../plugins/dynamix.vm.manager/include/VMMachines.php | 1 +
.../dynamix.vm.manager/javascript/vmmanager.js | 11 ++++++++++-
emhttp/plugins/dynamix/include/DashboardApps.php | 1 +
5 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/emhttp/languages/en_US/helptext.txt b/emhttp/languages/en_US/helptext.txt
index b878ec9af..f78226d10 100644
--- a/emhttp/languages/en_US/helptext.txt
+++ b/emhttp/languages/en_US/helptext.txt
@@ -1680,6 +1680,10 @@ For setting the console options to show on context menus. Web will show only inb
Virtual Manager Remote Viewer will only show the Remote Viewer option. Both will show both Web and Remote Viewer.
:end
+:vms_rdp_help:
+Adds option to menu to start RDP. RDP file is downloaded. You need to set browser to open when ready.
+:end
+
:vms_usage_help:
Show metrics for CPU both guest and host percentage, memory, disk io and network io.
:end
diff --git a/emhttp/plugins/dynamix.vm.manager/VMSettings.page b/emhttp/plugins/dynamix.vm.manager/VMSettings.page
index 99d2501a3..afa172038 100644
--- a/emhttp/plugins/dynamix.vm.manager/VMSettings.page
+++ b/emhttp/plugins/dynamix.vm.manager/VMSettings.page
@@ -183,6 +183,14 @@ _(Console Options)_:
:vms_console_help:
+_(Show RDP menu option)_:
+:
+ =mk_option($domain_cfg['RDPOPT'], 'no', _('Dont show RDP option'))?>
+ =mk_option($domain_cfg['RDPOPT'], 'yes', _('Show RDP option'))?>
+
+
+:vms_rdpopt_help:
+
_(Show VM Usage)_:
:
=mk_option($domain_cfg['USAGE'], 'N', _('Disabled'))?>
diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
index f09ea2a00..42eedee1b 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
@@ -110,6 +110,7 @@ foreach ($vms as $vm) {
}
unset($dom);
if (!isset($domain_cfg["CONSOLE"])) $vmrcconsole = "web" ; else $vmrcconsole = $domain_cfg["CONSOLE"] ;
+ if (!isset($domain_cfg["RDPOPT"])) $vmrcconsole .= ";no" ; else $vmrcconsole .= ";".$domain_cfg["RDPOPT"] ;
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s', '%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,addslashes($vmrcurl),strtoupper($vmrcprotocol),addslashes($log),addslashes($fstype), $vmrcconsole,false,addslashes(str_replace('"',"'",$WebUI)));
$kvm[] = "kvm.push({id:'$uuid',state:'$state'});";
switch ($state) {
diff --git a/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js b/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
index 66e36095c..9cc8c3f13 100644
--- a/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
+++ b/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
@@ -83,10 +83,13 @@ function ajaxVMDispatchWebUI(params, spin){
}
},'json');
}
-function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, fstype="QEMU",console="web",usage=false,webui=""){
+function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, fstype="QEMU",consolein="web;no",usage=false,webui=""){
var opts = [];
var path = location.pathname;
var x = path.indexOf("?");
+ var consolesplit = consolein.split(";");
+ var console = consolesplit[0];
+ var rdpopt = consolesplit[1];
if (x!=-1) path = path.substring(0,x);
if (vmrcurl !== "" && state == "running") {
if (console == "web" || console == "both") {
@@ -108,6 +111,12 @@ function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, f
ajaxVMDispatchWebUI({action:"domain-openWebUI", uuid:uuid, vmrcurl:webui}, "loadlist") ;
}});
}
+ if (rdpopt == "yes") {
+ opts.push({text:_("VM Windows RDP"), icon:"fa-desktop", action:function(e) {
+ e.preventDefault();
+ ajaxVMDispatchconsoleRV({action:"domain-consoleRDP", uuid:uuid, vmrcurl:vmrcurl}, "loadlist") ;
+ }});
+ }
opts.push({divider:true});
}
context.settings({right:false,above:false});
diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php
index 0c7fc87ab..36edf47a9 100644
--- a/emhttp/plugins/dynamix/include/DashboardApps.php
+++ b/emhttp/plugins/dynamix/include/DashboardApps.php
@@ -119,6 +119,7 @@ if ($_POST['vms']) {
if (empty($template)) $template = 'Custom';
$log = (is_file("/var/log/libvirt/qemu/$vm.log") ? "libvirt/qemu/$vm.log" : '');
if (!isset($domain_cfg["CONSOLE"])) $vmrcconsole = "web" ; else $vmrcconsole = $domain_cfg["CONSOLE"] ;
+ if (!isset($domain_cfg["RDPOPT"])) $vmrcconsole .= ";no" ; else $vmrcconsole .= ";".$domain_cfg["RDPOPT"] ;
$WebUI = html_entity_decode($arrConfig["template"]["webui"]);
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vmrcurl), strtoupper($vmrcprotocol), addslashes($log),addslashes($fstype), $vmrcconsole,false,addslashes(str_replace('"',"'",$WebUI)));
$icon = $lv->domain_get_icon_url($res);
From 392811005c9eb80d4733256b6d08a37f6b47f60b Mon Sep 17 00:00:00 2001
From: SimonFair <39065407+SimonFair@users.noreply.github.com>
Date: Sun, 2 Jun 2024 16:02:45 +0100
Subject: [PATCH 6/7] Update text.
---
emhttp/languages/en_US/helptext.txt | 2 +-
emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/emhttp/languages/en_US/helptext.txt b/emhttp/languages/en_US/helptext.txt
index f78226d10..3227592d3 100644
--- a/emhttp/languages/en_US/helptext.txt
+++ b/emhttp/languages/en_US/helptext.txt
@@ -1680,7 +1680,7 @@ For setting the console options to show on context menus. Web will show only inb
Virtual Manager Remote Viewer will only show the Remote Viewer option. Both will show both Web and Remote Viewer.
:end
-:vms_rdp_help:
+:vms_rdpopt_help:
Adds option to menu to start RDP. RDP file is downloaded. You need to set browser to open when ready.
:end
diff --git a/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js b/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
index 9cc8c3f13..4c598a089 100644
--- a/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
+++ b/emhttp/plugins/dynamix.vm.manager/javascript/vmmanager.js
@@ -112,7 +112,7 @@ function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, f
}});
}
if (rdpopt == "yes") {
- opts.push({text:_("VM Windows RDP"), icon:"fa-desktop", action:function(e) {
+ opts.push({text:_("VM Remote Desktop Protocol(RDP)"), icon:"fa-desktop", action:function(e) {
e.preventDefault();
ajaxVMDispatchconsoleRV({action:"domain-consoleRDP", uuid:uuid, vmrcurl:vmrcurl}, "loadlist") ;
}});
From 8354a5c6acb9761250da527ccce7deccc53fc5c5 Mon Sep 17 00:00:00 2001
From: SimonFair <39065407+SimonFair@users.noreply.github.com>
Date: Sun, 2 Jun 2024 16:14:18 +0100
Subject: [PATCH 7/7] Code tidy
---
emhttp/plugins/dynamix.vm.manager/include/VMMachines.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
index 42eedee1b..5bcec8694 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
@@ -72,7 +72,7 @@ foreach ($vms as $vm) {
$diskdesc = 'Current physical size: '.$lv->get_disk_capacity($res, true)."\nDefault snapshot type: $fstype";
}
$arrValidDiskBuses = getValidDiskBuses();
- $WebUI = $webGui = html_entity_decode($arrConfig['template']['webui']);
+ $WebUI = html_entity_decode($arrConfig['template']['webui']);
$vmrcport = $lv->domain_get_vnc_port($res);
$autoport = $lv->domain_get_vmrc_autoport($res);
$vmrcurl = '';