0.4.0: ISO install (attach CD devices incl. virtio-win driver ISO), eject, virtio-win download preset
This commit is contained in:
1 parent
e989df97a5
commit
c577f3c96f
5 files changed
+232
-2
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"appname": "VM Manager",
|
||||
"version": "0.3.3",
|
||||
"version": "0.4.0",
|
||||
"rootfolder": "/mnt/Daten/extensions/vmmngr",
|
||||
"vm_source": "auto",
|
||||
"bridges": ["ix0bridge"],
|
||||
|
||||
@@ -12,7 +12,19 @@ $post = strtoupper((string)($_SERVER['REQUEST_METHOD'] ?? '')) === 'POST';
|
||||
$act = $post ? (string)($_POST['act'] ?? '') : '';
|
||||
$confirm = $post ? (string)($_POST['confirm'] ?? '') : '';
|
||||
|
||||
$presets = [
|
||||
'virtio' => ['kind' => 'iso', 'url' => 'https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso'],
|
||||
];
|
||||
|
||||
if ($post && $act !== '') {
|
||||
if (str_starts_with($act, 'preset:')) {
|
||||
$key = substr($act, 7);
|
||||
if (isset($presets[$key])) {
|
||||
$job = vmm_job_new($presets[$key]['kind'] . '_download', $key, [$presets[$key]['kind'], $presets[$key]['url']], 21600);
|
||||
header('Location: vmmngr_jobs.php?id=' . urlencode((string)$job['id']));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($act === 'download') {
|
||||
$kind = (string)($_POST['kind'] ?? 'iso');
|
||||
$url = trim((string)($_POST['url'] ?? ''));
|
||||
@@ -97,6 +109,13 @@ function vmmAskDelete(name) {
|
||||
<span style="opacity:.75;margin-left:8px;"><?=gettext('Downloads run as a job in the background.');?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="celltag"><?=gettext('Presets');?></td>
|
||||
<td class="celldata">
|
||||
<button type="submit" class="formbtn" name="act" value="preset:virtio"><?=gettext('virtio-win drivers ISO');?></button>
|
||||
<span style="opacity:.75;margin-left:8px;"><?=gettext('Official stable build - needed by Windows guests for disk/network drivers.');?></span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -17,6 +17,40 @@ if (strtoupper((string)($_SERVER['REQUEST_METHOD'] ?? '')) === 'POST' && isset($
|
||||
if ($vmName !== $name) {
|
||||
$vmName = $name;
|
||||
}
|
||||
|
||||
// media: attach ISOs (install) or eject them
|
||||
if ($verb === 'install' || $verb === 'eject') {
|
||||
if ($verb === 'eject') {
|
||||
$res = vmm_iso_detach($name);
|
||||
$_SESSION['vmmngr_error'] = isset($res['error'])
|
||||
? (string)$res['error']
|
||||
: ($res['removed'] === [] ? gettext('No ISO attached.') : sprintf(gettext('Ejected: %s'), implode(', ', $res['removed'])));
|
||||
header('Location: vmmngr_vm.php?name=' . urlencode($name));
|
||||
exit;
|
||||
}
|
||||
$isoDir = vmm_data_dir('.iso');
|
||||
$pick = [];
|
||||
foreach (['iso', 'driver_iso'] as $field) {
|
||||
$f = vmm_safe_basename((string)($_POST[$field] ?? ''));
|
||||
if ($f !== '' && str_ends_with(strtolower($f), '.iso')) {
|
||||
$pick[] = $isoDir . '/' . $f;
|
||||
}
|
||||
}
|
||||
if ($pick === []) {
|
||||
$_SESSION['vmmngr_error'] = gettext('Choose an ISO first.');
|
||||
header('Location: vmmngr_vm.php?name=' . urlencode($name));
|
||||
exit;
|
||||
}
|
||||
$res = vmm_iso_attach($name, $pick);
|
||||
if (isset($res['error'])) {
|
||||
$_SESSION['vmmngr_error'] = (string)$res['error'];
|
||||
header('Location: vmmngr_vm.php?name=' . urlencode($name));
|
||||
exit;
|
||||
}
|
||||
$job = vmm_job_new('start', $name);
|
||||
header('Location: vmmngr_jobs.php?id=' . urlencode((string)$job['id']));
|
||||
exit;
|
||||
}
|
||||
$check = vmm_action_check($verb, $vmName, (string)($_POST['confirm'] ?? ''));
|
||||
if (!$check['ok']) {
|
||||
$_SESSION['vmmngr_error'] = $check['error'];
|
||||
@@ -93,6 +127,66 @@ vmm_nav('dashboard');
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
$attached = vmm_attached_isos($name);
|
||||
$isos = vmm_file_list(vmm_data_dir('.iso'), ['iso']);
|
||||
?>
|
||||
<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(gettext('Install / media'), 2); ?>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="celltag"><?=gettext('Attached');?></td>
|
||||
<td class="celldata vmm-mono">
|
||||
<?php if ($attached === []): ?>
|
||||
<?=gettext('none');?>
|
||||
<?php else: ?>
|
||||
<?php foreach ($attached as $a): ?>
|
||||
<div>disk<?=(int)$a['slot'];?> → <?=vmm_h((string)$a['path']);?></div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if (!$isRunning): ?>
|
||||
<tr>
|
||||
<td class="celltag"><?=gettext('Boot ISO');?></td>
|
||||
<td class="celldata">
|
||||
<select name="iso">
|
||||
<option value=""><?=gettext('none');?></option>
|
||||
<?php foreach ($isos as $i): ?>
|
||||
<option value="<?=vmm_h((string)$i['name']);?>"><?=vmm_h((string)$i['name']);?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<span style="opacity:.75;margin-left:8px;"><?=gettext('Windows: boot from the installation ISO, drivers from virtio-win below.');?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="celltag"><?=gettext('Driver ISO');?></td>
|
||||
<td class="celldata">
|
||||
<select name="driver_iso">
|
||||
<option value=""><?=gettext('none');?></option>
|
||||
<?php foreach ($isos as $i): ?>
|
||||
<?php if (stripos((string)$i['name'], 'virtio') === false) { continue; } ?>
|
||||
<option value="<?=vmm_h((string)$i['name']);?>"><?=vmm_h((string)$i['name']);?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<span style="opacity:.75;margin-left:8px;"><?=gettext('Only virtio-* images are listed here.');?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="celltag"><?=gettext('Actions');?></td>
|
||||
<td class="celldata">
|
||||
<button type="submit" class="formbtn" name="act" value="install:<?=vmm_h($name);?>"><?=gettext('Attach and start');?></button>
|
||||
<button type="submit" class="formbtn" name="act" value="eject:<?=vmm_h($name);?>" onclick="return confirm('Eject all attached ISOs?')"><?=gettext('Eject all');?></button>
|
||||
<span style="opacity:.75;margin-left:8px;"><?=gettext('Attaching rewrites the VM config (backup as .vmmngr.bak).');?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="vmm-job" class="vmm-job"></div>
|
||||
|
||||
<?php foreach (($info['sections'] ?? []) as $type => $blocks): ?>
|
||||
|
||||
Reference in new issue
Block a user