summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2019-06-07 18:24:41 +0200
committerJannik Schönartz2019-06-07 18:24:41 +0200
commit3e99058898918aa723d1c3139560798848193dfd (patch)
tree998975c157c456a8f5661fc19cd4ea9e2ef73461
parent[registration] Skip dhcp stuff for SERVERS (diff)
downloadbas-3e99058898918aa723d1c3139560798848193dfd.tar.gz
bas-3e99058898918aa723d1c3139560798848193dfd.tar.xz
bas-3e99058898918aa723d1c3139560798848193dfd.zip
[external-backends/idoit] Add bay assignment to the rack segments.
-rw-r--r--server/lib/external-backends/backends/idoit-backend.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/server/lib/external-backends/backends/idoit-backend.js b/server/lib/external-backends/backends/idoit-backend.js
index 95224fb..333569e 100644
--- a/server/lib/external-backends/backends/idoit-backend.js
+++ b/server/lib/external-backends/backends/idoit-backend.js
@@ -194,6 +194,10 @@ class IdoitBackend extends ExternalBackends {
// Get the name of the rack
const rackBody = this.getBody('cmdb.category.read', { 'apikey': c.apikey, 'object': client.parentId, 'objID': client.parentId, 'category': 'C__CATG__GLOBAL' }, 'get_rack')
const rack = await this.axiosRequest(c.url, [rackBody], headers)
+
+ if (!rack[0].result)
+ return { error: 'IDOIT_ERROR', message: rack[0].error.message }
+
const rackName = rack[0].result[0].title
let objectPositionBodies = []
@@ -325,12 +329,22 @@ class IdoitBackend extends ExternalBackends {
// If chassis id is set, assign the object to the chassis bay
if (chassisId) {
- const bay = client.location.bay + 1 + ''
+ // Read bay ids
+ const paramsSlots = {
+ 'object' : chassisId,
+ 'objID' : chassisId,
+ 'category': 'C__CATS__CHASSIS_SLOT',
+ 'apikey' : c.apikey
+ }
+ const readSlotsParam = this.getBody('cmdb.category.read', paramsSlots, 'read_slots')
+ const readSlots = await this.axiosRequest(c.url, [readSlotsParam], headers)
+ const bays = readSlots.result
+
const assignToSlotBody = this.getBody('cmdb.category.save', { 'apikey': c.apikey,
'objID': chassisId,
'object': chassisId,
'category': 'C__CATS__CHASSIS_DEVICES',
- 'data': { 'assigned_device': requestCreate[0].result.id, 'assigned_slots': [bay] } }, 'assign_to_slot')
+ 'data': { 'assigned_device': requestCreate[0].result.id, 'assigned_slots': [bays[client.location.bay].id] } }, 'assign_to_slot')
await this.axiosRequest(c.url, [assignToSlotBody], headers)
}