From 8f02dc7a012393e5046ca6e0686115df953aa00d Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Fri, 7 Jun 2019 15:10:24 +0000 Subject: [external-backends/idoit] New idoit version -> bugfixes -> remove workarounds --- .../external-backends/backends/idoit-backend.js | 28 ++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'server') diff --git a/server/lib/external-backends/backends/idoit-backend.js b/server/lib/external-backends/backends/idoit-backend.js index 160e7fe..95224fb 100644 --- a/server/lib/external-backends/backends/idoit-backend.js +++ b/server/lib/external-backends/backends/idoit-backend.js @@ -296,18 +296,24 @@ class IdoitBackend extends ExternalBackends { // Add mac address: Network port is a subcategory of network so it need an extra request. let macRequests = [] + const hostnameIds = requestCreate[0].result.categories.C__CATG__IP + if (client.networks) { for (let index in client.networks) { const network = client.networks[index] - // For the idresses + // For the ip adresses // network.id = requestCreate[0].result.categories.C__CATG__IP[index] + let addresses = [] + // Push the ids as string + if (hostnameIds.length >= index + 1) addresses.push('' + hostnameIds[index]) const paramsMac = { 'object': requestCreate[0].result.id, 'objID': requestCreate[0].result.id, 'category': 'C__CATG__NETWORK_PORT', 'data': { - 'mac': network.mac + 'mac': network.mac, + 'addresses': addresses }, 'apikey': c.apikey } @@ -483,10 +489,7 @@ class IdoitBackend extends ExternalBackends { } counter++ - // WORKAROUND - // bodies.push(this.getBody('cmdb.category.save', params, 'create_cpu_' + counter)) - const a = await this.axiosRequest(c.url, [this.getBody('cmdb.category.save', params, 'create_cpu_' + counter)], headers) - requestResults.push(a) + bodies.push(this.getBody('cmdb.category.save', params, 'create_cpu_' + counter)) } } @@ -512,17 +515,15 @@ class IdoitBackend extends ExternalBackends { 'apikey': c.apikey } counter++ - // WORKAROUND - // bodies.push(this.getBody('cmdb.category.save', params, 'create_memory_' + counter)) - const a = await this.axiosRequest(c.url, [this.getBody('cmdb.category.save', params, 'create_memory_' + counter)], headers) - requestResults.push(a) + bodies.push(this.getBody('cmdb.category.save', params, 'create_memory_' + counter)) } } // Update the object. Drive data. if (client.drives) { let counter = 1 - for (let drive of client.drives) { + for (let index in client.drives) { + const drive = client.drives[index] // UNIT if (drive.unit === 'GB') drive.unit = 3 else if (drive.unit === 'MB') drive.unit = 2 @@ -553,11 +554,8 @@ class IdoitBackend extends ExternalBackends { 'apikey': c.apikey } + bodies.push(this.getBody('cmdb.category.save', params, 'create_drive_' + counter)) counter++ - // WORKAROUND - // bodies.push(this.getBody('cmdb.category.save', params, 'create_drive_' + counter)) - const a = await this.axiosRequest(c.url, [this.getBody('cmdb.category.save', params, 'create_drive_' + counter)], headers) - requestResults.push(a) } } -- cgit v1.2.3-55-g7522