KEA Setup
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-13 02:13:43 +02:00
parent 4d73eec687
commit 677f9314f5
8 changed files with 285 additions and 73 deletions

View File

@@ -17,13 +17,20 @@
},
"setup": {
"fields": [
{ "name": "db.driver", "label": "DB Driver", "type": "text", "required": true },
{ "name": "db.host", "label": "DB Host", "type": "text", "required": true },
{ "name": "db.port", "label": "DB Port", "type": "number", "required": true },
{ "name": "db.dbname", "label": "DB Name", "type": "text", "required": true },
{ "name": "db.schema", "label": "DB Schema", "type": "text", "required": false },
{ "name": "db.user", "label": "DB User", "type": "text", "required": true },
{ "name": "db.password", "label": "DB Passwort", "type": "password", "required": true },
{ "name": "db.driver", "label": "KEA DB Driver", "type": "text", "required": true, "help": "Standard-KEA-Datenbank, die auch vom KEA-Dienst selbst genutzt wird." },
{ "name": "db.host", "label": "KEA DB Host", "type": "text", "required": true },
{ "name": "db.port", "label": "KEA DB Port", "type": "number", "required": true },
{ "name": "db.dbname", "label": "KEA DB Name", "type": "text", "required": true },
{ "name": "db.schema", "label": "KEA DB Schema", "type": "text", "required": false },
{ "name": "db.user", "label": "KEA DB User", "type": "text", "required": true },
{ "name": "db.password", "label": "KEA DB Passwort", "type": "password", "required": true },
{ "name": "metadata_db.driver", "label": "Nexus DHCP DB Driver", "type": "text", "required": true, "help": "Separate Datenbank fuer Nexus-eigene DHCP-Zusatzinfos, nicht fuer KEA-Standardtabellen." },
{ "name": "metadata_db.host", "label": "Nexus DHCP DB Host", "type": "text", "required": true },
{ "name": "metadata_db.port", "label": "Nexus DHCP DB Port", "type": "number", "required": true },
{ "name": "metadata_db.dbname", "label": "Nexus DHCP DB Name", "type": "text", "required": true },
{ "name": "metadata_db.schema", "label": "Nexus DHCP DB Schema", "type": "text", "required": false },
{ "name": "metadata_db.user", "label": "Nexus DHCP DB User", "type": "text", "required": true },
{ "name": "metadata_db.password", "label": "Nexus DHCP DB Passwort", "type": "password", "required": true },
{ "name": "kea_db_version", "label": "KEA DB Version", "type": "text", "required": false },
{ "name": "kea_init_script", "label": "KEA Init Script", "type": "text", "required": false },
{ "name": "kea_init_cmd", "label": "KEA Init Command", "type": "text", "required": false },
@@ -38,5 +45,14 @@
"schema": "public",
"user": "",
"password": ""
},
"metadata_db_defaults": {
"driver": "pgsql",
"host": "192.168.178.10",
"port": 5432,
"dbname": "",
"schema": "public",
"user": "",
"password": ""
}
}

View File

@@ -1,15 +1,28 @@
<?php
use App\Database;
use App\Repository\KeaHostRepository;
use App\Repository\KeaHostMetadataRepository;
$module = modules()->get('kea');
$fallback = $module['db_defaults'] ?? [];
$pdo = modules()->modulePdo('kea', $fallback);
$settings = modules()->settings('kea');
$metadataFallback = is_array($module['metadata_db_defaults'] ?? null) ? $module['metadata_db_defaults'] : [];
$metadataConfig = is_array($settings['metadata_db'] ?? null)
? array_replace($metadataFallback, $settings['metadata_db'])
: $metadataFallback;
$metadataRepo = null;
$hosts = [];
$error = null;
try {
$repo = new KeaHostRepository($pdo);
if (!empty($metadataConfig['driver']) && !empty($metadataConfig['dbname'])) {
$metadataRepo = new KeaHostMetadataRepository(Database::createFromArray($metadataConfig));
$metadataRepo->ensureSchema();
}
$repo = new KeaHostRepository($pdo, $metadataRepo);
$hosts = $repo->findAll(50);
} catch (\Exception $e) {
$error = "Datenbankfehler: " . $e->getMessage();

View File

@@ -35,7 +35,8 @@
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Hostname</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">IP Adresse</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">MAC Adresse</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Kontext</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Echter Name</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Standort</th>
<th scope="col" class="relative px-6 py-3">
<span class="sr-only">Edit</span>
</th>
@@ -44,7 +45,7 @@
<tbody class="bg-gray-800 divide-y divide-gray-700">
<?php if (empty($hosts)): ?>
<tr>
<td colspan="5" class="px-6 py-4 text-center text-sm text-gray-500">Keine Hosts gefunden.</td>
<td colspan="6" class="px-6 py-4 text-center text-sm text-gray-500">Keine Hosts gefunden.</td>
</tr>
<?php else: ?>
<?php foreach ($hosts as $host): ?>
@@ -59,7 +60,10 @@
<?= e($host['dhcp_identifier']) ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-400">
<?= e($host['user_context'] ?? '-') ?>
<?= e((string)($host['metadata']['real_name'] ?? '-')) ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-400">
<?= e((string)($host['metadata']['location'] ?? '-')) ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<a href="#" class="text-indigo-400 hover:text-indigo-300">Bearbeiten</a>
@@ -71,4 +75,4 @@
</table>
</div>
</div>
</div>
</div>