summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2019-12-01 17:08:28 +0100
committerJannik Schönartz2019-12-01 17:08:28 +0100
commit26f2933072f8c13e7b294b8edf4cc18ea639b4a7 (patch)
tree4e44b6b87f84ac1e9f880e77ab5d8828c954241b
parent[server/log] Add logging to all modules (diff)
downloadbas-26f2933072f8c13e7b294b8edf4cc18ea639b4a7.tar.gz
bas-26f2933072f8c13e7b294b8edf4cc18ea639b4a7.tar.xz
bas-26f2933072f8c13e7b294b8edf4cc18ea639b4a7.zip
[server/infoblox] Fix unreachable code bug / fix eslint
-rw-r--r--server/lib/external-backends/backends/infoblox-backend.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/server/lib/external-backends/backends/infoblox-backend.js b/server/lib/external-backends/backends/infoblox-backend.js
index b4c69e5..9cedfb7 100644
--- a/server/lib/external-backends/backends/infoblox-backend.js
+++ b/server/lib/external-backends/backends/infoblox-backend.js
@@ -77,13 +77,12 @@ class InfobloxBackend extends ExternalBackends {
// Get the host and check the leased state
let host = JSON.parse(await ipam.getHost(ipv4))[0]
- if (host && host.lease_state && host.lease_state === 'ACTIVE') {
+ if (!host) return { error: 'HOST_NOT_FOUND' }
+ if (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 }
@@ -105,11 +104,11 @@ class InfobloxBackend extends ExternalBackends {
if (setNextIp) {
try {
const network = JSON.parse(await ipam.getNetworkFromIp(ipv4))
+ ipv4 = 'func:nextavailableip:' + network[0].network
} catch (e) {
- console.log(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]