From 234aa456078c589e1d575810dad1873bd7458f36 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Fri, 17 Apr 2020 19:36:33 +0000 Subject: [server/registration] Add domain selection to the semi-automatic registration --- .../external-backends/backends/infoblox-backend.js | 19 +++++++++++++++++-- server/lib/external-backends/index.js | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'server/lib') 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' } } -- cgit v1.2.3-55-g7522