summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2021-03-23 21:24:11 +0100
committerJannik Schönartz2021-03-23 21:24:11 +0100
commitef4bd54cc8ee68d2ec99d154441c60bcf344aa4c (patch)
tree88b5a0a255bae7cc01133949ccc6a3c6c9545f0c
parent[server/ipxe_builder] Update embedded ipxe + config (diff)
downloadbas-ef4bd54cc8ee68d2ec99d154441c60bcf344aa4c.tar.gz
bas-ef4bd54cc8ee68d2ec99d154441c60bcf344aa4c.tar.xz
bas-ef4bd54cc8ee68d2ec99d154441c60bcf344aa4c.zip
[server/registration] Show error msg and name input when infoblox has a fixed ip but no hostname
-rw-r--r--server/api/registration.js13
1 files changed, 12 insertions, 1 deletions
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'