From af9482a0c6ebef83226829fb2a126d5ca9424ffd Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Wed, 29 Aug 2018 11:28:53 +0000 Subject: [external-backends] Add getClient methods for all backends Delete dummy and another backends. Extend template-dummy for testing stuff. Add getClient method for dhcp and idoit backends. Fixed appendicon for selections. --- .../external-backends/backends/infoblox-backend.js | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'server/lib/external-backends/backends/infoblox-backend.js') diff --git a/server/lib/external-backends/backends/infoblox-backend.js b/server/lib/external-backends/backends/infoblox-backend.js index f980b8b..9d070ac 100644 --- a/server/lib/external-backends/backends/infoblox-backend.js +++ b/server/lib/external-backends/backends/infoblox-backend.js @@ -25,7 +25,7 @@ class InfobloxBackend extends ExternalBackends { * * return: { success: , status: '', error: '' } */ - async checkConnection (credentials) { + checkConnection (credentials) { var c = this.mapCredentials(credentials) var ipam = new Infoblox({ @@ -34,13 +34,36 @@ class InfobloxBackend extends ExternalBackends { }) return ipam.login(c.username, c.password).then(response => { if (response) { - console.log('wefkin') return { success: true } } else { - return { success: false, error: 'TEST' } + return { success: false, error: 'Login failed' } } }) } + + /* + * Gets the client via IP, because only fixed pcs can be found via mac. But we also want so support leased pc's? + * + */ + async getClient (credentials, client) { + var c = this.mapCredentials(credentials) + + var ipam = new Infoblox({ + ip: c.url, + apiVersion: c.version + }) + + return ipam.login(c.username, c.password).then(response => { + if (response) { + return ipam.getHost('10.21.9.228').then(response => { + return JSON.parse(response) + }) + } else { + return { success: false, error: 'Login failed' } + } + }) + } + // ############################################################################ // ####################### helper/optional functions ######################### // Helper function, to map the array of credential objects into a single js object. -- cgit v1.2.3-55-g7522