summaryrefslogtreecommitdiffstats
path: root/server/lib/external-backends/backends/idoit-backend.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/external-backends/backends/idoit-backend.js')
-rw-r--r--server/lib/external-backends/backends/idoit-backend.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/server/lib/external-backends/backends/idoit-backend.js b/server/lib/external-backends/backends/idoit-backend.js
index 1fe7b5f..74a59fe 100644
--- a/server/lib/external-backends/backends/idoit-backend.js
+++ b/server/lib/external-backends/backends/idoit-backend.js
@@ -180,9 +180,10 @@ class IdoitBackend extends ExternalBackends {
else if (client.type === 'SERVER') {
params['type'] = 5
- if (client.location) params.categories.C__CATG__LOCATION = { 'data': { 'option': client.location.assembly, 'insertion': client.location.insertion, 'pos': 32 } }
+ if (client.location) params.categories.C__CATG__LOCATION = { 'data': { 'parent': client.parentId, 'option': client.location.assembly, 'insertion': client.location.insertion, 'pos': client.location.pos } }
+ if (client.formfactor) params.categories.C__CATG__FORMFACTOR = { 'data': { 'formfactor': client.formfactor, 'rackunits': client.formfactor.rackunits } }
// TODO: Assign to rack with the given rackid
- }
+ } else if (client.parentId) params.categories.C__CATG__LOCATION = { 'data': { 'parent': client.parentId } }
// Add categories to the object
if (client.uuid) params.categories.C__CATG__MODEL = { 'data': { 'productid': client.uuid } }
@@ -194,17 +195,19 @@ class IdoitBackend extends ExternalBackends {
if (client.network.mac) params.categories.C__CATG__NETWORK_PORT = { 'data': { 'category_id': 1, 'mac': client.network.mac } }
if (client.network.ip) params.categories.C__CATG__IP = { 'data': { 'category_id': 1, 'ipv4_address': client.network.ip } }
}
- if (client.parentId) params.categories.C__CATG__LOCATION = { 'data': { 'parent': client.parentId } }
// Send the create request.
const body = this.getBody('cmdb.object.create', params, 'client_create')
const requestCreate = await this.axiosRequest(c.url, [body], headers)
+
+ // Error handling
if (requestCreate.error) return { error: requestCreate.errno, message: 'Connection was refused.' }
+ else if (requestCreate[0].error) return { error: 'IDOIT_ERROR', message: requestCreate[0].error.message }
// Purpose for Clients:
// 1 = Production | 5 = PVS
// 2 = Test | 7 = Pool PC
// 3 = Quality Assurance | 8 = Mitarbeiter Arbeitsplatz
- return { id: requestCreate[0].result.id, type: params.type, message: requestCreate[0].result.message }
+ return { succes: true, id: requestCreate[0].result.id, type: params.type, message: requestCreate[0].result.message }
}
/*