0.2.0: job engine, VM actions, theme-aware styling
This commit is contained in:
1 parent
c62de24cc0
commit
485a267ffe
14 files changed
+901
-71
No files matched your search
@@ -1,13 +1,13 @@
|
|||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
## GUI / Styling
|
## Erledigt
|
||||||
- [ ] **Kontrast/Farben (von Matthias, 19:18):** dunkle Grautöne verdecken Info-Text.
|
- [x] **Kontrast/Farben** (19:18): Karten/Badges/`<pre>` nutzen jetzt Theme-Variablen
|
||||||
Ursache: Karten/badges/`<pre>` nutzen hartkodierte Hex-Farben statt Theme-Variablen.
|
(`--bgc-area-data`, `--bgc-input-ro`, currentColor) statt harter Hex-Werte.
|
||||||
Fix: XigmaNAS-Theme-CSS-Variablen erben, heller Verlauf, Badges mit Theme-Rahmen;
|
- [x] **M2**: Start/Stop/Restart/Reset/Poweroff/Destroy + Job-Engine
|
||||||
Lesbarkeit in Light+Dark prüfen. -> M2, vor den Aktions-Buttons.
|
(flock pro VM, Logs, Recovery, RAM-Budget 85 %, Destroy mit eingetipptem Namen).
|
||||||
|
|
||||||
## Funktion
|
## Offen
|
||||||
- [ ] M2: Start/Stop/Restart/Reset/Destroy + Job-Engine (flock, Logs, Recovery)
|
|
||||||
- [ ] M3: Create-Wizard, Images (ISO/IMG/Cloud-Init), Datastores
|
- [ ] M3: Create-Wizard, Images (ISO/IMG/Cloud-Init), Datastores
|
||||||
- [ ] M4: Templates-CRUD, Switches, Snapshots/Clone/Rename, Autostart
|
- [ ] M4: Templates-CRUD, Switches, Snapshots/Clone/Rename, Autostart
|
||||||
- [ ] M5: Konsole (ttyd), VNC, Passthru-Gate, OBI-Eintrag, Doku
|
- [ ] M5: Konsole (ttyd), VNC, Passthru-Gate, OBI-Eintrag, Doku
|
||||||
|
- [ ] Nice-to-have: Job-Liste filtern, Fortschritt bei Downloads
|
||||||
+69
@@ -122,6 +122,75 @@ switch ($cmd) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
case 'action':
|
||||||
|
$verb = $argv[1] ?? '';
|
||||||
|
$name = $argv[2] ?? '';
|
||||||
|
$confirm = '';
|
||||||
|
foreach ($argv as $a) {
|
||||||
|
if (str_starts_with($a, '--confirm=')) {
|
||||||
|
$confirm = substr($a, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$check = vmm_action_check($verb, $name, $confirm);
|
||||||
|
if (!$check['ok']) {
|
||||||
|
if ($json) {
|
||||||
|
vmm_json(['ok' => false, 'error' => $check['error']], 1);
|
||||||
|
}
|
||||||
|
fwrite(STDERR, 'refused: ' . $check['error'] . "\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
$job = vmm_job_new($verb, $name);
|
||||||
|
out(
|
||||||
|
['ok' => true, 'job' => $job],
|
||||||
|
$json,
|
||||||
|
static function (array $d): void {
|
||||||
|
printf("job %s queued: %s %s\n", $d['job']['id'], $d['job']['verb'], $d['job']['vm']);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'job':
|
||||||
|
$job = vmm_job_get($arg);
|
||||||
|
if ($job === null) {
|
||||||
|
if ($json) {
|
||||||
|
vmm_json(['ok' => false, 'error' => 'job not found'], 404);
|
||||||
|
}
|
||||||
|
fwrite(STDERR, "job not found\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
$job['log'] = vmm_job_log($arg);
|
||||||
|
out(
|
||||||
|
['ok' => true, 'job' => $job],
|
||||||
|
$json,
|
||||||
|
static function (array $d): void {
|
||||||
|
printf("job %s %s %s state=%s rc=%s\n", $d['job']['id'], $d['job']['verb'], $d['job']['vm'], $d['job']['state'], $d['job']['rc'] ?? '-');
|
||||||
|
echo $d['job']['log'];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'jobs':
|
||||||
|
$jobs = vmm_job_list(50, $arg);
|
||||||
|
out(
|
||||||
|
['ok' => true, 'jobs' => $jobs],
|
||||||
|
$json,
|
||||||
|
static function (array $d): void {
|
||||||
|
foreach ($d['jobs'] as $j) {
|
||||||
|
printf("%-32s %-8s %-8s %-10s rc=%s\n", $j['id'], $j['verb'], $j['vm'], $j['state'], $j['rc'] ?? '-');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'cancel':
|
||||||
|
$res = vmm_job_cancel($arg);
|
||||||
|
out($res, $json, static function (array $d): void {
|
||||||
|
echo $d['ok'] ? "cancel requested\n" : ('error: ' . $d['error'] . "\n");
|
||||||
|
});
|
||||||
|
|
||||||
|
case 'recover':
|
||||||
|
$fixed = vmm_job_recover();
|
||||||
|
out(['ok' => true, 'fixed' => $fixed], $json, static function (array $d): void {
|
||||||
|
printf("%d interrupted job(s) marked failed\n", $d['fixed']);
|
||||||
|
});
|
||||||
|
|
||||||
case 'json':
|
case 'json':
|
||||||
vmm_json(vmm_selfcheck());
|
vmm_json(vmm_selfcheck());
|
||||||
// no break
|
// no break
|
||||||
|
|||||||
+189
@@ -0,0 +1,189 @@
|
|||||||
|
#!/usr/local/bin/php
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* vmm-jobd - executes exactly one queued VM job, then exits.
|
||||||
|
*
|
||||||
|
* Started detached by vmm-ctl. Owns the per-VM lock while it runs, streams
|
||||||
|
* stdout/stderr into state/jobs/<id>.log and records the final state.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
require_once __DIR__ . '/vmm-lib.php';
|
||||||
|
|
||||||
|
$id = $argv[1] ?? '';
|
||||||
|
$job = vmm_job_get($id);
|
||||||
|
if ($job === null) {
|
||||||
|
fwrite(STDERR, "job not found: {$id}\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
$verb = (string)$job['verb'];
|
||||||
|
$name = (string)$job['vm'];
|
||||||
|
if (!isset(VMM_ACTIONS[$verb])) {
|
||||||
|
$job['state'] = 'failed';
|
||||||
|
$job['error'] = 'unknown verb';
|
||||||
|
$job['ended'] = time();
|
||||||
|
vmm_job_write($job);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
$logFile = VMM_JOBDIR . '/' . $id . '.log';
|
||||||
|
$log = fopen($logFile, 'ab');
|
||||||
|
if ($log === false) {
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function joblog($log, string $line): void
|
||||||
|
{
|
||||||
|
fwrite($log, '[' . date('H:i:s') . '] ' . $line . "\n");
|
||||||
|
fflush($log);
|
||||||
|
}
|
||||||
|
|
||||||
|
// one lock per VM (destroy/start/stop of the same guest never overlap)
|
||||||
|
vmm_ensure_state_dirs();
|
||||||
|
$lockPath = VMM_LOCKDIR . '/' . preg_replace('/[^A-Za-z0-9._-]/', '_', $name) . '.lock';
|
||||||
|
$lock = fopen($lockPath, 'c');
|
||||||
|
if ($lock === false || !flock($lock, LOCK_EX | LOCK_NB)) {
|
||||||
|
$job['state'] = 'failed';
|
||||||
|
$job['error'] = 'another job holds the lock for this vm';
|
||||||
|
$job['ended'] = time();
|
||||||
|
vmm_job_write($job);
|
||||||
|
joblog($log, 'lock busy: ' . $lockPath);
|
||||||
|
fclose($log);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
$job['state'] = 'running';
|
||||||
|
$job['pid'] = getmypid();
|
||||||
|
$job['started'] = time();
|
||||||
|
vmm_job_write($job);
|
||||||
|
|
||||||
|
$argvVm = array_merge(VMM_ACTIONS[$verb]['argv'], [$name]);
|
||||||
|
joblog($log, 'start: vm ' . implode(' ', $argvVm));
|
||||||
|
|
||||||
|
$vm = vmm_resolve('vm');
|
||||||
|
if (!$vm['available']) {
|
||||||
|
$job['state'] = 'failed';
|
||||||
|
$job['error'] = 'vm-bhyve not available';
|
||||||
|
$job['ended'] = time();
|
||||||
|
vmm_job_write($job);
|
||||||
|
joblog($log, 'fatal: vm-bhyve not available');
|
||||||
|
flock($lock, LOCK_UN);
|
||||||
|
fclose($lock);
|
||||||
|
fclose($log);
|
||||||
|
exit(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
$env = getenv() ?: [];
|
||||||
|
$env['LC_ALL'] = 'C';
|
||||||
|
$grub = vmm_resolve('grub');
|
||||||
|
if ($grub['source'] === 'bundle') {
|
||||||
|
$env['PATH'] = VMM_ROOT . '/vendor/grub2-bhyve:' . ($env['PATH'] ?? '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin');
|
||||||
|
}
|
||||||
|
|
||||||
|
$cmd = array_merge([$vm['path']], $argvVm);
|
||||||
|
$spec = [
|
||||||
|
0 => ['pipe', 'r'],
|
||||||
|
1 => ['pipe', 'w'],
|
||||||
|
2 => ['pipe', 'w'],
|
||||||
|
];
|
||||||
|
$proc = proc_open($cmd, $spec, $pipes, null, $env);
|
||||||
|
if (!is_resource($proc)) {
|
||||||
|
$job['state'] = 'failed';
|
||||||
|
$job['error'] = 'proc_open failed';
|
||||||
|
$job['ended'] = time();
|
||||||
|
vmm_job_write($job);
|
||||||
|
flock($lock, LOCK_UN);
|
||||||
|
fclose($lock);
|
||||||
|
fclose($log);
|
||||||
|
exit(5);
|
||||||
|
}
|
||||||
|
fclose($pipes[0]);
|
||||||
|
stream_set_blocking($pipes[1], false);
|
||||||
|
stream_set_blocking($pipes[2], false);
|
||||||
|
|
||||||
|
$timeout = (int)(VMM_ACTIONS[$verb]['timeout'] ?? 300);
|
||||||
|
$start = time();
|
||||||
|
$timedOut = false;
|
||||||
|
$cancelFile = VMM_JOBDIR . '/' . $id . '.cancel';
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
$status = proc_get_status($proc);
|
||||||
|
$out = (string)stream_get_contents($pipes[1]);
|
||||||
|
$err = (string)stream_get_contents($pipes[2]);
|
||||||
|
if ($out !== '') {
|
||||||
|
fwrite($log, $out);
|
||||||
|
fflush($log);
|
||||||
|
}
|
||||||
|
if ($err !== '') {
|
||||||
|
fwrite($log, $err);
|
||||||
|
fflush($log);
|
||||||
|
}
|
||||||
|
if (!$status['running']) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (is_file($cancelFile)) {
|
||||||
|
joblog($log, 'cancel requested, sending TERM');
|
||||||
|
proc_terminate($proc, 15);
|
||||||
|
usleep(300000);
|
||||||
|
if (proc_get_status($proc)['running']) {
|
||||||
|
proc_terminate($proc, 9);
|
||||||
|
}
|
||||||
|
@unlink($cancelFile);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (time() - $start > $timeout) {
|
||||||
|
$timedOut = true;
|
||||||
|
joblog($log, "timeout after {$timeout}s, sending TERM");
|
||||||
|
proc_terminate($proc, 15);
|
||||||
|
usleep(500000);
|
||||||
|
if (proc_get_status($proc)['running']) {
|
||||||
|
proc_terminate($proc, 9);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
usleep(200000);
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite($log, (string)stream_get_contents($pipes[1]));
|
||||||
|
fwrite($log, (string)stream_get_contents($pipes[2]));
|
||||||
|
fclose($pipes[1]);
|
||||||
|
fclose($pipes[2]);
|
||||||
|
$rc = proc_close($proc);
|
||||||
|
|
||||||
|
$stateAfter = vmm_vm_state($name);
|
||||||
|
|
||||||
|
// vm-bhyve often returns 0 even when it refused the operation, so the
|
||||||
|
// resulting state is what counts.
|
||||||
|
$expected = [
|
||||||
|
'start' => 'running',
|
||||||
|
'stop' => 'stopped',
|
||||||
|
'restart' => 'running',
|
||||||
|
'reset' => 'running',
|
||||||
|
'poweroff' => 'stopped',
|
||||||
|
'destroy' => 'absent',
|
||||||
|
][$verb] ?? '';
|
||||||
|
|
||||||
|
$job['rc'] = $rc;
|
||||||
|
$job['ended'] = time();
|
||||||
|
$job['state_after'] = $stateAfter;
|
||||||
|
if ($timedOut) {
|
||||||
|
$job['state'] = 'failed';
|
||||||
|
$job['error'] = 'timeout';
|
||||||
|
} elseif ($rc !== 0) {
|
||||||
|
$job['state'] = 'failed';
|
||||||
|
$job['error'] = 'vm exited with code ' . $rc;
|
||||||
|
} elseif ($expected !== '' && $stateAfter !== $expected) {
|
||||||
|
$job['state'] = 'failed';
|
||||||
|
$job['error'] = sprintf('unexpected state after %s: %s (expected %s)', $verb, $stateAfter, $expected);
|
||||||
|
} else {
|
||||||
|
$job['state'] = 'done';
|
||||||
|
}
|
||||||
|
vmm_job_write($job);
|
||||||
|
joblog($log, sprintf('finished: rc=%d, state=%s', $rc, $stateAfter));
|
||||||
|
|
||||||
|
flock($lock, LOCK_UN);
|
||||||
|
fclose($lock);
|
||||||
|
fclose($log);
|
||||||
|
exit(0);
|
||||||
+249
@@ -472,3 +472,252 @@ function vmm_json(array $data, int $code = 0): never
|
|||||||
echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* job engine */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
const VMM_JOBDIR = VMM_ROOT . '/state/jobs';
|
||||||
|
const VMM_LOCKDIR = VMM_ROOT . '/state/locks';
|
||||||
|
const VMM_ACTIONS = [
|
||||||
|
'start' => ['argv' => ['start'], 'timeout' => 300, 'needs' => 'stopped'],
|
||||||
|
'stop' => ['argv' => ['stop'], 'timeout' => 180, 'needs' => 'running'],
|
||||||
|
'restart' => ['argv' => ['restart'], 'timeout' => 300, 'needs' => 'running'],
|
||||||
|
'reset' => ['argv' => ['reset', '-f'], 'timeout' => 120, 'needs' => 'running'],
|
||||||
|
'poweroff' => ['argv' => ['poweroff', '-f'], 'timeout' => 120, 'needs' => 'running'],
|
||||||
|
'destroy' => ['argv' => ['destroy', '-f'], 'timeout' => 300, 'needs' => 'stopped'],
|
||||||
|
];
|
||||||
|
|
||||||
|
function vmm_ensure_state_dirs(): void
|
||||||
|
{
|
||||||
|
foreach ([VMM_JOBDIR, VMM_LOCKDIR] as $d) {
|
||||||
|
if (!is_dir($d)) {
|
||||||
|
@mkdir($d, 0750, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_vm_state(string $name): string
|
||||||
|
{
|
||||||
|
foreach (vmm_list() as $v) {
|
||||||
|
if (($v['name'] ?? '') === $name) {
|
||||||
|
return (string)$v['state'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'absent';
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_ram_budget(): array
|
||||||
|
{
|
||||||
|
$conf = vmm_config();
|
||||||
|
$limitPct = (int)($conf['ram_budget_pct'] ?? 85);
|
||||||
|
$total = 0;
|
||||||
|
$out = trim((string)@shell_exec('/sbin/sysctl -n hw.physmem 2>/dev/null'));
|
||||||
|
if ($out !== '' && ctype_digit($out)) {
|
||||||
|
$total = (int)$out;
|
||||||
|
}
|
||||||
|
if ($total <= 0) {
|
||||||
|
$total = 8 * 1024 ** 3;
|
||||||
|
}
|
||||||
|
return ['total' => $total, 'limit' => (int)($total * $limitPct / 100), 'pct' => $limitPct];
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_ram_used(): int
|
||||||
|
{
|
||||||
|
$used = 0;
|
||||||
|
foreach (vmm_list() as $v) {
|
||||||
|
if (($v['state'] ?? '') === 'running') {
|
||||||
|
$used += vmm_size_to_bytes((string)($v['memory'] ?? '0'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $used;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_action_check(string $verb, string $name, string $confirm = ''): array
|
||||||
|
{
|
||||||
|
if (!isset(VMM_ACTIONS[$verb])) {
|
||||||
|
return ['ok' => false, 'error' => 'unknown action'];
|
||||||
|
}
|
||||||
|
if (!vmm_valid_name($name)) {
|
||||||
|
return ['ok' => false, 'error' => 'invalid vm name'];
|
||||||
|
}
|
||||||
|
$state = vmm_vm_state($name);
|
||||||
|
if ($state === 'absent') {
|
||||||
|
return ['ok' => false, 'error' => 'vm not found'];
|
||||||
|
}
|
||||||
|
$needs = VMM_ACTIONS[$verb]['needs'];
|
||||||
|
if ($needs === 'running' && $state !== 'running') {
|
||||||
|
return ['ok' => false, 'error' => "vm is {$state}, not running"];
|
||||||
|
}
|
||||||
|
if ($needs === 'stopped' && $state === 'running') {
|
||||||
|
return ['ok' => false, 'error' => 'vm is running; stop it first'];
|
||||||
|
}
|
||||||
|
if ($verb === 'start') {
|
||||||
|
$budget = vmm_ram_budget();
|
||||||
|
$used = vmm_ram_used();
|
||||||
|
$need = 0;
|
||||||
|
foreach (vmm_list() as $v) {
|
||||||
|
if (($v['name'] ?? '') === $name) {
|
||||||
|
$need = vmm_size_to_bytes((string)($v['memory'] ?? '0'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($need > 0 && $used + $need > $budget['limit']) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'error' => sprintf(
|
||||||
|
'RAM budget: %s in use + %s requested exceeds limit of %s (%d%%)',
|
||||||
|
vmm_human_bytes($used),
|
||||||
|
vmm_human_bytes($need),
|
||||||
|
vmm_human_bytes($budget['limit']),
|
||||||
|
$budget['pct']
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($verb === 'destroy') {
|
||||||
|
if ($confirm !== $name) {
|
||||||
|
return ['ok' => false, 'error' => 'confirmation mismatch: type the vm name exactly'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ['ok' => true, 'state' => $state];
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_job_path(string $id): string
|
||||||
|
{
|
||||||
|
return VMM_JOBDIR . '/' . $id . '.json';
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_job_write(array $job): void
|
||||||
|
{
|
||||||
|
$job['updated'] = time();
|
||||||
|
$tmp = vmm_job_path($job['id']) . '.tmp';
|
||||||
|
file_put_contents($tmp, json_encode($job, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||||
|
rename($tmp, vmm_job_path($job['id']));
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_job_get(string $id): ?array
|
||||||
|
{
|
||||||
|
if (!preg_match('/^[0-9]{8}-[0-9]{6}-[a-f0-9]{8}$/', $id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$f = vmm_job_path($id);
|
||||||
|
if (!is_file($f)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$job = json_decode((string)file_get_contents($f), true);
|
||||||
|
return is_array($job) ? $job : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_job_list(int $limit = 50, string $vm = ''): array
|
||||||
|
{
|
||||||
|
$files = glob(VMM_JOBDIR . '/*.json') ?: [];
|
||||||
|
rsort($files);
|
||||||
|
$out = [];
|
||||||
|
foreach ($files as $f) {
|
||||||
|
$job = json_decode((string)file_get_contents($f), true);
|
||||||
|
if (!is_array($job)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($vm !== '' && ($job['vm'] ?? '') !== $vm) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$out[] = $job;
|
||||||
|
if (count($out) >= $limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_job_log(string $id, int $maxBytes = 65536): string
|
||||||
|
{
|
||||||
|
$f = VMM_JOBDIR . '/' . $id . '.log';
|
||||||
|
if (!is_file($f)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$size = filesize($f);
|
||||||
|
if ($size <= $maxBytes) {
|
||||||
|
return (string)file_get_contents($f);
|
||||||
|
}
|
||||||
|
$fh = fopen($f, 'rb');
|
||||||
|
fseek($fh, $maxBytes * -1, SEEK_END);
|
||||||
|
$data = (string)stream_get_contents($fh);
|
||||||
|
fclose($fh);
|
||||||
|
return "... (truncated)\n" . $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_job_new(string $verb, string $name): array
|
||||||
|
{
|
||||||
|
vmm_ensure_state_dirs();
|
||||||
|
$id = date('Ymd-His') . '-' . bin2hex(random_bytes(4));
|
||||||
|
$job = [
|
||||||
|
'id' => $id,
|
||||||
|
'verb' => $verb,
|
||||||
|
'vm' => $name,
|
||||||
|
'state' => 'queued',
|
||||||
|
'created' => time(),
|
||||||
|
'started' => null,
|
||||||
|
'ended' => null,
|
||||||
|
'pid' => null,
|
||||||
|
'rc' => null,
|
||||||
|
'error' => '',
|
||||||
|
'by' => (string)($_SERVER['REMOTE_ADDR'] ?? 'cli'),
|
||||||
|
];
|
||||||
|
vmm_job_write($job);
|
||||||
|
@touch(VMM_JOBDIR . '/' . $id . '.log');
|
||||||
|
|
||||||
|
$php = PHP_BINARY !== '' ? PHP_BINARY : '/usr/local/bin/php';
|
||||||
|
$cmd = sprintf(
|
||||||
|
'/usr/bin/nohup %s %s %s > /dev/null 2>&1 &',
|
||||||
|
escapeshellarg($php),
|
||||||
|
escapeshellarg(VMM_ROOT . '/bin/vmm-jobd'),
|
||||||
|
escapeshellarg($id)
|
||||||
|
);
|
||||||
|
exec($cmd);
|
||||||
|
return $job;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_job_recover(): int
|
||||||
|
{
|
||||||
|
$fixed = 0;
|
||||||
|
foreach (vmm_job_list(200) as $job) {
|
||||||
|
if (($job['state'] ?? '') !== 'running') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$pid = (int)($job['pid'] ?? 0);
|
||||||
|
$alive = vmm_pid_alive($pid);
|
||||||
|
if (!$alive) {
|
||||||
|
$job['state'] = 'failed';
|
||||||
|
$job['error'] = 'interrupted (process gone)';
|
||||||
|
$job['ended'] = time();
|
||||||
|
vmm_job_write($job);
|
||||||
|
$fixed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_pid_alive(int $pid): bool
|
||||||
|
{
|
||||||
|
if ($pid <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (function_exists('posix_kill')) {
|
||||||
|
return @posix_kill($pid, 0);
|
||||||
|
}
|
||||||
|
exec('/bin/kill -0 ' . $pid . ' > /dev/null 2>&1', $o, $rc);
|
||||||
|
return $rc === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vmm_job_cancel(string $id): array
|
||||||
|
{
|
||||||
|
$job = vmm_job_get($id);
|
||||||
|
if ($job === null) {
|
||||||
|
return ['ok' => false, 'error' => 'job not found'];
|
||||||
|
}
|
||||||
|
if (!in_array($job['state'], ['queued', 'running'], true)) {
|
||||||
|
return ['ok' => false, 'error' => 'job already finished'];
|
||||||
|
}
|
||||||
|
@touch(VMM_JOBDIR . '/' . $id . '.cancel');
|
||||||
|
return ['ok' => true, 'id' => $id];
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"appname": "VM Manager",
|
"appname": "VM Manager",
|
||||||
"version": "0.1.0-preview",
|
"version": "0.2.0",
|
||||||
"rootfolder": "/mnt/Daten/extensions/vmmngr",
|
"rootfolder": "/mnt/Daten/extensions/vmmngr",
|
||||||
"vm_source": "auto",
|
"vm_source": "auto",
|
||||||
"bridges": ["ix0bridge"],
|
"bridges": ["ix0bridge"],
|
||||||
"default_bridge": "ix0bridge",
|
"default_bridge": "ix0bridge",
|
||||||
"enable": true,
|
"enable": true,
|
||||||
"job_timeout": 900
|
"job_timeout": 900,
|
||||||
|
"ram_budget_pct": 85
|
||||||
}
|
}
|
||||||
@@ -42,3 +42,36 @@ if (!function_exists('vmm_badge')) {
|
|||||||
return sprintf('%s %s', $icon, $p['source']);
|
return sprintf('%s %s', $icon, $p['source']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('vmm_css')) {
|
||||||
|
/**
|
||||||
|
* Theme-aware styles: no hardcoded dark panels — colours derive from the
|
||||||
|
* XigmaNAS theme variables, so light and dark themes both stay readable.
|
||||||
|
*/
|
||||||
|
function vmm_css(): void
|
||||||
|
{
|
||||||
|
?>
|
||||||
|
<style>
|
||||||
|
.vmm-badge{display:inline-block;padding:1px 8px;border-radius:10px;font-size:11px;font-weight:600;border:1px solid currentColor;background:transparent;white-space:nowrap}
|
||||||
|
.vmm-running{color:#2f9e63}
|
||||||
|
.vmm-stopped{color:#c25656}
|
||||||
|
.vmm-suspended,.vmm-starting{color:#b98a1f}
|
||||||
|
.vmm-unknown,.vmm-locked{color:#7d7dab}
|
||||||
|
.vmm-grid{display:flex;flex-wrap:wrap;gap:10px;margin:10px 0 14px}
|
||||||
|
.vmm-card{flex:1 1 160px;min-width:160px;padding:10px 12px;border:1px solid rgba(127,127,127,.35);border-radius:6px;background:var(--bgc-area-data,transparent);color:inherit}
|
||||||
|
.vmm-card .k{font-size:11px;text-transform:uppercase;letter-spacing:.05em;opacity:.7}
|
||||||
|
.vmm-card .v{font-size:20px;font-weight:600;margin-top:2px}
|
||||||
|
.vmm-card .s{font-size:11px;opacity:.75;margin-top:2px}
|
||||||
|
.vmm-mono{font-family:monospace;font-size:12px}
|
||||||
|
.vmm-raw{background:var(--bgc-input-ro,rgba(127,127,127,.08));color:inherit;border:1px solid rgba(127,127,127,.3);border-radius:4px;padding:10px;overflow:auto;max-height:340px;white-space:pre-wrap}
|
||||||
|
.vmm-actions{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
|
||||||
|
.vmm-job{display:none;margin:12px 0;border:1px solid rgba(127,127,127,.35);border-radius:6px;padding:10px;background:var(--bgc-area-data,transparent)}
|
||||||
|
.vmm-job-head{font-size:12px;margin-bottom:6px;opacity:.9}
|
||||||
|
.vmm-job-state{font-weight:600;margin-left:6px}
|
||||||
|
.vmm-ok{color:#2f9e63}
|
||||||
|
.vmm-err{color:#c25656}
|
||||||
|
</style>
|
||||||
|
<script src="vmmngr.js"></script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* vmmngr.js - minimal helpers for the VM Manager GUI.
|
||||||
|
* Mutations are POST-only against vmmngr_api.php; long tasks run as jobs.
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function post(data) {
|
||||||
|
return fetch('vmmngr_api.php', {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'same-origin',
|
||||||
|
headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'},
|
||||||
|
body: new URLSearchParams(data).toString()
|
||||||
|
}).then(function (r) { return r.json(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
function poll(id, box) {
|
||||||
|
var head = box.querySelector('.vmm-job-head');
|
||||||
|
var stateEl = box.querySelector('.vmm-job-state');
|
||||||
|
var logEl = box.querySelector('pre');
|
||||||
|
var timer = setInterval(function () {
|
||||||
|
fetch('vmmngr_api.php?action=job&id=' + encodeURIComponent(id), {credentials: 'same-origin'})
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.then(function (d) {
|
||||||
|
if (!d.ok) { return; }
|
||||||
|
var j = d.job;
|
||||||
|
stateEl.textContent = j.state + (j.rc !== null && j.rc !== undefined ? ' (rc ' + j.rc + ')' : '');
|
||||||
|
stateEl.className = 'vmm-job-state ' + (j.state === 'failed' ? 'vmm-err' : 'vmm-ok');
|
||||||
|
logEl.textContent = j.log || '';
|
||||||
|
logEl.scrollTop = logEl.scrollHeight;
|
||||||
|
if (j.state === 'done' || j.state === 'failed' || j.state === 'canceled') {
|
||||||
|
clearInterval(timer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.vmmTrack = function (id) {
|
||||||
|
var box = document.getElementById('vmm-job');
|
||||||
|
if (!box) { return; }
|
||||||
|
box.style.display = 'block';
|
||||||
|
box.innerHTML = '<div class="vmm-job-head">Job <span class="vmm-mono">' + id + '</span><span class="vmm-job-state">queued</span></div><pre class="vmm-raw"></pre>';
|
||||||
|
poll(id, box);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.vmmRun = function (verb, vm, confirmText) {
|
||||||
|
var payload = {action: 'action', verb: verb, vm: vm};
|
||||||
|
if (confirmText !== undefined && confirmText !== null) {
|
||||||
|
payload.confirm = confirmText;
|
||||||
|
}
|
||||||
|
post(payload).then(function (d) {
|
||||||
|
if (!d.ok) {
|
||||||
|
alert(d.error || 'action refused');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vmmTrack(d.job.id);
|
||||||
|
}).catch(function (e) {
|
||||||
|
alert('request failed: ' + e);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
window.vmmConfirmRun = function (verb, vm, question) {
|
||||||
|
if (!window.confirm(question)) { return; }
|
||||||
|
vmmRun(verb, vm);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.vmmDestroy = function (vm) {
|
||||||
|
if (!window.confirm('Destroy ' + vm + '?\n\nAll disks and snapshots of this VM are deleted. This cannot be undone.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var typed = window.prompt('Type the VM name to confirm:', '');
|
||||||
|
if (typed === null) { return; }
|
||||||
|
if (typed !== vm) {
|
||||||
|
alert('Name does not match - nothing was done.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vmmRun('destroy', vm, typed);
|
||||||
|
};
|
||||||
|
})();
|
||||||
+75
-30
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* vmmngr.php - VM Manager dashboard (read-only preview 0.1.0)
|
* vmmngr.php - VM Manager dashboard (0.2.0: actions via job engine)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once 'vmmngr-boot.inc';
|
require_once 'vmmngr-boot.inc';
|
||||||
@@ -11,6 +11,7 @@ $vmprov = vmm_resolve('vm');
|
|||||||
$vms = $vmprov['available'] ? vmm_list() : [];
|
$vms = $vmprov['available'] ? vmm_list() : [];
|
||||||
$ver = $vmprov['available'] ? vmm_vm_version() : ['version' => '', 'rev' => ''];
|
$ver = $vmprov['available'] ? vmm_vm_version() : ['version' => '', 'rev' => ''];
|
||||||
$vm_dir = $vmprov['available'] ? vmm_vm_dir() : '';
|
$vm_dir = $vmprov['available'] ? vmm_vm_dir() : '';
|
||||||
|
$budget = vmm_ram_budget();
|
||||||
|
|
||||||
$running = array_values(array_filter($vms, static fn(array $v): bool => ($v['state'] ?? '') === 'running'));
|
$running = array_values(array_filter($vms, static fn(array $v): bool => ($v['state'] ?? '') === 'running'));
|
||||||
$mem_used = 0;
|
$mem_used = 0;
|
||||||
@@ -19,27 +20,17 @@ foreach ($running as $v) {
|
|||||||
$mem_used += vmm_size_to_bytes((string)($v['memory'] ?? '0'));
|
$mem_used += vmm_size_to_bytes((string)($v['memory'] ?? '0'));
|
||||||
$cpus += (int)($v['cpu'] ?? 0);
|
$cpus += (int)($v['cpu'] ?? 0);
|
||||||
}
|
}
|
||||||
|
vmm_job_recover();
|
||||||
|
$jobs = vmm_job_list(5);
|
||||||
|
|
||||||
include 'fbegin.inc';
|
include 'fbegin.inc';
|
||||||
|
vmm_css();
|
||||||
?>
|
?>
|
||||||
<style>
|
|
||||||
.vmm-badge{display:inline-block;padding:1px 8px;border-radius:10px;font-size:11px;font-weight:600;letter-spacing:.02em}
|
|
||||||
.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-grid{display:flex;flex-wrap:wrap;gap:10px;margin:10px 0 14px}
|
|
||||||
.vmm-card{flex:1 1 150px;min-width:150px;padding:10px 12px;border:1px solid #3a3f46;border-radius:6px;background:#23272c}
|
|
||||||
.vmm-card .k{font-size:11px;text-transform:uppercase;letter-spacing:.05em;opacity:.65}
|
|
||||||
.vmm-card .v{font-size:20px;font-weight:600;margin-top:2px}
|
|
||||||
.vmm-card .s{font-size:11px;opacity:.7;margin-top:2px}
|
|
||||||
.vmm-mono{font-family:monospace;font-size:12px}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<form action="vmmngr.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
<form action="vmmngr.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||||
|
|
||||||
<?php if (!$vmprov['available']): ?>
|
<?php if (!$vmprov['available']): ?>
|
||||||
<?php print_info_box(sprintf(gettext('vm-bhyve was not found. Neither %s nor the bundled copy exists.'), '/usr/local/sbin/vm') . '<br />' . gettext('Install vm-bhyve or run the installer with a bundled vendor tree.')); ?>
|
<?php print_info_box(sprintf(gettext('vm-bhyve was not found. Neither %s nor the bundled copy exists.'), '/usr/local/sbin/vm')); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="vmm-grid">
|
<div class="vmm-grid">
|
||||||
@@ -51,7 +42,7 @@ include 'fbegin.inc';
|
|||||||
<div class="vmm-card">
|
<div class="vmm-card">
|
||||||
<div class="k"><?=gettext('Assigned Memory');?></div>
|
<div class="k"><?=gettext('Assigned Memory');?></div>
|
||||||
<div class="v"><?=vmm_human_bytes($mem_used);?></div>
|
<div class="v"><?=vmm_human_bytes($mem_used);?></div>
|
||||||
<div class="s"><?=$cpus;?> vCPU</div>
|
<div class="s"><?=$cpus;?> vCPU · <?=gettext('budget');?> <?=vmm_human_bytes($budget['limit']);?> (<?=$budget['pct'];?>%)</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="vmm-card">
|
<div class="vmm-card">
|
||||||
<div class="k"><?=gettext('vm-bhyve');?></div>
|
<div class="k"><?=gettext('vm-bhyve');?></div>
|
||||||
@@ -65,16 +56,18 @@ include 'fbegin.inc';
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="vmm-job" class="vmm-job"></div>
|
||||||
|
|
||||||
<table class="area_data_selection" style="width:100%;table-layout:fixed;border-collapse:collapse;">
|
<table class="area_data_selection" style="width:100%;table-layout:fixed;border-collapse:collapse;">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width:20%">
|
<col style="width:16%">
|
||||||
|
<col style="width:11%">
|
||||||
|
<col style="width:8%">
|
||||||
|
<col style="width:6%">
|
||||||
|
<col style="width:8%">
|
||||||
<col style="width:12%">
|
<col style="width:12%">
|
||||||
<col style="width:9%">
|
<col style="width:6%">
|
||||||
<col style="width:7%">
|
<col style="width:33%">
|
||||||
<col style="width:9%">
|
|
||||||
<col style="width:18%">
|
|
||||||
<col style="width:7%">
|
|
||||||
<col style="width:18%">
|
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<?php
|
<?php
|
||||||
@@ -88,8 +81,8 @@ include 'fbegin.inc';
|
|||||||
<th class="lhell"><?=gettext('vCPU');?></th>
|
<th class="lhell"><?=gettext('vCPU');?></th>
|
||||||
<th class="lhell"><?=gettext('Memory');?></th>
|
<th class="lhell"><?=gettext('Memory');?></th>
|
||||||
<th class="lhell"><?=gettext('Datastore');?></th>
|
<th class="lhell"><?=gettext('Datastore');?></th>
|
||||||
<th class="lhell"><?=gettext('Autostart');?></th>
|
<th class="lhell"><?=gettext('Auto');?></th>
|
||||||
<th class="lhebl"><?=gettext('Details');?></th>
|
<th class="lhebl"><?=gettext('Actions');?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -97,8 +90,13 @@ include 'fbegin.inc';
|
|||||||
<tr><td class="lcell" colspan="8"><?=gettext('No virtual machines found.');?></td></tr>
|
<tr><td class="lcell" colspan="8"><?=gettext('No virtual machines found.');?></td></tr>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php foreach ($vms as $v): ?>
|
<?php foreach ($vms as $v): ?>
|
||||||
|
<?php
|
||||||
|
$n = (string)$v['name'];
|
||||||
|
$isRunning = ($v['state'] ?? '') === 'running';
|
||||||
|
$jsName = htmlspecialchars(json_encode($n), ENT_QUOTES);
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="lcell"><strong><?=vmm_h((string)$v['name']);?></strong></td>
|
<td class="lcell"><strong><?=vmm_h($n);?></strong></td>
|
||||||
<td class="lcell"><?=vmm_badge((string)$v['state']);?></td>
|
<td class="lcell"><?=vmm_badge((string)$v['state']);?></td>
|
||||||
<td class="lcell"><?=vmm_h((string)$v['loader']);?></td>
|
<td class="lcell"><?=vmm_h((string)$v['loader']);?></td>
|
||||||
<td class="lcell"><?=vmm_h((string)$v['cpu']);?></td>
|
<td class="lcell"><?=vmm_h((string)$v['cpu']);?></td>
|
||||||
@@ -106,7 +104,15 @@ include 'fbegin.inc';
|
|||||||
<td class="lcell"><?=vmm_h((string)$v['datastore']);?></td>
|
<td class="lcell"><?=vmm_h((string)$v['datastore']);?></td>
|
||||||
<td class="lcell"><?=!empty($v['auto']) ? gettext('yes') : gettext('no');?></td>
|
<td class="lcell"><?=!empty($v['auto']) ? gettext('yes') : gettext('no');?></td>
|
||||||
<td class="lcebl">
|
<td class="lcebl">
|
||||||
<a class="formbtn" href="vmmngr_vm.php?name=<?=urlencode((string)$v['name']);?>"><?=gettext('Open');?></a>
|
<span class="vmm-actions">
|
||||||
|
<?php if ($isRunning): ?>
|
||||||
|
<input type="button" class="formbtn" value="<?=gettext('Stop');?>" onclick='vmmConfirmRun("stop", <?=$jsName;?>, "Stop <?=vmm_h($n);?>?")'/>
|
||||||
|
<input type="button" class="formbtn" value="<?=gettext('Restart');?>" onclick='vmmConfirmRun("restart", <?=$jsName;?>, "Restart <?=vmm_h($n);?>?")'/>
|
||||||
|
<?php else: ?>
|
||||||
|
<input type="button" class="formbtn" value="<?=gettext('Start');?>" onclick='vmmRun("start", <?=$jsName;?>)'/>
|
||||||
|
<?php endif; ?>
|
||||||
|
<a class="formbtn" href="vmmngr_vm.php?name=<?=urlencode($n);?>"><?=gettext('Details');?></a>
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@@ -114,12 +120,51 @@ include 'fbegin.inc';
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<table class="area_data_selection" style="width:100%;border-collapse:collapse;">
|
||||||
|
<colgroup>
|
||||||
|
<col style="width:26%">
|
||||||
|
<col style="width:10%">
|
||||||
|
<col style="width:14%">
|
||||||
|
<col style="width:10%">
|
||||||
|
<col style="width:40%">
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<?php html_separator2(); html_titleline2(gettext('Recent jobs'), 5); ?>
|
||||||
|
<tr>
|
||||||
|
<th class="lhell"><?=gettext('Job');?></th>
|
||||||
|
<th class="lhell"><?=gettext('Action');?></th>
|
||||||
|
<th class="lhell"><?=gettext('VM');?></th>
|
||||||
|
<th class="lhell"><?=gettext('State');?></th>
|
||||||
|
<th class="lhebl"><?=gettext('Started');?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php if ($jobs === []): ?>
|
||||||
|
<tr><td class="lcell" colspan="5"><?=gettext('No jobs yet.');?></td></tr>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($jobs as $j): ?>
|
||||||
|
<tr>
|
||||||
|
<td class="lcell vmm-mono"><a href="vmmngr_jobs.php?id=<?=urlencode((string)$j['id']);?>"><?=vmm_h((string)$j['id']);?></a></td>
|
||||||
|
<td class="lcell"><?=vmm_h((string)$j['verb']);?></td>
|
||||||
|
<td class="lcell"><?=vmm_h((string)$j['vm']);?></td>
|
||||||
|
<td class="lcell">
|
||||||
|
<span class="<?=($j['state'] ?? '') === 'failed' ? 'vmm-err' : 'vmm-ok';?>"><?=vmm_h((string)$j['state']);?></span>
|
||||||
|
</td>
|
||||||
|
<td class="lcebl vmm-mono"><?=!empty($j['started']) ? date('Y-m-d H:i:s', (int)$j['started']) : '—';?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div id="remarks">
|
<div id="remarks">
|
||||||
<?php
|
<?php
|
||||||
html_remark2(
|
html_remark2(
|
||||||
'preview',
|
'status',
|
||||||
gettext('Preview build'),
|
gettext('Status'),
|
||||||
gettext('This build is read-only on purpose: it lists and inspects the existing machines but does not start, stop or change anything. Actions, creation wizard, images and templates follow in the next milestone.')
|
gettext('0.2.0: start/stop/restart/reset/poweroff/destroy run as jobs. Every action is locked per VM and logged; long operations continue if you close the browser.')
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+44
-5
@@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* vmmngr_api.php - read-only JSON endpoint.
|
* vmmngr_api.php - JSON endpoint for the VM Manager GUI.
|
||||||
*
|
*
|
||||||
* GET/POST ?action=list|info|selfcheck
|
* GET ?action=list|info|selfcheck|job|jobs
|
||||||
* Every request requires an authenticated admin session (XigmaNAS auth.inc).
|
* POST ?action=action (verb, vm, confirm) - mutations are POST only
|
||||||
|
* POST ?action=cancel (id)
|
||||||
|
*
|
||||||
|
* Requires an authenticated XigmaNAS session with admin rights.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once 'vmmngr-boot.inc';
|
require_once 'vmmngr-boot.inc';
|
||||||
@@ -12,8 +15,11 @@ if (!session::is_admin()) {
|
|||||||
vmm_json(['ok' => false, 'error' => 'forbidden'], 403);
|
vmm_json(['ok' => false, 'error' => 'forbidden'], 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$method = strtoupper((string)($_SERVER['REQUEST_METHOD'] ?? 'GET'));
|
||||||
$action = (string)($_REQUEST['action'] ?? '');
|
$action = (string)($_REQUEST['action'] ?? '');
|
||||||
$name = (string)($_REQUEST['name'] ?? '');
|
$name = (string)($_REQUEST['vm'] ?? $_REQUEST['name'] ?? '');
|
||||||
|
$confirm = (string)($_REQUEST['confirm'] ?? '');
|
||||||
|
$id = (string)($_REQUEST['id'] ?? '');
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'list':
|
case 'list':
|
||||||
@@ -33,10 +39,43 @@ switch ($action) {
|
|||||||
// no break
|
// no break
|
||||||
|
|
||||||
case 'selfcheck':
|
case 'selfcheck':
|
||||||
case '':
|
|
||||||
vmm_json(['ok' => true, 'selfcheck' => vmm_selfcheck()]);
|
vmm_json(['ok' => true, 'selfcheck' => vmm_selfcheck()]);
|
||||||
// no break
|
// no break
|
||||||
|
|
||||||
|
case 'action':
|
||||||
|
if ($method !== 'POST') {
|
||||||
|
vmm_json(['ok' => false, 'error' => 'POST required'], 405);
|
||||||
|
}
|
||||||
|
$verb = (string)($_POST['verb'] ?? '');
|
||||||
|
$check = vmm_action_check($verb, $name, $confirm);
|
||||||
|
if (!$check['ok']) {
|
||||||
|
vmm_json(['ok' => false, 'error' => $check['error']], 409);
|
||||||
|
}
|
||||||
|
$job = vmm_job_new($verb, $name);
|
||||||
|
vmm_json(['ok' => true, 'job' => $job], 202);
|
||||||
|
// no break
|
||||||
|
|
||||||
|
case 'cancel':
|
||||||
|
if ($method !== 'POST') {
|
||||||
|
vmm_json(['ok' => false, 'error' => 'POST required'], 405);
|
||||||
|
}
|
||||||
|
$res = vmm_job_cancel($id);
|
||||||
|
vmm_json($res, $res['ok'] ? 200 : 409);
|
||||||
|
// no break
|
||||||
|
|
||||||
|
case 'job':
|
||||||
|
$job = vmm_job_get($id);
|
||||||
|
if ($job === null) {
|
||||||
|
vmm_json(['ok' => false, 'error' => 'job not found'], 404);
|
||||||
|
}
|
||||||
|
$job['log'] = vmm_job_log($id);
|
||||||
|
vmm_json(['ok' => true, 'job' => $job]);
|
||||||
|
// no break
|
||||||
|
|
||||||
|
case 'jobs':
|
||||||
|
vmm_json(['ok' => true, 'jobs' => vmm_job_list(30, $name)]);
|
||||||
|
// no break
|
||||||
|
|
||||||
default:
|
default:
|
||||||
vmm_json(['ok' => false, 'error' => 'unknown action'], 400);
|
vmm_json(['ok' => false, 'error' => 'unknown action'], 400);
|
||||||
}
|
}
|
||||||
@@ -11,12 +11,7 @@ $conf = vmm_config();
|
|||||||
|
|
||||||
include 'fbegin.inc';
|
include 'fbegin.inc';
|
||||||
?>
|
?>
|
||||||
<style>
|
<?php vmm_css(); ?>
|
||||||
.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}
|
|
||||||
.vmm-ok{color:#5ee79b}
|
|
||||||
.vmm-miss{color:#e0a0a0}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<form action="vmmngr_config.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
<form action="vmmngr_config.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||||
|
|
||||||
@@ -38,6 +33,8 @@ include 'fbegin.inc';
|
|||||||
nmdm: <span class="<?=$sc['kld']['nmdm'] === 'loaded' ? 'vmm-ok' : 'vmm-miss';?>"><?=vmm_h($sc['kld']['nmdm']);?></span>
|
nmdm: <span class="<?=$sc['kld']['nmdm'] === 'loaded' ? 'vmm-ok' : 'vmm-miss';?>"><?=vmm_h($sc['kld']['nmdm']);?></span>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td class="celltag"><?=gettext('Virtual machines');?></td><td class="celldata"><?=$sc['vm_count'];?> <?=gettext('total');?>, <?=$sc['vm_running'];?> <?=gettext('running');?></td></tr>
|
<tr><td class="celltag"><?=gettext('Virtual machines');?></td><td class="celldata"><?=$sc['vm_count'];?> <?=gettext('total');?>, <?=$sc['vm_running'];?> <?=gettext('running');?></td></tr>
|
||||||
|
<?php $b = vmm_ram_budget(); ?>
|
||||||
|
<tr><td class="celltag"><?=gettext('RAM budget');?></td><td class="celldata"><?=vmm_human_bytes(vmm_ram_used());?> <?=gettext('in use');?> · <?=gettext('limit');?> <?=vmm_human_bytes($b['limit']);?> (<?=$b['pct'];?>% <?=gettext('of');?> <?=vmm_human_bytes($b['total']);?>)</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* vmmngr_jobs.php - job history and log viewer (0.2.0)
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once 'vmmngr-boot.inc';
|
||||||
|
|
||||||
|
$pgtitle = [gettext('Extensions'), gettext('VM Manager'), gettext('Jobs')];
|
||||||
|
$id = (string)($_GET['id'] ?? '');
|
||||||
|
$job = $id !== '' ? vmm_job_get($id) : null;
|
||||||
|
$jobs = vmm_job_list(50);
|
||||||
|
|
||||||
|
include 'fbegin.inc';
|
||||||
|
vmm_css();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form action="vmmngr_jobs.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||||
|
|
||||||
|
<?php if ($job !== null): ?>
|
||||||
|
<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('Job'), $job['id']), 2); ?>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr><td class="celltag"><?=gettext('Action');?></td><td class="celldata"><?=vmm_h((string)$job['verb']);?></td></tr>
|
||||||
|
<tr><td class="celltag"><?=gettext('VM');?></td><td class="celldata"><a href="vmmngr_vm.php?name=<?=urlencode((string)$job['vm']);?>"><?=vmm_h((string)$job['vm']);?></a></td></tr>
|
||||||
|
<tr><td class="celltag"><?=gettext('State');?></td><td class="celldata"><span class="<?=($job['state'] ?? '') === 'failed' ? 'vmm-err' : 'vmm-ok';?>"><?=vmm_h((string)$job['state']);?></span><?php if ($job['error'] ?? ''): ?> — <?=vmm_h((string)$job['error']);?><?php endif; ?></td></tr>
|
||||||
|
<tr><td class="celltag"><?=gettext('Return code');?></td><td class="celldata vmm-mono"><?=vmm_h((string)($job['rc'] ?? '—'));?></td></tr>
|
||||||
|
<tr><td class="celltag"><?=gettext('Requested by');?></td><td class="celldata vmm-mono"><?=vmm_h((string)($job['by'] ?? ''));?></td></tr>
|
||||||
|
<tr><td class="celltag"><?=gettext('Timing');?></td><td class="celldata vmm-mono">
|
||||||
|
<?=!empty($job['created']) ? date('Y-m-d H:i:s', (int)$job['created']) : '—';?>
|
||||||
|
<?php if (!empty($job['started'])): ?> → <?=date('H:i:s', (int)$job['started']);?><?php endif; ?>
|
||||||
|
<?php if (!empty($job['ended'])): ?> → <?=date('H:i:s', (int)$job['ended']);?> (<?=(int)$job['ended'] - (int)($job['started'] ?? $job['ended']);?>s)<?php endif; ?>
|
||||||
|
</td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="celltag"><?=gettext('Log');?></td>
|
||||||
|
<td class="celldata">
|
||||||
|
<pre class="vmm-raw vmm-mono"><?=vmm_h(vmm_job_log((string)$job['id']));?></pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<br />
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<table class="area_data_selection" style="width:100%;border-collapse:collapse;">
|
||||||
|
<colgroup>
|
||||||
|
<col style="width:26%">
|
||||||
|
<col style="width:10%">
|
||||||
|
<col style="width:14%">
|
||||||
|
<col style="width:10%">
|
||||||
|
<col style="width:10%">
|
||||||
|
<col style="width:30%">
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<?php html_separator2(); html_titleline2(gettext('All jobs'), 6); ?>
|
||||||
|
<tr>
|
||||||
|
<th class="lhell"><?=gettext('Job');?></th>
|
||||||
|
<th class="lhell"><?=gettext('Action');?></th>
|
||||||
|
<th class="lhell"><?=gettext('VM');?></th>
|
||||||
|
<th class="lhell"><?=gettext('State');?></th>
|
||||||
|
<th class="lhell">RC</th>
|
||||||
|
<th class="lhebl"><?=gettext('Started');?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php if ($jobs === []): ?>
|
||||||
|
<tr><td class="lcell" colspan="6"><?=gettext('No jobs yet.');?></td></tr>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($jobs as $j): ?>
|
||||||
|
<tr>
|
||||||
|
<td class="lcell vmm-mono"><a href="vmmngr_jobs.php?id=<?=urlencode((string)$j['id']);?>"><?=vmm_h((string)$j['id']);?></a></td>
|
||||||
|
<td class="lcell"><?=vmm_h((string)$j['verb']);?></td>
|
||||||
|
<td class="lcell"><?=vmm_h((string)$j['vm']);?></td>
|
||||||
|
<td class="lcell"><span class="<?=($j['state'] ?? '') === 'failed' ? 'vmm-err' : 'vmm-ok';?>"><?=vmm_h((string)$j['state']);?></span></td>
|
||||||
|
<td class="lcell vmm-mono"><?=vmm_h((string)($j['rc'] ?? '—'));?></td>
|
||||||
|
<td class="lcebl vmm-mono"><?=!empty($j['started']) ? date('Y-m-d H:i:s', (int)$j['started']) : '—';?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</td></tr></tbody></table></form>
|
||||||
|
<?php include 'fend.inc'; ?>
|
||||||
+56
-16
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* vmmngr_vm.php - VM detail view (read-only preview 0.1.0)
|
* vmmngr_vm.php - VM detail view with actions (0.2.0)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once 'vmmngr-boot.inc';
|
require_once 'vmmngr-boot.inc';
|
||||||
@@ -13,18 +13,11 @@ if ($name === '' || !vmm_valid_name($name)) {
|
|||||||
|
|
||||||
$info = vmm_info($name);
|
$info = vmm_info($name);
|
||||||
$pgtitle = [gettext('Extensions'), gettext('VM Manager'), $name];
|
$pgtitle = [gettext('Extensions'), gettext('VM Manager'), $name];
|
||||||
|
$jobs = vmm_job_list(10, $name);
|
||||||
|
|
||||||
include 'fbegin.inc';
|
include 'fbegin.inc';
|
||||||
|
vmm_css();
|
||||||
?>
|
?>
|
||||||
<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">
|
<form action="vmmngr_vm.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||||
|
|
||||||
@@ -34,6 +27,8 @@ include 'fbegin.inc';
|
|||||||
<?php
|
<?php
|
||||||
$g = $info['general'] ?? [];
|
$g = $info['general'] ?? [];
|
||||||
$state = vmm_state_from_string((string)($g['state'] ?? ''));
|
$state = vmm_state_from_string((string)($g['state'] ?? ''));
|
||||||
|
$isRunning = $state['state'] === 'running';
|
||||||
|
$jsName = htmlspecialchars(json_encode($name), ENT_QUOTES);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<table class="area_data_settings" style="width:100%;border-collapse:collapse;">
|
<table class="area_data_settings" style="width:100%;border-collapse:collapse;">
|
||||||
@@ -53,10 +48,27 @@ include 'fbegin.inc';
|
|||||||
<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('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"><?=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>
|
<tr><td class="celltag">UUID</td><td class="celldata vmm-mono"><?=vmm_h((string)($g['uuid'] ?? ''));?></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="celltag"><?=gettext('Actions');?></td>
|
||||||
|
<td class="celldata">
|
||||||
|
<span class="vmm-actions">
|
||||||
|
<?php if ($isRunning): ?>
|
||||||
|
<input type="button" class="formbtn" value="<?=gettext('Stop');?>" onclick='vmmConfirmRun("stop", <?=$jsName;?>, "Stop <?=vmm_h($name);?>?")'/>
|
||||||
|
<input type="button" class="formbtn" value="<?=gettext('Restart');?>" onclick='vmmConfirmRun("restart", <?=$jsName;?>, "Restart <?=vmm_h($name);?>?")'/>
|
||||||
|
<input type="button" class="formbtn" value="<?=gettext('Power off');?>" onclick='vmmConfirmRun("poweroff", <?=$jsName;?>, "Force power off <?=vmm_h($name);?>? Unsaved data in the guest may be lost.")'/>
|
||||||
|
<input type="button" class="formbtn" value="<?=gettext('Reset');?>" onclick='vmmConfirmRun("reset", <?=$jsName;?>, "Hard reset <?=vmm_h($name);?>?")'/>
|
||||||
|
<?php else: ?>
|
||||||
|
<input type="button" class="formbtn" value="<?=gettext('Start');?>" onclick='vmmRun("start", <?=$jsName;?>)'/>
|
||||||
|
<input type="button" class="formbtn" value="<?=gettext('Destroy');?>" onclick='vmmDestroy(<?=$jsName;?>)'/>
|
||||||
|
<?php endif; ?>
|
||||||
|
<a class="formbtn" href="vmmngr.php"><?=gettext('Back');?></a>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br />
|
<div id="vmm-job" class="vmm-job"></div>
|
||||||
|
|
||||||
<?php foreach (($info['sections'] ?? []) as $type => $blocks): ?>
|
<?php foreach (($info['sections'] ?? []) as $type => $blocks): ?>
|
||||||
<table class="area_data_settings" style="width:100%;border-collapse:collapse;">
|
<table class="area_data_settings" style="width:100%;border-collapse:collapse;">
|
||||||
@@ -90,15 +102,43 @@ include 'fbegin.inc';
|
|||||||
<br />
|
<br />
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
<details>
|
<table class="area_data_selection" style="width:100%;border-collapse:collapse;">
|
||||||
|
<colgroup>
|
||||||
|
<col style="width:30%">
|
||||||
|
<col style="width:12%">
|
||||||
|
<col style="width:12%">
|
||||||
|
<col style="width:46%">
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<?php html_separator2(); html_titleline2(gettext('Jobs for this VM'), 4); ?>
|
||||||
|
<tr>
|
||||||
|
<th class="lhell"><?=gettext('Job');?></th>
|
||||||
|
<th class="lhell"><?=gettext('Action');?></th>
|
||||||
|
<th class="lhell"><?=gettext('State');?></th>
|
||||||
|
<th class="lhebl"><?=gettext('Started');?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php if ($jobs === []): ?>
|
||||||
|
<tr><td class="lcell" colspan="4"><?=gettext('No jobs yet.');?></td></tr>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($jobs as $j): ?>
|
||||||
|
<tr>
|
||||||
|
<td class="lcell vmm-mono"><a href="vmmngr_jobs.php?id=<?=urlencode((string)$j['id']);?>"><?=vmm_h((string)$j['id']);?></a></td>
|
||||||
|
<td class="lcell"><?=vmm_h((string)$j['verb']);?></td>
|
||||||
|
<td class="lcell"><span class="<?=($j['state'] ?? '') === 'failed' ? 'vmm-err' : 'vmm-ok';?>"><?=vmm_h((string)$j['state']);?></span></td>
|
||||||
|
<td class="lcebl vmm-mono"><?=!empty($j['started']) ? date('Y-m-d H:i:s', (int)$j['started']) : '—';?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<details style="margin-top:12px;">
|
||||||
<summary style="cursor:pointer;padding:6px 0;"><?=gettext('Raw vm-bhyve output');?></summary>
|
<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>
|
<pre class="vmm-raw vmm-mono"><?=vmm_h((string)($info['raw'] ?? ''));?></pre>
|
||||||
</details>
|
</details>
|
||||||
<?php endif; ?>
|
<?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>
|
</td></tr></tbody></table></form>
|
||||||
<?php include 'fend.inc'; ?>
|
<?php include 'fend.inc'; ?>
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
0.1.0-preview
|
0.2.0
|
||||||
@@ -68,7 +68,7 @@ preflight() {
|
|||||||
*livecd*|*liveusb*) fail "live media is not supported for extensions (platform: ${platform})" ;;
|
*livecd*|*liveusb*) fail "live media is not supported for extensions (platform: ${platform})" ;;
|
||||||
esac
|
esac
|
||||||
[ -d "${CWDIR}" ] || fail "install directory ${CWDIR} is missing"
|
[ -d "${CWDIR}" ] || fail "install directory ${CWDIR} is missing"
|
||||||
mkdir -p "${CWDIR}/state" "${CWDIR}/log" "${CWDIR}/backup" "${CWDIR}/templates"
|
mkdir -p "${CWDIR}/state/jobs" "${CWDIR}/state/locks" "${CWDIR}/log" "${CWDIR}/backup" "${CWDIR}/templates"
|
||||||
|
|
||||||
free_kb=$(df -k "${CWDIR}" | awk 'NR==2 {print $4}')
|
free_kb=$(df -k "${CWDIR}" | awk 'NR==2 {print $4}')
|
||||||
if [ -n "${free_kb}" ] && [ "${free_kb}" -lt 1048576 ]; then
|
if [ -n "${free_kb}" ] && [ "${free_kb}" -lt 1048576 ]; then
|
||||||
@@ -133,7 +133,7 @@ do_symlinks() {
|
|||||||
mkdir -p "${WWWEXT}"
|
mkdir -p "${WWWEXT}"
|
||||||
link_force "${CONFDIR}" "${WWWEXT}/${APPNAME}"
|
link_force "${CONFDIR}" "${WWWEXT}/${APPNAME}"
|
||||||
|
|
||||||
for f in "${CWDIR}"/gui/*.php "${CWDIR}"/gui/*.inc; do
|
for f in "${CWDIR}"/gui/*.php "${CWDIR}"/gui/*.inc "${CWDIR}"/gui/*.js "${CWDIR}"/gui/*.css; do
|
||||||
[ -e "${f}" ] || continue
|
[ -e "${f}" ] || continue
|
||||||
link_force "${f}" "${WWW}/$(basename "${f}")"
|
link_force "${f}" "${WWW}/$(basename "${f}")"
|
||||||
done
|
done
|
||||||
@@ -187,7 +187,7 @@ set_permissions() {
|
|||||||
find "${CWDIR}/bin" -type f -exec chmod 0555 {} \; 2>/dev/null
|
find "${CWDIR}/bin" -type f -exec chmod 0555 {} \; 2>/dev/null
|
||||||
find "${CWDIR}/gui" -type f \( -name '*.php' -o -name '*.inc' \) -exec chmod 0644 {} \; 2>/dev/null
|
find "${CWDIR}/gui" -type f \( -name '*.php' -o -name '*.inc' \) -exec chmod 0644 {} \; 2>/dev/null
|
||||||
find "${CWDIR}/gui" -type f \( -name '*.js' -o -name '*.css' \) -exec chmod 0644 {} \; 2>/dev/null
|
find "${CWDIR}/gui" -type f \( -name '*.js' -o -name '*.css' \) -exec chmod 0644 {} \; 2>/dev/null
|
||||||
chmod 0750 "${CWDIR}/state" "${CWDIR}/log" "${CWDIR}/backup" 2>/dev/null
|
chmod 0750 "${CWDIR}/state" "${CWDIR}/state/jobs" "${CWDIR}/state/locks" "${CWDIR}/log" "${CWDIR}/backup" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
selfcheck() {
|
selfcheck() {
|
||||||
@@ -264,7 +264,7 @@ cmd_remove() {
|
|||||||
fi
|
fi
|
||||||
banner "uninstall"
|
banner "uninstall"
|
||||||
rm -f "${WWWEXT}/${APPNAME}"
|
rm -f "${WWWEXT}/${APPNAME}"
|
||||||
for f in "${CWDIR}"/gui/*.php "${CWDIR}"/gui/*.inc; do
|
for f in "${CWDIR}"/gui/*.php "${CWDIR}"/gui/*.inc "${CWDIR}"/gui/*.js "${CWDIR}"/gui/*.css; do
|
||||||
[ -e "${f}" ] || continue
|
[ -e "${f}" ] || continue
|
||||||
lnk="${WWW}/$(basename "${f}")"
|
lnk="${WWW}/$(basename "${f}")"
|
||||||
if [ -L "${lnk}" ] && [ "$(readlink "${lnk}")" = "${f}" ]; then
|
if [ -L "${lnk}" ] && [ "$(readlink "${lnk}")" = "${f}" ]; then
|
||||||
|
|||||||
Reference in new issue
Block a user