Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 45b744a

Browse files
authored
Merge pull request #4 from Dell-SMI/wsman-computer-system-for-northbound-redfish
adding controller and view support for wsman conputerSystem view
2 parents 5028e44 + 869cac9 commit 45b744a

2 files changed

Lines changed: 131 additions & 21 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"@odata.context" : "<%= basepath %>/$metadata#Systems/Members/$entity",
3+
"@odata.id": "<%= url %>",
4+
"@odata.type": "#ComputerSystem.1.0.0.ComputerSystem",
5+
"Oem" : {},
6+
"Id": "<%= identifier %>",
7+
"Description": "<%= hardware.data.system.systemGeneration %>",
8+
"Name": "Computer System",
9+
"SystemType": "<%= systemType %>",
10+
"AssetTag": "<%= hardware.data.system.assetTag || 'Not Specified' %>",
11+
"Manufacturer": "<%= hardware.data.system.manufacturer %>",
12+
"Model": "<%= hardware.data.system.model %>",
13+
"SKU": "<%= hardware.data.system.boardSerialNumber %>",
14+
"SerialNumber": "<%= hardware.data.system.serviceTag %>",
15+
"PartNumber": "",
16+
"UUID": "<%= hardware.data.system.uuid.toLowerCase() %>",
17+
"HostName": "<% hardware.data.system.hostName %>",
18+
"IndicatorLED": "<%= hardware.data.leds[0] || 'Unknown' %>",
19+
"PowerState": "<%= hardware.data.system.powerState == 2 ? 'On' : 'Off' %>",
20+
"Boot": {},
21+
"BiosVersion": "<%= hardware.data.system.biosVersionString.trim() %> <%= hardware.data.system.biosReleaseDate.trim() %> ",
22+
"ProcessorSummary": {
23+
"Count": <%= hardware.data.system.populatedCpuSockets %>,
24+
"Model": "<%= hardware.data.cpus[0].model %>",
25+
"Status": {}
26+
},
27+
"MemorySummary": {
28+
"TotalSystemMemoryGiB": <%= hardware.data.system.sysMemTotalSize %>,
29+
"Status": {}
30+
},
31+
"Actions": {
32+
"Oem": {
33+
"RackHD": {
34+
"#RackHD.BootImage": {
35+
"target": "<%=basepath%>/Systems/<%=identifier%>/Actions/RackHD.BootImage"
36+
}
37+
}
38+
},
39+
"#ComputerSystem.Reset": {
40+
"target": "<%=basepath%>/Systems/<%=identifier%>/Actions/ComputerSystem.Reset"
41+
}
42+
},
43+
"Status": {},
44+
"Processors": {
45+
"@odata.id": "<%= basepath %>/Systems/<%= identifier %>/Processors"
46+
},
47+
"EthernetInterfaces": {
48+
"@odata.id": "<%= basepath %>/Systems/<%= identifier %>/EthernetInterfaces"
49+
},
50+
"SimpleStorage": {
51+
"@odata.id": "<%= basepath %>/Systems/<%= identifier %>/SimpleStorage"
52+
},
53+
"LogServices": {
54+
"@odata.id": "<%= basepath %>/Systems/<%= identifier %>/LogServices"
55+
},
56+
"Links": {
57+
"Oem": {},
58+
"ManagedBy@odata.count": <%= obm.length %>,
59+
"ManagedBy": [
60+
<% obm.forEach(function(obm, i, arr) { %>
61+
{
62+
"@odata.id": "<%= basepath %>/Managers/<%= obm %>"
63+
}
64+
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
65+
<% }); %>
66+
],
67+
"PoweredBy@odata.count": 0,
68+
"PoweredBy": [],
69+
"CooledBy@odata.count": 0,
70+
"CooledBy": [],
71+
"Chassis@odata.count": <%= chassis.length %>,
72+
"Chassis": [
73+
<% chassis.forEach(function(chassis, i, arr) { %>
74+
{
75+
"@odata.id": "<%= basepath %>/Chassis/<%= chassis %>"
76+
}
77+
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
78+
<% }); %>
79+
]
80+
}
81+
}

lib/api/redfish-1.0/systems.js

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var dataFactory = function(identifier, dataName) {
1818
case 'ohai':
1919
case 'dmi':
2020
case 'smart':
21+
case 'hardware':
2122
return nodeApi.getNodeCatalogSourceById(identifier, dataName);
2223

2324
case 'chassis':
@@ -211,27 +212,55 @@ var getSystem = controller(function(req, res) {
211212
var options = redfish.makeOptions(req, res, identifier);
212213
options.systemType = 'Physical';
213214

214-
return Promise.props({
215-
ohai: dataFactory(identifier, 'ohai'),
216-
dmi: dataFactory(identifier, 'dmi'),
217-
chassis: dataFactory(identifier, 'chassis'),
218-
chassisData: dataFactory(identifier, 'chassisData'),
219-
obm: waterline.nodes.getNodeById(identifier)
220-
.then(function(node) {
221-
return _.map(node.obms, function(val, idx) {
222-
return node.id + '.' + idx;
223-
});
224-
})
225-
.then(function(obms) {
226-
obms.push('RackHD');
227-
return obms;
228-
})
229-
}).then(function(data) {
230-
return redfish.render('redfish.1.0.0.computersystem.1.0.0.json',
231-
'ComputerSystem.1.0.0.json#/definitions/ComputerSystem',
232-
_.merge(options, data));
233-
}).catch(function(error) {
234-
return redfish.handleError(error, res);
215+
return waterline.nodes.getNodeById(identifier)
216+
.then(function(node){
217+
if(/^[0-9|A-Z]{7}$/.test(node.name)){
218+
return Promise.props({
219+
hardware: dataFactory(identifier, 'hardware'),
220+
chassis: dataFactory(identifier, 'chassis'),
221+
chassisData: dataFactory(identifier, 'chassisData'),
222+
obm: Promise.resolve(node)
223+
.then(function(node) {
224+
return _.map(node.obms, function(val, idx) {
225+
return node.id + '.' + idx;
226+
});
227+
})
228+
.then(function(obms) {
229+
obms.push('RackHD');
230+
return obms;
231+
})
232+
}).then(function(data) {
233+
return redfish.render('wsman.1.0.0.computersystem.1.0.0.json',
234+
'ComputerSystem.1.0.0.json#/definitions/ComputerSystem',
235+
_.merge(options, data));
236+
}).catch(function(error) {
237+
return redfish.handleError(error, res);
238+
});
239+
} else {
240+
241+
return Promise.props({
242+
ohai: dataFactory(identifier, 'ohai'),
243+
dmi: dataFactory(identifier, 'dmi'),
244+
chassis: dataFactory(identifier, 'chassis'),
245+
chassisData: dataFactory(identifier, 'chassisData'),
246+
obm: Promise.resolve(node)
247+
.then(function(node) {
248+
return _.map(node.obms, function(val, idx) {
249+
return node.id + '.' + idx;
250+
});
251+
})
252+
.then(function(obms) {
253+
obms.push('RackHD');
254+
return obms;
255+
})
256+
}).then(function(data) {
257+
return redfish.render('redfish.1.0.0.computersystem.1.0.0.json',
258+
'ComputerSystem.1.0.0.json#/definitions/ComputerSystem',
259+
_.merge(options, data));
260+
}).catch(function(error) {
261+
return redfish.handleError(error, res);
262+
});
263+
}
235264
});
236265
});
237266

0 commit comments

Comments
 (0)