0.8.1: switch dropdown shows type, interface and IP; chosen switch is written into the new VM config

This commit is contained in:
Claw committed 2026-11-17 21:08:53 +01:00
1 parent dd395dfe76
commit 81b4d6a63e
5 files changed
+54 -10

No files matched your search

+16 -3
View File
@@ -22,6 +22,7 @@ if ($post) {
$size = (string)($_POST['size'] ?? '20G');
$cloud = isset($_POST['cloudinit']);
$img = (string)($_POST['image'] ?? '');
$switch = trim((string)($_POST['switch'] ?? ''));
if (!vmm_valid_name($name)) {
$err = gettext('Invalid name: letters, digits, dot, dash, underscore (max 32).');
@@ -57,7 +58,7 @@ if ($post) {
$argv[] = $img;
}
$argv[] = $name;
$job = vmm_job_new('create', $name, $argv, 900);
$job = vmm_job_new('create', $name, $argv, 900, ['switch' => $switch]);
header('Location: vmmngr_jobs.php?id=' . urlencode((string)$job['id']));
exit;
}
@@ -122,8 +123,20 @@ vmm_nav('create');
<td class="celltag"><?=gettext('Network switch');?></td>
<td class="celldata">
<select name="switch">
<?php foreach ($switches as $s): ?>
<option value="<?=vmm_h((string)($s['name'] ?? ''));?>"><?=vmm_h((string)($s['name'] ?? ''));?> (<?=vmm_h((string)($s['type'] ?? ''));?>)</option>
<?php foreach ($switches as $s):
$swName = (string)($s['name'] ?? '');
$swType = (string)($s['type'] ?? '');
$swIface = (string)($s['iface'] ?? '');
$swIp = vmm_iface_ipv4($swIface);
$label = $swName . ' — ' . $swType;
if ($swIface !== '' && $swIface !== 'n/a') {
$label .= ' → ' . $swIface;
}
if ($swIp !== '') {
$label .= ' (' . $swIp . ')';
}
?>
<option value="<?=vmm_h($swName);?>"><?=vmm_h($label);?></option>
<?php endforeach; ?>
</select>
</td>