vmmngr 0.1.0-preview: read-only VM Manager extension (installer, vmm-ctl, GUI)

This commit is contained in:
Claw committed 2026-11-17 19:16:16 +01:00
commit 5f664cc8c2
14 files changed
+1422

No files matched your search

+104
View File
@@ -0,0 +1,104 @@
<?php
/*
* vmmngr_vm.php - VM detail view (read-only preview 0.1.0)
*/
require_once 'vmmngr-boot.inc';
$name = (string)($_GET['name'] ?? '');
if ($name === '' || !vmm_valid_name($name)) {
header('Location: vmmngr.php');
exit;
}
$info = vmm_info($name);
$pgtitle = [gettext('Extensions'), gettext('VM Manager'), $name];
include 'fbegin.inc';
?>
<style>
.vmm-badge{display:inline-block;padding:1px 8px;border-radius:10px;font-size:11px;font-weight:600}
.vmm-running{background:#153e2b;color:#5ee79b;border:1px solid #2f7d54}
.vmm-stopped{background:#3a2c2c;color:#e0a0a0;border:1px solid #7d4a4a}
.vmm-suspended,.vmm-starting{background:#3a3320;color:#e8cf7a;border:1px solid #7d6a2f}
.vmm-unknown,.vmm-locked{background:#2c2c3a;color:#a9a9d0;border:1px solid #4a4a7d}
.vmm-mono{font-family:monospace;font-size:12px}
.vmm-raw{background:#1b1f23;border:1px solid #333a41;border-radius:4px;padding:10px;overflow:auto;max-height:420px}
</style>
<form action="vmmngr_vm.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
<?php if (isset($info['error'])): ?>
<?php print_info_box(sprintf(gettext('Could not read VM details: %s'), vmm_h((string)$info['error']))); ?>
<?php else: ?>
<?php
$g = $info['general'] ?? [];
$state = vmm_state_from_string((string)($g['state'] ?? ''));
?>
<table class="area_data_settings" style="width:100%;border-collapse:collapse;">
<colgroup>
<col class="area_data_settings_col_tag">
<col class="area_data_settings_col_data">
</colgroup>
<thead>
<?php
html_separator2();
html_titleline2(sprintf('%s: %s', gettext('Virtual Machine'), $name), 2);
?>
</thead>
<tbody>
<tr><td class="celltag"><?=gettext('State');?></td><td class="celldata"><?=vmm_badge($state['state']);?> <?php if ($state['pid']): ?><span class="vmm-mono">PID <?=$state['pid'];?></span><?php endif; ?></td></tr>
<tr><td class="celltag"><?=gettext('Loader');?></td><td class="celldata"><?=vmm_h((string)($g['loader'] ?? ''));?></td></tr>
<tr><td class="celltag"><?=gettext('vCPU / Memory');?></td><td class="celldata"><?=vmm_h((string)($g['cpu'] ?? ''));?> vCPU · <?=vmm_h((string)($g['memory'] ?? ''));?><?php if (!empty($g['memory-resident'])): ?> <span class="vmm-mono">(<?=vmm_h((string)$g['memory-resident']);?>)</span><?php endif; ?></td></tr>
<tr><td class="celltag"><?=gettext('Datastore');?></td><td class="celldata"><?=vmm_h((string)($g['datastore'] ?? ''));?></td></tr>
<tr><td class="celltag">UUID</td><td class="celldata vmm-mono"><?=vmm_h((string)($g['uuid'] ?? ''));?></td></tr>
</tbody>
</table>
<br />
<?php foreach (($info['sections'] ?? []) as $type => $blocks): ?>
<table class="area_data_settings" style="width:100%;border-collapse:collapse;">
<colgroup>
<col class="area_data_settings_col_tag">
<col class="area_data_settings_col_data">
</colgroup>
<thead>
<?php html_separator2(); html_titleline2(vmm_h(ucwords(str_replace('-', ' ', $type))), 2); ?>
</thead>
<tbody>
<?php foreach ($blocks as $b): ?>
<?php foreach ($b['data'] as $k => $v): ?>
<tr>
<td class="celltag"><?=vmm_h((string)$k);?></td>
<td class="celldata vmm-mono"><?=vmm_h((string)$v);?></td>
</tr>
<?php endforeach; ?>
<?php foreach ($b['lines'] as $line): ?>
<tr>
<td class="celltag">—</td>
<td class="celldata vmm-mono"><?=vmm_h((string)$line);?></td>
</tr>
<?php endforeach; ?>
<?php if ($b['data'] === [] && $b['lines'] === []): ?>
<tr><td class="celltag">—</td><td class="celldata"><?=gettext('none');?></td></tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
<br />
<?php endforeach; ?>
<details>
<summary style="cursor:pointer;padding:6px 0;"><?=gettext('Raw vm-bhyve output');?></summary>
<pre class="vmm-raw vmm-mono"><?=vmm_h((string)($info['raw'] ?? ''));?></pre>
</details>
<?php endif; ?>
<div id="remarks">
<?php html_remark2('preview', gettext('Read-only'), gettext('Actions are intentionally not wired yet. This page shows exactly what vm-bhyve reports.')); ?>
</div>
</td></tr></tbody></table></form>
<?php include 'fend.inc'; ?>