summaryrefslogtreecommitdiffstats
path: root/server/lib
diff options
context:
space:
mode:
authorJannik Schönartz2020-04-17 21:36:33 +0200
committerJannik Schönartz2020-04-17 21:36:33 +0200
commit234aa456078c589e1d575810dad1873bd7458f36 (patch)
treec8e0227dba5b92544d09ba175702c397263ce8d4 /server/lib
parent[webapp/Backends] Add docu overlay styles, used for the screenshots (diff)
downloadbas-234aa456078c589e1d575810dad1873bd7458f36.tar.gz
bas-234aa456078c589e1d575810dad1873bd7458f36.tar.xz
bas-234aa456078c589e1d575810dad1873bd7458f36.zip
[server/registration] Add domain selection to the semi-automatic registration
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/external-backends/backends/infoblox-backend.js19
-rw-r--r--server/lib/external-backends/index.js3
2 files changed, 20 insertions, 2 deletions
diff --git a/server/lib/external-backends/backends/infoblox-backend.js b/server/lib/external-backends/backends/infoblox-backend.js
index 6c80392..0571841 100644
--- a/server/lib/external-backends/backends/infoblox-backend.js
+++ b/server/lib/external-backends/backends/infoblox-backend.js
@@ -64,6 +64,20 @@ class InfobloxBackend extends ExternalBackends {
})
}
+ async checkDomain (credentials) {
+ const c = this.mapCredentials(credentials)
+
+ const ipam = new Infoblox({
+ ip: c.url,
+ apiVersion: c.version
+ })
+ const login = await ipam.login(c.username, c.password)
+ if (!login) return { error: 'LOGIN_FAILED' }
+
+ const domainList = await ipam.getDomain()
+ return domainList
+ }
+
async checkIp (credentials, ipv4) {
const c = this.mapCredentials(credentials)
@@ -96,7 +110,7 @@ class InfobloxBackend extends ExternalBackends {
return response
}
- async setIp (credentials, ipv4, mac, name, setNextIp = false) {
+ async setIp (credentials, ipv4, domain, mac, name, setNextIp = false) {
const c = this.mapCredentials(credentials)
const ipam = new Infoblox({
@@ -116,7 +130,8 @@ class InfobloxBackend extends ExternalBackends {
return { error: 'ERROR_INFOBLOX', msg: 'No network found. Missing permissions?' }
}
}
- const domain = (await ipam.getDomain())[0]
+ // If the domain is not set, take the first available one.
+ if (!domain) domain = (await ipam.getDomain())[0]
// Set fixed ip if the name is not set (Automatic registration)
let path = ''
diff --git a/server/lib/external-backends/index.js b/server/lib/external-backends/index.js
index 9716b36..f16a1e1 100644
--- a/server/lib/external-backends/index.js
+++ b/server/lib/external-backends/index.js
@@ -166,6 +166,9 @@ class ExternalBackends {
async getFile (credentials, externalId, filename) {
return { error: 'NOT_IMPLEMENTED_EXCEPTION', message: 'The provided backend does not have an getFile method' }
}
+ async checkDomain (credentials) {
+ return { error: 'NOT_IMPLEMENTED_EXCEPTION', message: 'The provided backend does not have a checkDomain method' }
+ }
async checkIp (credentials, ipv4) {
return { error: 'NOT_IMPLEMENTED_EXCEPTION', message: 'The provided backend does not have a checkIp method' }
}