summaryrefslogtreecommitdiffstats
path: root/server/lib/external-backends/backends/infoblox-backend.js
diff options
context:
space:
mode:
authorJannik Schönartz2019-11-27 11:09:43 +0100
committerJannik Schönartz2019-11-27 11:09:43 +0100
commitfeafcbfe00ead360140d38a9dd2c03da2204b1dc (patch)
tree100d74a8a9d4cf64219319a5e9446f2ba0c800fe /server/lib/external-backends/backends/infoblox-backend.js
parent[server/configloader] Add a better (dynamic) default config, delete the old d... (diff)
downloadbas-feafcbfe00ead360140d38a9dd2c03da2204b1dc.tar.gz
bas-feafcbfe00ead360140d38a9dd2c03da2204b1dc.tar.xz
bas-feafcbfe00ead360140d38a9dd2c03da2204b1dc.zip
[server/external-backends/infoblox] Add infoblox fix for a client registration in a network where the bas has no permission
Diffstat (limited to 'server/lib/external-backends/backends/infoblox-backend.js')
-rw-r--r--server/lib/external-backends/backends/infoblox-backend.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/server/lib/external-backends/backends/infoblox-backend.js b/server/lib/external-backends/backends/infoblox-backend.js
index 3165b05..b4c69e5 100644
--- a/server/lib/external-backends/backends/infoblox-backend.js
+++ b/server/lib/external-backends/backends/infoblox-backend.js
@@ -77,11 +77,13 @@ class InfobloxBackend extends ExternalBackends {
// Get the host and check the leased state
let host = JSON.parse(await ipam.getHost(ipv4))[0]
- if (host.lease_state && host.lease_state === 'ACTIVE') {
+ if (host && host.lease_state && host.lease_state === 'ACTIVE') {
// If leased return the next 20 free ips of the subnet.
const dhcpNetwork = JSON.parse(await ipam.getNetworkFromIp(ipv4))
const nextIps = await ipam.getNext(dhcpNetwork[0]._ref, 20)
return { leased: true, nextIps: nextIps }
+ } else {
+ return { error: 'HOST_NOT_FOUND' }
}
let response = { leased: false, id: host._ref }
@@ -101,7 +103,12 @@ class InfobloxBackend extends ExternalBackends {
// If setNextIp is true, use the next available ip from the subnet
if (setNextIp) {
- const network = JSON.parse(await ipam.getNetworkFromIp(ipv4))
+ try {
+ const network = JSON.parse(await ipam.getNetworkFromIp(ipv4))
+ } catch (e) {
+ console.log(e)
+ return { error: 'ERROR_INFOBLOX', msg: 'No network found. Missing permissions?' }
+ }
ipv4 = 'func:nextavailableip:' + network[0].network
}
const domain = (await ipam.getDomain())[0]