Skip to content
Merged
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
34 changes: 34 additions & 0 deletions data/views/redfish-1.0/redfish.1.0.0.DCIMCoolingDomain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"@odata.type": "#DCIMCooling.v1_0_0.DCIMCooling",
"Id": "<%=domain%>",
"Name": "DCIMCooling <%=domain%> Domain",
"DCIMCoolingType": "Domain",
"Status": {
"State": "Enabled",
"Health": "OK"
},

<% types.forEach(function(type) { %>
"<%=type%>":
{
"@odata.id": "<%=basepath%>/DCIMCooling/<%=domain%>/<%=type%>"
},
<% }); %>

"Links": {
"Chassis": [
{
}
],
"ManagedBy": [
{
}
],
"RelatedSystems": [
{
}
]
},
"@odata.context": "/redfish/v1/$metadata#DCIMCooling.DCIMCooling",
"@odata.id": "/redfish/v1/DCIMCooling/<%=domain%>"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@odata.context" : "/redfish/v1/$metadata#CoolingCollection",
"@odata.id": "<%= url %>",
"@odata.type": "#CoolingCollection.CoolingCollection",
"Oem" : {},
"Name": "DCIMCooling Collection",
"Members@odata.count": <%= domains.length %>,
"Members": [
<% domains.forEach(function(domain, i, arr) { %>
{
"@odata.id": "<%= basepath %>/DCIMCooling/<%=domain %>"
}
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
<% }); %>
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"@odata.type": "#<%=type%>Collection.<%=type%>Collection",
"Name": "<%=type%> Collection",
"Members@odata.count": <%= nodes.length %>,

"Members": [
<% nodes.forEach(function(node, i, arr) { %>

{
"@odata.id": "<%= basepath %>/DCIMCooling/<%=node.identifiers[2]%>/<%=node.identifiers[3]%>/<%=node.identifiers[0]%>-<%= node.id %>"
}
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
<% }); %>

],
"@odata.context": "/redfish/v1/$metadata#<%=type%>Collection",
"@odata.id": "/redfish/v1/DCIMCooling/<%=domain%>/<%=type%>"
}



34 changes: 34 additions & 0 deletions data/views/redfish-1.0/redfish.1.0.0.DCIMPowerDomain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"@odata.type": "#DCIMPower.v1_0_0.DCIMPower",
"Id": "<%=domain%>",
"Name": "DCIMPower <%=domain%> Domain",
"DCIMPowerType": "Domain",
"Status": {
"State": "Enabled",
"Health": "OK"
},

<% types.forEach(function(type) { %>
"<%=type%>":
{
"@odata.id": "<%=basepath%>/DCIMPower/<%=domain%>/<%=type%>"
},
<% }); %>

"Links": {
"Chassis": [
{
}
],
"ManagedBy": [
{
}
],
"RelatedSystems": [
{
}
]
},
"@odata.context": "/redfish/v1/$metadata#DCIMPower.DCIMPower",
"@odata.id": "/redfish/v1/DCIMPower/<%=domain%>"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@odata.context" : "/redfish/v1/$metadata#PowerCollection",
"@odata.id": "<%= url %>",
"@odata.type": "#PowerCollection.PowerCollection",
"Oem" : {},
"Name": "DCIMPower Collection",
"Members@odata.count": <%= domains.length %>,
"Members": [
<% domains.forEach(function(domain, i, arr) { %>
{
"@odata.id": "<%= basepath %>/DCIMPower/<%=domain %>"
}
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
<% }); %>
]
}
21 changes: 21 additions & 0 deletions data/views/redfish-1.0/redfish.1.0.0.DCIMPowerTypeCollection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"@odata.type": "#<%=type%>Collection.<%=type%>Collection",
"Name": "<%=type%> Collection",
"Members@odata.count": <%= nodes.length %>,

"Members": [
<% nodes.forEach(function(node, i, arr) { %>

{
"@odata.id": "<%= basepath %>/DCIMPower/<%=node.identifiers[2]%>/<%=node.identifiers[3]%>/<%=node.identifiers[0]%>-<%= node.id %>"
}
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
<% }); %>

],
"@odata.context": "/redfish/v1/$metadata#<%=type%>Collection",
"@odata.id": "/redfish/v1/DCIMPower/<%=domain%>/<%=type%>"
}



