Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions data/views/redfish-1.0/redfish.1.0.0.bios.1.0.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"@odata.context" : "<%= basepath %>/$metadata#Systems/<%= identifier %>/Bios",
"@odata.id": "<%= url %>",
"@odata.type": "#Bios.1.0.0.Bios",
"Actions": {
"Oem": {}
},
"@Redfish.Settings": {
"@odata.type": "#Settings.v1_0_0.Settings",
"ETag": "",
"Messages": [],
"SettingsObject": {
"@odata.id": "/redfish/v1/Systems/<%= identifier %>/Bios/Settings"
},
"Time": ""
},
"AttributeRegistry": "",
"Attributes": {
<% bios.attributes.forEach(function(item, i, arr) { %>
"<%= item.attributeName.value %>": %> "<%= item.currentValue[0].value %>"
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
<% }); %>
},
"Description": "BIOS Configuration Current Settings",
"Id": "Bios",
"Name": "BIOS Configuration Current Settings",
"Oem": {},
"Actions": {
"#Bios.ResetBios": {
"target": "/redfish/v1/Systems/1/Bios/Actions/Bios.ResetBios"
},
"#Bios.ChangePassword": {
"target": "/redfish/v1/Systems/1/Bios/Actions/Bios.ChangePassword"
}
}
}
16 changes: 16 additions & 0 deletions data/views/redfish-1.0/redfish.1.0.0.bios.1.0.0.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@odata.context" : "<%= basepath %>/$metadata#Systems/<%= identifier %>/Bios/Settings",
"@odata.id": "<%= url %>",
"@odata.type": "#Bios.1.0.0.Bios",
"AttributeRegistry": "",
"Attributes": {
<% bios.attributes.forEach(function(item, i, arr) { %>
"<%= item.attributeName.value %>": %> "<%= item.currentValue[0].value %>"
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
<% }); %>
},
"Description": "BIOS Configuration Current Settings",
"Id": "Bios",
"Name": "BIOS Configuration Current Settings",
"Oem": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"HostName": "",
"IndicatorLED": "<%= chassisData.uid %>",
"PowerState": "<%= chassisData.power==='Unknown' ? 'On' : chassisData.power %>",
"Bios": {},
"Boot": {},
"BiosVersion": "<%= ohai.data.dmi.bios.version.trim() %> <%= ohai.data.dmi.bios.bios_revision.trim() %> <%= ohai.data.dmi.bios.release_date.trim() %>",
"ProcessorSummary": {
Expand Down
3 changes: 3 additions & 0 deletions data/views/redfish-1.0/wsman.1.0.0.computersystem.1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"HostName": "<% hardware.data.system.hostName %>",
"IndicatorLED": "<%= hardware.data.leds[0] || 'Unknown' %>",
"PowerState": "<%= hardware.data.system.powerState == 2 ? 'On' : 'Off' %>",
"Bios": {
"@odata.id": "<%= basepath %>/Systems/<%= identifier %>/Bios"
},
"Boot": {},
"BiosVersion": "<%= hardware.data.system.biosVersionString.trim() %> <%= hardware.data.system.biosReleaseDate.trim() %> ",
"ProcessorSummary": {
Expand Down
174 changes: 174 additions & 0 deletions lib/api/redfish-1.0/systems.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ var nodeApi = injector.get('Http.Services.Api.Nodes');
var controller = injector.get('Http.Services.Swagger').controller;
var Errors = injector.get('Errors');
var moment = require('moment');
var configuration = injector.get('Services.Configuration');

var southboundApiRouter = _.filter(configuration.get('httpEndpoints', []),
_.matches({routers:'southbound-api-router'}))[0];

var dataFactory = function(identifier, dataName) {
switch(dataName) {
Expand All @@ -20,6 +24,8 @@ var dataFactory = function(identifier, dataName) {
case 'smart':
case 'hardware':
case 'boot':
case 'bios':
case 'DeviceSummary':
return nodeApi.getNodeCatalogSourceById(identifier, dataName);

case 'chassis':
Expand Down Expand Up @@ -273,6 +279,171 @@ var getSystem = controller(function(req, res) {
});
});


/**
* Generate information about the bios of a specific system
* @param {Object} req
* @param {Object} res
*/
var listSystemBios = controller(function(req, res) {
var identifier = req.swagger.params.identifier.value;
var options = redfish.makeOptions(req, res, identifier);

return waterline.nodes.getNodeById(identifier)
.then(function(node){
var dellFound = false;
node.identifiers.forEach(function(ident) {
if(/^[0-9|A-Z]{7}$/.test(ident)){
dellFound = true;
}
});
if(dellFound){
return dataFactory(identifier, 'bios').then(function(bios) {
options.bios = bios;
bios.attributes = [];
var key;
// create a single bios attribute list (not organized by type)
for(key in bios.data) {
if (bios.data.hasOwnProperty(key)) {
bios.attributes = bios.attributes.concat(bios.data[key]);
}
}
// normalize the currentValue field (some need value fields)
for(key in bios.attributes) {
if (bios.attributes[key].currentValue[0] === null) {
bios.attributes[key].currentValue[0] = {"value": null};
}
}
}).then(function(){
return redfish.render('redfish.1.0.0.bios.1.0.0.json',
'Bios.v1_0_1.json#/definitions/Bios',
options);
});
} else {
// TODO: Non-Dell still needs work
options.bios = {"source": "bios", "attributes": []};
return redfish.render('redfish.1.0.0.bios.1.0.0.json',
'Bios.v1_0_1.json#/definitions/Bios',
options);
}
}).catch(function(error) {
return redfish.handleError(error, res);
});
});


/**
* Generate information about the bios settings data of a specific system
* @param {Object} req
* @param {Object} res
*/
var listSystemBiosSettings = controller(function(req, res) {
var identifier = req.swagger.params.identifier.value;
var options = redfish.makeOptions(req, res, identifier);

return waterline.nodes.getNodeById(identifier)
.then(function(node){
var dellFound = false;
node.identifiers.forEach(function(ident) {
if(/^[0-9|A-Z]{7}$/.test(ident)){
dellFound = true;
}
});
if(dellFound){
return dataFactory(identifier, 'bios').then(function(bios) {
options.bios = bios;
bios.attributes = [];
var key;

// create a single bios attribute list (not organized by type)
for(key in bios.data) {
if (bios.data.hasOwnProperty(key)) {
bios.attributes = bios.attributes.concat(bios.data[key]);
}
}
for (key = bios.attributes.length - 1; key >= 0; key -= 1) {
// remove entries that are readOnly
if (bios.attributes[key].isReadOnly.value === "true") {
bios.attributes.splice(key, 1);
continue;
}
// normalize the currentValue field (some need value fields)
if (bios.attributes[key].currentValue[0] === null) {
bios.attributes[key].currentValue[0] = {"value": null};
}
}
}).then(function(){
return redfish.render('redfish.1.0.0.bios.1.0.0.settings.json',
'Bios.v1_0_1.json#/definitions/Bios',
options);
});
} else {
// TODO: Non-Dell still needs work
options.bios = {"source": "bios", "attributes": []};
return redfish.render('redfish.1.0.0.bios.1.0.0.settings.json',
'Bios.v1_0_1.json#/definitions/Bios',
options);
}
}).catch(function(error) {
return redfish.handleError(error, res);
});
});


/**
* Patch information about the bios settings data of a specific system
* @param {Object} req
* @param {Object} res
*/
var patchSystemBiosSettings = controller(function(req, res) {

var identifier = req.swagger.params.identifier.value;
var options = redfish.makeOptions(req, res, identifier);
var payload = req.swagger.params.payload.value;

return waterline.nodes.getNodeById(identifier)
.then(function(node){
var dellFound = false;
node.identifiers.forEach(function(ident) {
if(/^[0-9|A-Z]{7}$/.test(ident)){
dellFound = true;
}
});
if(dellFound){
var results = { name: "Graph.Dell.Wsman.UpdateSystemComponents", options: {} };

return dataFactory(identifier, 'DeviceSummary').then(function(summary) {
results.options = {
defaults: {
serverIP: summary.data.id,
fileName: "",
shareType: 0,
shareAddress: southboundApiRouter.address,
shareName: "/nfs",
shutdownType: 0,
serverUsername: "",
serverPassword: "",
serverComponents: [{fqdd: "BIOS.Setup.1-1", attributes: []}]
}
};
for (var key in payload.Attributes) {
if (payload.Attributes.hasOwnProperty(key)) {
results.options.defaults.serverComponents[0].attributes.push(
{name: key, value: payload.Attributes[key]});
}
}
}).then(function() {
return nodeApi.setNodeWorkflowById( results, identifier);
});
} else {
// TODO: Non-Dell still needs work
options.bios = {"source": "bios", "attributes": []};
}
}).catch(function(error) {
return redfish.handleError(error, res);
});
});

/**
* Generate information about the processors of a specific system
* @param {Object} req
Expand Down Expand Up @@ -782,6 +953,9 @@ var doBootImage = controller(function(req,res) {
module.exports = {
listSystems: listSystems,
getSystem: getSystem,
listSystemBios: listSystemBios,
listSystemBiosSettings: listSystemBiosSettings,
patchSystemBiosSettings: patchSystemBiosSettings,
listSystemProcessors: listSystemProcessors,
getSystemProcessor: getSystemProcessor,
listSimpleStorage: listSimpleStorage,
Expand Down
Loading