summaryrefslogtreecommitdiffstats
path: root/server/lib/external-backends/backends/infoblox-backend.js
diff options
context:
space:
mode:
authorJannik Schönartz2018-08-29 13:28:53 +0200
committerJannik Schönartz2018-08-29 13:28:53 +0200
commitaf9482a0c6ebef83226829fb2a126d5ca9424ffd (patch)
treed235ea088cb7e02c8c74b143b973cd780feabbb2 /server/lib/external-backends/backends/infoblox-backend.js
parent[external-backends] Use search table instead of datatables (diff)
downloadbas-af9482a0c6ebef83226829fb2a126d5ca9424ffd.tar.gz
bas-af9482a0c6ebef83226829fb2a126d5ca9424ffd.tar.xz
bas-af9482a0c6ebef83226829fb2a126d5ca9424ffd.zip
[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.
Diffstat (limited to 'server/lib/external-backends/backends/infoblox-backend.js')
-rw-r--r--server/lib/external-backends/backends/infoblox-backend.js29
1 files changed, 26 insertions, 3 deletions
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: <boolean>, status: '<STATUS_CODE_IF_ERROR>', error: '<ERROR_MESSAGE>' }
*/
- 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.