0.10.1: create wizard can pick/download an ISO and optionally start the guest right away

This commit is contained in:
Claw committed 2026-11-17 21:17:21 +01:00
1 parent fd2f0192c3
commit 9feb3fba86
4 files changed
+61 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"appname": "VM Manager",
"version": "0.10.0",
"version": "0.10.1",
"rootfolder": "/mnt/Daten/extensions/vmmngr",
"vm_source": "auto",
"bridges": ["ix0bridge"],
+39 -1
View File
@@ -12,6 +12,18 @@ $templates = vmm_file_list(vmm_data_dir('.templates'), ['conf']);
$datastores = vmm_datastores();
$switches = vmm_switches();
$images = vmm_file_list(vmm_data_dir('.img'), ['img']);
$isos = vmm_file_list(vmm_data_dir('.iso'), ['iso']);
if ($post && ($_POST['act'] ?? '') === 'download_iso') {
$url = trim((string)($_POST['iso_url'] ?? ''));
if (!preg_match('#^https?://[^\s"\'<>]+$#i', $url)) {
$err = gettext('Only http(s) URLs are allowed.');
} else {
$job = vmm_job_new('iso_download', basename((string)parse_url($url, PHP_URL_PATH)) ?: 'iso', ['iso', $url], 21600);
header('Location: ' . vmm_after_job_target((string)$job['id'], 'vmmngr_create.php'));
exit;
}
}
if ($post) {
$name = trim((string)($_POST['name'] ?? ''));
@@ -23,6 +35,8 @@ if ($post) {
$cloud = isset($_POST['cloudinit']);
$img = (string)($_POST['image'] ?? '');
$switch = trim((string)($_POST['switch'] ?? ''));
$iso = vmm_safe_basename((string)($_POST['iso'] ?? ''));
$autostart = isset($_POST['autostart']);
if (!vmm_valid_name($name)) {
$err = gettext('Invalid name: letters, digits, dot, dash, underscore (max 32).');
@@ -58,7 +72,14 @@ if ($post) {
$argv[] = $img;
}
$argv[] = $name;
$job = vmm_job_new('create', $name, $argv, 900, ['switch' => $switch]);
$meta = ['switch' => $switch];
if ($iso !== '' && str_ends_with(strtolower($iso), '.iso')) {
$meta['iso'] = vmm_data_dir('.iso') . '/' . $iso;
}
if ($autostart) {
$meta['autostart'] = '1';
}
$job = vmm_job_new('create', $name, $argv, 900, $meta);
header('Location: vmmngr_jobs.php?id=' . urlencode((string)$job['id']));
exit;
}
@@ -153,6 +174,23 @@ vmm_nav('create');
</select>
</td>
</tr>
<tr>
<td class="celltag"><?=gettext('Boot ISO');?></td>
<td class="celldata">
<select name="iso">
<option value=""><?=gettext('none (install later)');?></option>
<?php foreach ($isos as $i): ?>
<option value="<?=vmm_h((string)$i['name']);?>"><?=vmm_h((string)$i['name']);?></option>
<?php endforeach; ?>
</select>
<label style="margin-left:10px;"><input type="checkbox" name="autostart" value="1"/> <?=gettext('start right after create');?></label>
<div style="margin-top:8px;">
<input type="text" name="iso_url" size="52" placeholder="https://.../debian-13-netinst.iso"/>
<button type="submit" class="formbtn" name="act" value="download_iso"><?=gettext('Download ISO');?></button>
<a href="vmmngr_images.php" style="margin-left:8px;"><?=gettext('Images page');?></a>
</div>
</td>
</tr>
<tr>
<td class="celltag"><?=gettext('Summary');?></td>
<td class="celldata vmm-mono">