12 changes: 8 additions & 4 deletions data/views/redfish-1.0/redfish.1.0.0.chassiscollection.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
"Members@odata.count": <%= nodes.length %>,
"Members": [
<% nodes.forEach(function(node, i, arr) { %>
{
"@odata.id": "<%= basepath %>/Chassis/<%=node%>"
}
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
{
<% if (node.identifiers && node.identifiers.length > 1 && node.identifiers[1].includes('redfish')) { %>
"@odata.id": "<%= basepath %>/Chassis/<%=node.identifiers[0] %>-<%= node.id %>"
<% } else {%>
"@odata.id": "<%= basepath %>/Chassis/<%= node.id %>"
<% } %>
}
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
<% }); %>
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"Members": [
<% nodes.forEach(function(node, i, arr) { %>
{
"@odata.id": "<%= basepath %>/Systems/<%=node.id%>"
<% if (node.identifiers[1] !== undefined && node.identifiers[1].includes('redfish')) { %>
"@odata.id": "<%= basepath %>/Systems/<%=node.identifiers[0] %>-<%= node.id %>"
<% } else {%>
"@odata.id": "<%= basepath %>/Systems/<%= node.id %>"
<% } %>
}
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
<% }); %>
Expand Down
16 changes: 16 additions & 0 deletions data/views/redfish-1.0/redfish.1.0.0.networkdevicecollection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@odata.context" : "<%= basepath %>/$metadata#Systems",
"@odata.id": "<%= url %>",
"@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
"Oem" : {},
"Name": "Network Device Collection",
"Members@odata.count": <%= nodes.length %>,
"Members": [
<% nodes.forEach(function(node, i, arr) { %>
{
"@odata.id": "<%= basepath %>/NetworkDevices/<%=node.identifiers[0] %>-<%= node.id %>"
}
<%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %>
<% }); %>
]
}
149 changes: 77 additions & 72 deletions lib/api/redfish-1.0/chassis.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,17 @@ var listChassis = controller(function(req, res) {
options.nodes = [];

return Promise.each(nodeApi.getAllNodes({type: 'enclosure'}), function(node) {
options.nodes.push(node.id);
options.nodes.push(node);

return Promise.each(_getEnclosedSystems(node), function(objId) {
return waterline.nodes.findByIdentifier(objId)
.then(function(obj) {
return env.get('config.redfish.computeType', 'Other', obj && obj.sku ? [ obj.sku ] : null );
})
.then(function(val) {
if(val === 'Blade') {
options.nodes.push(node.id + '.' + objId);
node.id = node.id + '.' + objId;
options.nodes.push(node);
}
});
});
Expand All @@ -181,6 +183,7 @@ var listChassis = controller(function(req, res) {
var getChassis = controller(function(req, res) {
var chassisId = req.swagger.params.identifier.value.split('.')[0];
var systemId = req.swagger.params.identifier.value.split('.')[1];
var redfishId = redfish.isRedfish(req.swagger.params.identifier.value);
var options = redfish.makeOptions(req, res, req.swagger.params.identifier.value);
var typeEnum = [
"Rack",
Expand All @@ -204,81 +207,83 @@ var getChassis = controller(function(req, res) {
"Component",
"Other" ];

return Promise.all([
nodeApi.getNodeById(chassisId),
systemId ? nodeApi.getNodeById(systemId) : null
])
.tap(function(nodes) {
if(!nodes[1]) {
return Promise.each(_getEnclosedSystems(nodes[0]), function(objId) {
return waterline.nodes.findByIdentifier(objId)
.then(function(obj) {
return env.get('config.redfish.computeType', 'Other', obj && obj.sku ? [ obj.sku ] : null );
})
.then(function(val) {
if(val === 'Blade') {
options.contains = options.contains || [];
options.contains.push(nodes[0].id + '.' + objId);
options.chassisType = 'Enclosure';
if (redfishId.isRedfish) {
return redfish.getRedfishCatalog(req, res);
} else {
return Promise.all([
nodeApi.getNodeById(chassisId),
systemId ? nodeApi.getNodeById(systemId) : null
])
.tap(function (nodes) {
if (!nodes[1]) {
return Promise.each(_getEnclosedSystems(nodes[0]), function (objId) {
return waterline.nodes.findByIdentifier(objId)
.then(function (obj) {
return env.get('config.redfish.computeType', 'Other', obj && obj.sku ? [obj.sku] : null);
})
.then(function (val) {
if (val === 'Blade') {
options.contains = options.contains || [];
options.contains.push(nodes[0].id + '.' + objId);
options.chassisType = 'Enclosure';
}
});
});
} else {
if (_.includes(_getEnclosedSystems(nodes[0]), systemId)) {
options.containedBy = chassisId;
options.chassisType = 'Blade';
}
});
});
} else {
if(_.includes(_getEnclosedSystems(nodes[0]), systemId)) {
options.containedBy = chassisId;
options.chassisType = 'Blade';
}
}
})
.spread(function(chassisNode) {
var systems = _getEnclosedSystems(chassisNode);
var chassisName = chassisNode.name;
if(!_.isEmpty(systems)) {
if (chassisName.indexOf("sys/chassis")!== -1)
{
return Promise.props({
systems: Promise.map(systems, nodeApi.getNodeById.bind(nodeApi)),
catData: dataFactory(chassisNode.id, 'catData'),
chassisData: dataFactory(chassisNode.id, 'chassisData')
}
})
.spread(function (chassisNode) {
var systems = _getEnclosedSystems(chassisNode);
var chassisName = chassisNode.name;
if (!_.isEmpty(systems)) {
if (chassisName.indexOf("sys/chassis") !== -1) {
return Promise.props({
systems: Promise.map(systems, nodeApi.getNodeById.bind(nodeApi)),
catData: dataFactory(chassisNode.id, 'catData'),
chassisData: dataFactory(chassisNode.id, 'chassisData')

});
}
else
{
return Promise.props({
systems: Promise.map(systems, nodeApi.getNodeById.bind(nodeApi)),
catData: dataFactory(systemId || systems[0], 'catData'),
chassisData: dataFactory(systemId || systems[0], 'chassisData')
});
}
});
}
else {
return Promise.props({
systems: Promise.map(systems, nodeApi.getNodeById.bind(nodeApi)),
catData: dataFactory(systemId || systems[0], 'catData'),
chassisData: dataFactory(systemId || systems[0], 'chassisData')
});
}

}
return {};
})
.then(function(obj) {
if(!_.get(options, 'chassisType')) {
options.chassisType = 'Other';
_.forEach(typeEnum,function(type) {
var re = new RegExp(type, 'g');
var match = obj.catData.chassis.type.match(re);
if (match) {
options.chassisType = match.toString().replace(/ /g,'');
}
});
}
return {};
})
.then(function (obj) {
if (!_.get(options, 'chassisType')) {
options.chassisType = 'Other';
_.forEach(typeEnum, function (type) {
var re = new RegExp(type, 'g');
var match = obj.catData.chassis.type.match(re);
if (match) {
options.chassisType = match.toString().replace(/ /g, '');
}
});
}

options.obm = ['RackHD'];
options.targetList = [];
_.forEach(obj.systems, function(system) {
options.targetList.push(system.id);
});
return redfish.render('redfish.1.0.0.chassis.1.0.0.json',
'Chassis.v1_4_0.json#/definitions/Chassis',
_.merge({}, obj, options));
})
.catch(function(error) {
return redfish.handleError(error, res);
});
options.obm = ['RackHD'];
options.targetList = [];
_.forEach(obj.systems, function (system) {
options.targetList.push(system.id);
});
return redfish.render('redfish.1.0.0.chassis.1.0.0.json',
'Chassis.v1_4_0.json#/definitions/Chassis',
_.merge({}, obj, options));
})
.catch(function (error) {
return redfish.handleError(error, res);
});
}
});

var getThermal = controller(function(req, res) {
Expand Down
Loading