summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2022-02-16 18:57:39 +0100
committerJannik Schönartz2022-02-16 18:57:39 +0100
commit481714da988fdf72f20c2305d40bd76a1ba1b5b3 (patch)
tree7208328424097af95ab90b4ecc0bba88a3ed734b
parent[server/backends/idoit] Add check if bay is in range 0 or 1 (diff)
downloadbas-481714da988fdf72f20c2305d40bd76a1ba1b5b3.tar.gz
bas-481714da988fdf72f20c2305d40bd76a1ba1b5b3.tar.xz
bas-481714da988fdf72f20c2305d40bd76a1ba1b5b3.zip
[server/backends/idoit] Use blade-chassis instead of rack segmentation
-rw-r--r--server/lib/external-backends/backends/idoit-backend.js51
1 files changed, 39 insertions, 12 deletions
diff --git a/server/lib/external-backends/backends/idoit-backend.js b/server/lib/external-backends/backends/idoit-backend.js
index 59c7b23..9632aa8 100644
--- a/server/lib/external-backends/backends/idoit-backend.js
+++ b/server/lib/external-backends/backends/idoit-backend.js
@@ -796,18 +796,28 @@ class IdoitBackend extends ExternalBackends {
*/
// Update the object location.
- if (client.parentId && (!client.location || (client.location && !client.location.slot))) {
+ if (client.parentId && (!client.location || (client.location && !client.location.bay))) {
// Either client or no slot was set
- const locationData = {
+ let locationData = {
'parent': client.parentId
}
+ // If location slot information was given, assume it's a rack and add slot position and stuff (without bay -> no segmentation)
+ if (client.location.slot) {
+ locationData = {
+ ...locationData,
+ 'option': client.location.option ? client.location.option : 'Horizontal',
+ 'insertion': client.location.insertion ? client.location.insertion : 'Front and backside',
+ 'pos': client.location.slot
+ }
+ }
+
bodies.push(createUpdateCategorieRequest('C__CATG__LOCATION', locationData))
} else {
// Create segments and prepare bay
// Rack segmentation
- if (!!client.location && !!client.location.slot) {
+ if (!!client.location && !!client.location.slot && !!client.location.bay) {
// Get the parentId if none was given
if (!client.parentId) {
let boundedLocation = boundObjects.filter(response => response.id.startsWith('READ_C__CATG__LOCATION'))
@@ -934,7 +944,7 @@ class IdoitBackend extends ExternalBackends {
// For each segmentation object in the rack get the slot number
for (let object of rackObjects.result) {
- if (object.assigned_object.type !== 'C__OBJTYPE__RACK_SEGMENT') continue
+ if (object.assigned_object.type !== 'C__OBJTYPE__BLADE_CHASSIS') continue // Old segmentation was: C__OBJTYPE__RACK_SEGMENT
if (object.assigned_object.title === `${rackName} Slot ${client.location.slot}`) {
// This is the slot where it should get added
@@ -949,28 +959,44 @@ class IdoitBackend extends ExternalBackends {
// Create a new rack segment
const createSegmentParamObject = {
'apikey': credentials.apikey,
- 'type': 92,
+ 'type': 74, // 92 = Rack Segment, 74 = Blade Chassis
'title': rackName + ' Slot ' + client.location.slot,
'categories': {
'C__CATS__CHASSIS': {
'data': {
'front_x': 2,
- 'front_y': 1,
+ 'front_y': 2,
'rear_x': 0,
'rear_y': 0
}
},
'C__CATS__CHASSIS_SLOT': [
{
+ 'title': 'Bay 0',
+ 'insertion': 'front',
+ 'from_x': 0,
+ 'to_x': 0,
+ 'from_y': 1,
+ 'to_y': 1
+ },
+ {
'title': 'Bay 1',
'insertion': 'front',
+ 'from_x': 1,
+ 'to_x': 1,
+ 'from_y': 1,
+ 'to_y': 1
+ },
+ {
+ 'title': 'Bay 2',
+ 'insertion': 'front',
'from_x': 0,
'to_x': 0,
'from_y': 0,
'to_y': 0
},
{
- 'title': 'Bay 2',
+ 'title': 'Bay 3',
'insertion': 'front',
'from_x': 1,
'to_x': 1,
@@ -993,15 +1019,16 @@ class IdoitBackend extends ExternalBackends {
const createSegment = await this.axiosRequest(credentials.url, [createSegmentParam], headers)
chassisId = createSegment[0].result.id
- /*
// Set the new rack units height. (Needs an extra request, why? I DONT KNOW... idoit...)
- const setSegmentSizeParams = this.getBody('cmdb.category.save', { 'apikey': c.apikey,
+ const setSegmentSizeParams = this.getBody('cmdb.category.save', {
+ 'apikey': credentials.apikey,
'object': chassisId,
'objID': chassisId,
'category': 'C__CATG__FORMFACTOR',
- 'data': { 'rackunits': client.formfactor.rackunits } }, 'set_segment_size')
- await this.axiosRequest(c.url, [setSegmentSizeParams], headers)
- */
+ 'data': { 'rackunits': client.formfactor.rackunits }
+ }, 'set_segment_size')
+ await this.axiosRequest(credentials.url, [setSegmentSizeParams], headers)
+
}
return chassisId
}