From ef4bd54cc8ee68d2ec99d154441c60bcf344aa4c Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Tue, 23 Mar 2021 20:24:11 +0000 Subject: [server/registration] Show error msg and name input when infoblox has a fixed ip but no hostname --- server/api/registration.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/api/registration.js b/server/api/registration.js index b9d6f0b..09513c6 100644 --- a/server/api/registration.js +++ b/server/api/registration.js @@ -289,6 +289,16 @@ noAuthRouter.postAsync('/clients', async (req, res) => { if (!ipCheck.leased && ipCheck.name !== '') { if (ipCheck.name) client.name = ipCheck.name if (ipCheck.id) dhcp.ref = ipCheck.id + } else { + // Leased ip but no hostname? --> Maybe not waited long enough after DHCP deletion + let date = new Date() + const tenMin = 1000 * 60 * 10 + const fiveMin = 1000 * 60 * 5 + // Round up to the next 10-min mark for the error msg + // === 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 ...`)) } } } else { // End of DHCP Stuff @@ -793,9 +803,10 @@ function buildSelectDomainIpxeMenu (client, domainList) { return script } -function buildNameClientIpxeMenu (client) { +function buildNameClientIpxeMenu (client, showError) { const basUrl = 'https://' + url let script = '#!ipxe\r\n' + if (showError) script += `echo ${showError}` 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