$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'vms';
require_once "$docroot/webGui/include/Translations.php";
$user_prefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg';
$vms = $lv->get_domains();
if (empty($vms)) {
echo '
" : "' style='display:none'>");
echo "";
echo "";
echo "| ",_('Disk devices/Volume')," | ",_('Serial')," | ",_('Bus')," | ",_('Capacity')," | ",_('Allocation')," | Boot Order | ";
echo "";
/* Display VM disks */
foreach ($lv->get_disk_stats($res) as $arrDisk) {
$capacity = $lv->format_size($arrDisk['capacity'], 0);
$allocation = $lv->format_size($arrDisk['allocation'], 0);
$disk = $arrDisk['file'] ?? $arrDisk['partition'];
$dev = $arrDisk['device'];
$bus = $arrValidDiskBuses[$arrDisk['bus']] ?? 'VirtIO';
$boot= $arrDisk["boot order"];
$serial = $arrDisk["serial"];
if ($boot < 1) $boot = _('Not set');
$reallocation = trim(get_realvolume($disk));
if (!empty($reallocation)) $reallocationstr = "($reallocation)"; else $reallocationstr = "";
echo "| $disk $reallocationstr | $serial | $bus | ";
if ($state == 'shutoff') {
echo "";
echo " | ";
} else {
echo "$capacity | ";
}
echo "$allocation | $boot | ";
}
/* Display VM cdroms */
foreach ($cdroms as $arrCD) {
$tooltip = "";
$capacity = $lv->format_size($arrCD['capacity'], 0);
$allocation = $lv->format_size($arrCD['allocation'], 0);
if ($arrCD['spundown']) {$capacity = $allocation = "*"; $tooltip = "Drive spun down ISO volume is ".$arrCD['reallocation'];} else $tooltip = "ISO volume is ".$arrCD['reallocation'];
$disk = $arrCD['file'] ?? $arrCD['partition'] ?? "" ;
$dev = $arrCD['device'];
$bus = $arrValidDiskBuses[$arrCD['bus']] ?? 'VirtIO';
$boot = $arrCD["boot order"] ?? "" ;
if ($boot < 1) $boot = _('Not set');
if ($disk != "" ) {
$title = _('Eject CD Drive');
$changemedia = "changemedia(\"{$uuid}\",\"{$dev}\",\"{$bus}\", \"--eject\")";
echo "| $disk | | $bus | $capacity | $allocation | $boot | ";
} else {
$title = _('Insert CD');
$changemedia = "changemedia(\"{$uuid}\",\"{$dev}\",\"{$bus}\",\"--select\")";
$disk = _("No CD image inserted into drive");
echo "| $disk | | $bus | $capacity | $allocation | $boot | ";
}
}
echo "";
/* Display VM IP Addresses "execute":"guest-network-get-interfaces" --pretty */
echo "| ",_('Interfaces')." | | | ",_('Type')." | ",_('IP Address')," | ",_('Prefix')," | ";
echo "";
echo $ipliststr ;
echo "";
/* Display VM Snapshots */
if ($snapshots != null) {
$j = 0;
$steps = array();
foreach ($snapshots as $snap) {
if ($snap['parent'] == "" || $snap['parent'] == "Base") $j++;
$steps[$j] .= $snap['name'].';';
}
echo "| ",_('Snapshots')," | | ",_('Date/Time')," | ",_('Type (Method)')," | ",_('Parent')," | ",_('Memory')," | ";
echo "";
foreach ($steps as $stepsline) {
$snapshotlist = explode(";",$stepsline);
$tab = " ";
foreach ($snapshotlist as $snapshotitem) {
if ($snapshotitem == "") continue;
$snapshot = $snapshots[$snapshotitem] ;
$snapshotstate = _(ucfirst($snapshot["state"]))." ({$snapshot["method"]})";
$snapshotdesc = $snapshot["desc"];
$snapshotmemory = _(ucfirst($snapshot["memory"]["@attributes"]["snapshot"]));
$snapshotparent = $snapshot["parent"] ? $snapshot["parent"] : "None";
$snapshotdatetime = my_time($snapshot["creationtime"],"Y-m-d" )." ".my_time($snapshot["creationtime"],"H:i:s");
$snapmenu = sprintf("onclick=\"addVMSnapContext('%s','%s','%s','%s','%s','%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,$snapshot["name"],$snapshot["method"]);
echo "| $tab|__ ",$snapshot["name"]," | $snapshotdesc | $snapshotdatetime | $snapshotstate | $snapshotparent | $snapshotmemory | ";
$tab .=" ";
}
echo "";
}
}
echo " ";
}
echo "\0".implode($kvm);
?>
|