diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php
index 0ffb5d264..df8beacfd 100644
--- a/emhttp/plugins/dynamix/include/DashboardApps.php
+++ b/emhttp/plugins/dynamix/include/DashboardApps.php
@@ -69,6 +69,7 @@ if ($_POST['docker']) {
echo "\0";
if ($_POST['vms']) {
$vmusage = $_POST['vmusage'];
+ $vmusagehtml = [];
$user_prefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg';
$vms = $lv->get_domains() ?: [];
if (file_exists($user_prefs)) {
@@ -141,6 +142,17 @@ if ($_POST['vms']) {
}
$image = substr($icon,-4)=='.png' ? "
" : (substr($icon,0,5)=='icon-' ? "" : "");
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);
+ $vmusagehtml[] = "$image$vm
"._($status)."";
+ $vmusagehtml[] = "
"._("Loading")."....";
+ $vmusagehtml[] = "
"._("Loading")."....";
+ $vmusagehtml[] = "
"._("Loading")."....";
+ $vmusagehtml[] = "
"._("Loading")."....";
+ $vmusagehtml[] = "
"._("Loading")."....";
+ $vmusagehtml[] = "";
+ }
}
$none = count($vms) ? _('No running virtual machines') : _('No virtual machines defined');
echo "$none
";
@@ -148,70 +160,12 @@ if ($_POST['vms']) {
echo "\0";
echo "
";
- $running = 0;
if ($vmusage == "Y") {
- foreach ($vms as $vm) {
- $res = $lv->get_domain_by_name($vm);
- $uuid = libvirt_domain_get_uuid_string($res);
- $dom = $lv->domain_get_info($res);
- $id = $lv->domain_get_id($res);
- $fstype ="QEMU";
- if (($diskcnt = $lv->get_disk_count($res)) > 0) $fstype = $lv->get_disk_fstype($res);
- $state = $lv->domain_state_translate($dom['state']);
- $vmrcport = $lv->domain_get_vnc_port($res);
- $autoport = $lv->domain_get_vmrc_autoport($res);
- $vmrcurl = '';
- $arrConfig = domain_to_config($uuid);
- if ($vmrcport > 0) {
- $wsport = $lv->domain_get_ws_port($res);
- $vmrcprotocol = $lv->domain_get_vmrc_protocol($res) ;
- $vmrcurl = autov('/plugins/dynamix.vm.manager/'.$vmrcprotocol.'.html',true).'&autoconnect=true&host=' . $_SERVER['HTTP_HOST'] ;
- if ($vmrcprotocol == "spice") $vmrcurl .= '&vmname='. urlencode($vm) . '&port=/wsproxy/'.$vmrcport.'/' ; else $vmrcurl .= '&port=&path=/wsproxy/' . $wsport . '/';
- } elseif ($vmrcport == -1 || $autoport) {
- $vmrcprotocol = $lv->domain_get_vmrc_protocol($res) ;
- if ($autoport == "yes") $auto = "auto" ; else $auto="manual" ;
- } elseif (!empty($arrConfig['gpu'])) {
- $arrValidGPUDevices = getValidGPUDevices();
- foreach ($arrConfig['gpu'] as $arrGPU) {
- foreach ($arrValidGPUDevices as $arrDev) {
- if ($arrGPU['id'] == $arrDev['id']) {
- if (count(array_filter($arrValidGPUDevices, function($v) use ($arrDev) { return $v['name'] == $arrDev['name']; })) > 1) {
- $vmrcprotocol = "VGA" ;
- } else {
- $vmrcprotocol = "VGA" ;
- }
- }
- }
- }
- }
- $template = $lv->_get_single_xpath_result($res, '//domain/metadata/*[local-name()=\'vmtemplate\']/@name');
- 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"] ;
- $icon = $lv->domain_get_icon_url($res);
- $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','%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vmrcurl), strtoupper($vmrcprotocol), addslashes($log),addslashes($fstype), $vmrcconsole,true);
- if ($state != "running") continue;
- $running++;
- switch ($state) {
- case 'running':
- $shape = 'play';
- $status = 'started';
- $color = 'green-text';
- break;
- }
- $image = substr($icon,-4)=='.png' ? " " : (substr($icon,0,5)=='icon-' ? "" : "");
- echo "$image$vm "._($status)."";
- echo "
",_("Loading")."....";
- echo " "._("Loading")."....";
- echo " "._("Loading")."....";
- echo " "._("Loading")."....";
- echo " "._("Loading")."....";
- echo "";
- }
- if (!count($vms)) echo " "._('No running virtual machines')." ";
- if ($running < 1 && count($vms)) echo " ". _('No running virtual machines')." ";
+ foreach ($vmusagehtml as $vmhtml) {
+ echo $vmhtml;
+ }
+ if (!count($vmusagehtml)) echo " "._('No running virtual machines')." ";
+ if ($running < 1 && count($vmsusagehtml)) echo " ". _('No running virtual machines')." ";
echo " |
";
}
}