Fixed display "Power Status" for libvirt vm's (#12283)

* Update print-vm.inc.php

virsh (libvirtd (libvirt) 4.5.0) displaying status of VMs:
```
shut off
running
paused
```

* Update libvirt-vminfo.inc.php
This commit is contained in:
DerTFL
2020-11-01 03:26:00 +03:00
committed by GitHub
parent 134b110e71
commit 1374c56ade
2 changed files with 5 additions and 4 deletions

View File

@@ -74,6 +74,7 @@ if (Config::get('enable_libvirt') && $device['os'] == 'linux') {
// libvirt does not supply this
exec(Config::get('virsh') . ' -rc ' . $uri . ' domstate ' . $dom_id, $vm_state);
$vmwVmState = ucfirst($vm_state[0]);
unset($vm_state);
$vmwVmCpus = $xml->vcpu['current'];
if (! isset($vmwVmCpus)) {

View File

@@ -11,11 +11,11 @@ if (getidbyname($vm['vmwVmDisplayName'])) {
echo '</td>';
if ($vm['vmwVmState'] == 'powered off') {
if ($vm['vmwVmState'] == 'powered off' || $vm['vmwVmState'] == 'Shut off') {
echo '<td class="list"><span style="min-width:40px; display:inline-block;" class="label label-default">OFF</span></td>';
} elseif ($vm['vmwVmState'] == 'powered on') {
} elseif ($vm['vmwVmState'] == 'powered on' || $vm['vmwVmState'] == 'Running') {
echo '<td class="list"><span style="min-width:40px; display:inline-block;" class="label label-success">ON</span></td>';
} elseif ($vm['vmwVmState'] == 'suspended') {
} elseif ($vm['vmwVmState'] == 'suspended' || $vm['vmwVmState'] == 'Paused') {
echo '<td class="list"><span style="min-width:40px; display:inline-block;" class="label label-warning">SUSPEND</span></td>';
}