0.10.1: create wizard can pick/download an ISO and optionally start the guest right away
This commit is contained in:
1 parent
fd2f0192c3
commit
9feb3fba86
4 files changed
+61
-3
No files matched your search
@@ -190,6 +190,26 @@ if ($verb === 'create' && !empty($job['switch'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optional: attach the chosen ISO and boot right away
|
||||||
|
if ($verb === 'create' && $rc === 0 && empty($timedOut)) {
|
||||||
|
if (!empty($job['iso'])) {
|
||||||
|
$att = vmm_iso_attach($name, [(string)$job['iso']]);
|
||||||
|
if (isset($att['error'])) {
|
||||||
|
joblog($log, 'iso attach failed: ' . $att['error']);
|
||||||
|
} else {
|
||||||
|
joblog($log, 'iso attached: ' . basename((string)$job['iso']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($job['autostart']) && !empty($job['iso'])) {
|
||||||
|
joblog($log, 'starting guest');
|
||||||
|
$start = vmm_run(['start', $name], 180);
|
||||||
|
if ($start['stdout'] !== '') {
|
||||||
|
fwrite($log, $start['stdout']);
|
||||||
|
}
|
||||||
|
joblog($log, 'start rc=' . $start['rc']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// vm-bhyve often returns 0 even when it refused the operation, so the
|
// vm-bhyve often returns 0 even when it refused the operation, so the
|
||||||
// resulting state is what counts. Some states are transitional (a guest that
|
// resulting state is what counts. Some states are transitional (a guest that
|
||||||
// just booted reports "bootloader" for a moment), so wait a little.
|
// just booted reports "bootloader" for a moment), so wait a little.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"appname": "VM Manager",
|
"appname": "VM Manager",
|
||||||
"version": "0.10.0",
|
"version": "0.10.1",
|
||||||
"rootfolder": "/mnt/Daten/extensions/vmmngr",
|
"rootfolder": "/mnt/Daten/extensions/vmmngr",
|
||||||
"vm_source": "auto",
|
"vm_source": "auto",
|
||||||
"bridges": ["ix0bridge"],
|
"bridges": ["ix0bridge"],
|
||||||
|
|||||||
+39
-1
@@ -12,6 +12,18 @@ $templates = vmm_file_list(vmm_data_dir('.templates'), ['conf']);
|
|||||||
$datastores = vmm_datastores();
|
$datastores = vmm_datastores();
|
||||||
$switches = vmm_switches();
|
$switches = vmm_switches();
|
||||||
$images = vmm_file_list(vmm_data_dir('.img'), ['img']);
|
$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) {
|
if ($post) {
|
||||||
$name = trim((string)($_POST['name'] ?? ''));
|
$name = trim((string)($_POST['name'] ?? ''));
|
||||||
@@ -23,6 +35,8 @@ if ($post) {
|
|||||||
$cloud = isset($_POST['cloudinit']);
|
$cloud = isset($_POST['cloudinit']);
|
||||||
$img = (string)($_POST['image'] ?? '');
|
$img = (string)($_POST['image'] ?? '');
|
||||||
$switch = trim((string)($_POST['switch'] ?? ''));
|
$switch = trim((string)($_POST['switch'] ?? ''));
|
||||||
|
$iso = vmm_safe_basename((string)($_POST['iso'] ?? ''));
|
||||||
|
$autostart = isset($_POST['autostart']);
|
||||||
|
|
||||||
if (!vmm_valid_name($name)) {
|
if (!vmm_valid_name($name)) {
|
||||||
$err = gettext('Invalid name: letters, digits, dot, dash, underscore (max 32).');
|
$err = gettext('Invalid name: letters, digits, dot, dash, underscore (max 32).');
|
||||||
@@ -58,7 +72,14 @@ if ($post) {
|
|||||||
$argv[] = $img;
|
$argv[] = $img;
|
||||||
}
|
}
|
||||||
$argv[] = $name;
|
$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']));
|
header('Location: vmmngr_jobs.php?id=' . urlencode((string)$job['id']));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -153,6 +174,23 @@ vmm_nav('create');
|
|||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td class="celltag"><?=gettext('Summary');?></td>
|
<td class="celltag"><?=gettext('Summary');?></td>
|
||||||
<td class="celldata vmm-mono">
|
<td class="celldata vmm-mono">
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
0.10.0
|
0.10.1
|
||||||
Reference in new issue
Block a user