refs #2092 adds new parameter bootfilename to create and update host
ogdhcp/pipeline/head There was a failure building this commit
Details
ogdhcp/pipeline/head There was a failure building this commit
Details
parent
271bcbb05d
commit
3fe53d35fd
|
@ -1382,6 +1382,8 @@ public function addDhcpHost(Request $request, $subnetId): JsonResponse
|
|||
$host = htmlspecialchars($input->host);
|
||||
$macAddress = htmlspecialchars($input->macAddress);
|
||||
$address = htmlspecialchars($input->address);
|
||||
// $bootFileName= htmlspecialchars($input->bootFileName);
|
||||
$bootFileName = isset($input->bootFileName) ? htmlspecialchars($input->bootFileName) : null;
|
||||
} catch (Exception $e) {
|
||||
$errorText = $e->getMessage();
|
||||
$this->logger->error(json_encode([
|
||||
|
@ -1406,7 +1408,8 @@ public function addDhcpHost(Request $request, $subnetId): JsonResponse
|
|||
$newHost = [
|
||||
"hostname" => $host,
|
||||
"hw-address" => $macAddress,
|
||||
"ip-address" => $address
|
||||
"ip-address" => $address,
|
||||
"boot-file-name" => $bootFileName
|
||||
];
|
||||
|
||||
$subnetFound = false;
|
||||
|
@ -1415,7 +1418,12 @@ public function addDhcpHost(Request $request, $subnetId): JsonResponse
|
|||
if ($subnet['id'] == $subnetId) {
|
||||
$subnetFound = true;
|
||||
|
||||
if (isset($subnet['boot-file-name'])) {
|
||||
// Si la subred tiene boot-file-name, lo añadimos a la reserva
|
||||
// Si hemos recibido bootFileName como parámetro de entrada, lo asignamos al host.
|
||||
if (!empty($bootFileName)) {
|
||||
$newHost['boot-file-name'] = $bootFileName;
|
||||
} elseif (isset($subnet['boot-file-name'])) {
|
||||
// Si no, usamos el de la subred si existe.
|
||||
$newHost['boot-file-name'] = $subnet['boot-file-name'];
|
||||
}
|
||||
if (isset($subnet['next-server'])) {
|
||||
|
@ -1862,6 +1870,8 @@ public function updateDhcpHost(Request $request, $subnetId): JsonResponse
|
|||
$oldMacAddress = htmlspecialchars($input->oldMacAddress);
|
||||
$macAddress = htmlspecialchars($input->macAddress);
|
||||
$address = htmlspecialchars($input->address);
|
||||
//Verifica si el campo bootFileName está presente, si no, lo deja como null
|
||||
$bootFileName = isset($input->bootFileName) ? htmlspecialchars($input->bootFileName) : null;
|
||||
} catch (Exception $e) {
|
||||
$errorText = $e->getMessage();
|
||||
$this->logger->error(json_encode([
|
||||
|
@ -1898,7 +1908,14 @@ public function updateDhcpHost(Request $request, $subnetId): JsonResponse
|
|||
if ($reservation['hw-address'] == $oldMacAddress) {
|
||||
$hostFound = true;
|
||||
|
||||
$bootFileName = $reservation['boot-file-name'] ?? $subnet['boot-file-name'] ?? null;
|
||||
// Si nos llega bootFileName en el input, lo usamos; si no, asignamos el tenga la subred
|
||||
if ($bootFileName !== null) {
|
||||
$reservation['boot-file-name'] = $bootFileName;
|
||||
} elseif (isset($subnet['boot-file-name'])) {
|
||||
$bootFileName = $subnet['boot-file-name'];
|
||||
} else {
|
||||
$bootFileName = null;
|
||||
}
|
||||
$nextServer = $reservation['next-server'] ?? $subnet['next-server'] ?? null;
|
||||
|
||||
$reservation['hw-address'] = $macAddress;
|
||||
|
|
Loading…
Reference in New Issue