From 79bf0b07aeef65b7a1e1ed6dc58f450cb7e125ff Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Tue, 6 Apr 2021 16:58:33 +0000 Subject: [server/registration] Fix error message when there is a fixed ip but no hostname --- server/api/registration.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'server') diff --git a/server/api/registration.js b/server/api/registration.js index a556bbe..fecc65c 100644 --- a/server/api/registration.js +++ b/server/api/registration.js @@ -298,7 +298,7 @@ noAuthRouter.postAsync('/clients', async (req, res) => { // === Add 5 min to the time and round to the nearest one const rounded = new Date(Math.round((date.getTime() + fiveMin) / tenMin) * tenMin) - return res.send(buildNameClientIpxeMenu(client, `Client has a fixed IP but NO hostname was found. \nInfoblox might not be ready after client deletion. \nWait until ${rounded.toTimeString()} or enter a name and continue anyways ...`)) + return res.send(buildNameClientIpxeMenu(client, ['Client has a fixed IP but NO hostname was found.', 'Infoblox might not be ready after client deletion.', `Wait until ${rounded.toTimeString()} or enter a name and continue anyways ...`])) } } } else { // End of DHCP Stuff @@ -770,8 +770,7 @@ function buildSelectIpIpxeMenu (client, ipList, error = undefined) { let menuscript = '' script += ':start\r\n' script += 'menu Select the ip for this client: \r\n' - for (let index in ipList) { - const ip = ipList[index] + for (let ip of ipList) { client.networks[0].dhcp = { ip: ip } script += 'item ' + ip + ' ' + ip + '\r\n' menuscript += ':' + ip + '\r\n' + 'params\r\nparam client ' + JSON.stringify(client) + '\r\n' @@ -803,10 +802,14 @@ function buildSelectDomainIpxeMenu (client, domainList) { return script } -function buildNameClientIpxeMenu (client, showError) { +function buildNameClientIpxeMenu (client, showErrorLines) { const basUrl = 'https://' + url let script = '#!ipxe\r\n' - if (showError) script += `echo ${showError}` + + for (let line of showErrorLines) { + script += `echo ${line}\r\n` + } + script += '\r\necho Enter client name\r\nread clientname\r\nparams\r\n' client.name = `\${clientname}` script += 'param client ' + JSON.stringify(client) + '\r\n' -- cgit v1.2.3-55-g7522