Skip to content

Commit

Permalink
Fixed display "Power Status" for libvirt vm's (#12283)
Browse files Browse the repository at this point in the history
* Update print-vm.inc.php

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

* Update libvirt-vminfo.inc.php
  • Loading branch information
DerTFL committed Nov 1, 2020
1 parent 134b110 commit 1374c56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion includes/discovery/libvirt-vminfo.inc.php
Expand Up @@ -74,7 +74,8 @@
// 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)) {
$vmwVmCpus = $xml->vcpu;
Expand Down
6 changes: 3 additions & 3 deletions includes/html/print-vm.inc.php
Expand Up @@ -11,11 +11,11 @@

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>';
}

Expand Down

0 comments on commit 1374c56

Please sign in to comment.