diff --git a/data/views/redfish-1.0/wsman.1.0.0.lclogentry.1.0.0.json b/data/views/redfish-1.0/wsman.1.0.0.lclogentry.1.0.0.json new file mode 100644 index 000000000..d42b60bf5 --- /dev/null +++ b/data/views/redfish-1.0/wsman.1.0.0.lclogentry.1.0.0.json @@ -0,0 +1,32 @@ +{ + "@odata.context" : "<%= basepath %>/$metadata#Systems/Links/Members/<%= identifier %>/LogServices/Members/<%=type%>/$entity", + "@odata.id": "<%= basepath %>/Systems/<%=identifier%>/LogServices/<%=type%>/Entries/<%= entry.recordId %>", + "@odata.type": "#LogEntry.1.0.0.LogEntry", + "Oem": { + "Dell":{ + "Log Name": "<%= entry.logName %>", + "Category": "<%= entry.category %>", + "Entry Id": "<%= entry.instanceId %>", + "Severity": "<%= entry.severity %>", + "Comment": "<%= entry.comment %>", + "Agent": "<%= entry.agentId %>", + "fqdd": "<%= entry.fqdd %>", + "Raw Event Data": "<%= entry.rawEventData %>", + "Sequence Number": "<%= entry.sequenceNumber %>" + } + }, + "Id": "<%= entry.recordId %>", + "Name": "<%= entry.elementName %>", + "EntryType": "Oem", + "Created": "<%= entry.creationTimeStamp %>", + "OemRecordFormat": "", + "Message": "<%= entry.message %>", + "MessageId": "<%= entry.messageId %>", + "MessageArgs": ["<%= entry.messageArguments %>"], + "Links": { + "Oem": {}, + "OriginOfCondition": { + "@odata.id": "<%= entry.origin || 'null' %>" + } + } +} diff --git a/data/views/redfish-1.0/wsman.1.0.0.lclogentrycollection.json b/data/views/redfish-1.0/wsman.1.0.0.lclogentrycollection.json new file mode 100644 index 000000000..b4a9dcdcf --- /dev/null +++ b/data/views/redfish-1.0/wsman.1.0.0.lclogentrycollection.json @@ -0,0 +1,44 @@ +{ + "@odata.context" : "<%= basepath %>/$metadata#Systems/Links/Members/<%= identifier %>/LogServices/Members/<%=type%>/Entries", + "@odata.id": "<%= url %>", + "@odata.type": "#LogEntryCollection.LogEntryCollection", + "Oem" : {}, + "Name": "Log Service Entry Collection", + "Members@odata.count": <%= logEntries.length %>, + "Members": [ + <% logEntries.forEach(function(entry, i, arr) { %> + { + "@odata.id": "<%= basepath %>/Systems/<%=identifier%>/LogServices/<%=type%>/Entries/<%= entry.recordId %>", + "@odata.type": "#LogEntry.1.0.0.LogEntry", + "Oem": { + "Dell":{ + "Log Name": "<%= entry.logName %>", + "Category": "<%= entry.category %>", + "Severity": "<%= entry.severity %>", + "Comment": "<%= entry.comment %>", + "Agent": "<%= entry.agentId %>", + "fqdd": "<%= entry.fqdd %>", + "Raw Event Data": "<%= entry.rawEventData %>", + "Sequence Number": "<%= entry.sequenceNumber %>" + } + }, + "Id": "<%= entry.recordId %>", + "Name": "<%= entry.elementName %>", + "EntryType": "<%= type %>", + "Created": "<%= entry.creationTimeStamp %>", + "OemRecordFormat": "", + "EntryCode": "<%= entry.instanceId %>", + "Message": "<%= entry.message %>", + "MessageId": "<%= entry.messageId %>", + "MessageArgs": ["<%= entry.messageArguments %>"], + "Links": { + "Oem": {}, + "OriginOfCondition": { + "@odata.id": "<%= entry.origin || 'null' %>" + } + } + } + <%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %> + <% }); %> + ] +} diff --git a/data/views/redfish-1.0/wsman.1.0.0.logentry.1.0.0.json b/data/views/redfish-1.0/wsman.1.0.0.logentry.1.0.0.json new file mode 100644 index 000000000..a7ff901c1 --- /dev/null +++ b/data/views/redfish-1.0/wsman.1.0.0.logentry.1.0.0.json @@ -0,0 +1,25 @@ +{ + "@odata.context" : "<%= basepath %>/$metadata#Systems/Links/Members/<%= identifier %>/LogServices/Members/<%=type%>/$entity", + "@odata.id": "<%= basepath %>/Systems/<%=identifier%>/LogServices/<%=type%>/Entries/<%= entry.logId %>", + "@odata.type": "#LogEntry.1.0.0.LogEntry", + "Oem": { + "Dell":{ + "instanceID": "<%= entry.instanceID %>", + "perceivedSeverity": "<%= entry.perceivedSeverity %>" + } + }, + "Id": "<%= entry.recordID %>", + "Name": "<%= entry.elementName %>", + "EntryType": "<%= type %>", + "Created": "<%= entry.creationTimeStamp %>", + "OemRecordFormat": "", + "Message": "<%= entry.recordData %>", + "MessageId": "", + "MessageArgs": [], + "Links": { + "Oem": {}, + "OriginOfCondition": { + "@odata.id": "<%= entry.origin || 'null' %>" + } + } +} diff --git a/data/views/redfish-1.0/wsman.1.0.0.logentrycollection.json b/data/views/redfish-1.0/wsman.1.0.0.logentrycollection.json new file mode 100644 index 000000000..0f4d1ec44 --- /dev/null +++ b/data/views/redfish-1.0/wsman.1.0.0.logentrycollection.json @@ -0,0 +1,38 @@ +{ + "@odata.context" : "<%= basepath %>/$metadata#Systems/Links/Members/<%= identifier %>/LogServices/Members/<%=type%>/Entries", + "@odata.id": "<%= url %>", + "@odata.type": "#LogEntryCollection.LogEntryCollection", + "Oem" : {}, + "Name": "Log Service Entry Collection", + "Members@odata.count": <%= logEntries.length %>, + "Members": [ + <% logEntries.forEach(function(entry, i, arr) { %> + { + "@odata.id": "<%= basepath %>/Systems/<%=identifier%>/LogServices/<%=type%>/Entries/<%= entry.recordID %>", + "@odata.type": "#LogEntry.1.0.0.LogEntry", + "Oem": { + "Dell":{ + "Log Name": "<%= entry.logName %>", + "Instance Id": "<%= entry.instanceID %>", + "Perceived Severity": "<%= entry.perceivedSeverity %>" + } + }, + "Id": "<%= entry.recordID %>", + "Name": "<%= entry.elementName %>", + "EntryType": "<%= type %>", + "Created": "<%= entry.creationTimeStamp %>", + "OemRecordFormat": "", + "Message": "<%= entry.recordData %>", + "MessageId": "", + "MessageArgs": [], + "Links": { + "Oem": {}, + "OriginOfCondition": { + "@odata.id": "<%= entry.origin || 'null' %>" + } + } + } + <%= ( arr.length > 0 && i < arr.length-1 ) ? ',': '' %> + <% }); %> + ] +} diff --git a/lib/api/redfish-1.0/systems.js b/lib/api/redfish-1.0/systems.js index ca9d48a6f..98c7c2a0a 100755 --- a/lib/api/redfish-1.0/systems.js +++ b/lib/api/redfish-1.0/systems.js @@ -13,6 +13,7 @@ var controller = injector.get('Http.Services.Swagger').controller; var Errors = injector.get('Errors'); var moment = require('moment'); var racadm = injector.get('JobUtils.RacadmTool'); +var wsman = injector.get('Http.Services.Wsman'); var dataFactory = function(identifier, dataName) { switch(dataName) { @@ -224,16 +225,10 @@ var getSystem = controller(function(req, res) { var options = redfish.makeOptions(req, res, identifier); options.systemType = 'Physical'; - return waterline.nodes.getNodeById(identifier) - .then(function(node){ -// if(/^[0-9|A-Z]{7}$/.test(node.name)){ - var dellFound = false; - for(var i=0; i 1){ + speedInDecimal += "." + speed[1]; } - controllers[id].push(ele); - }); - options.controllers = []; - _.forEach(hardware.data.storage.controllers, function(ele) { - var speed = ele.possibleSpeed; //possibleSpeed format is X_X_GBS or X_GBS, convert to decimal - var speedInDecimal; - if (speed){ - speed = speed.split('_'); - speed.splice(speed.length - 1, 1); - speedInDecimal = speed[0]; - if (speed.length > 1){ - speedInDecimal += "." + speed[1]; - } - } - else { - speedInDecimal = 0; - } - ele.possibleSpeed = speedInDecimal; - //console.log("speedInGbs: " + speedInDecimal); - options.controllers.push(ele); - }); + } + else { + speedInDecimal = 0; + } + ele.possibleSpeed = speedInDecimal; + options.controllers.push(ele); + }); - options.drives = []; -// console.log("CONTROLLER: " + JSON.stringify(options.controller, null, 4)); - _.forEach(hardware.data.storage.physicalDisks, function(ele) { -// console.log("DEVICE: " + JSON.stringify(ele, null, 4)); - //ele.size = ele.size.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " bytes"; - options.drives.push(ele); - }); + options.drives = []; + _.forEach(hardware.data.storage.physicalDisks, function(ele) { + options.drives.push(ele); + }); - return redfish.render('redfish.2016.3.storage.1.1.1.json', - 'Storage.v1_1_1.json#/definitions/Storage', - options); + return redfish.render('redfish.2016.3.storage.1.1.1.json', + 'Storage.v1_1_1.json#/definitions/Storage', + options); }).catch(function(error) { return redfish.handleError(error, res); }); - // } else { - // } + } else { + return redfish.handleError(new Error("Not implemented for non-Dell hardware.", res)); + } }); }); @@ -669,35 +624,31 @@ var getDrive = controller(function(req, res) { options.identifier = identifier; options.index = index; - return waterline.nodes.getNodeById(identifier) - .then(function(node){ - var dellFound = false; - for(var i=0; i -1){ - options.volumeIds.push(i); - } - } - return redfish.render('redfish.2016.3.drive.1.1.1.json', - 'Drive.v1_1_1.json#/definitions/Drive', - options); + .then(function(hardware) { + options.hardware = hardware; + options.drive = hardware.data.storage.physicalDisks[driveIndex]; + options.volumeIds = []; + //get redfish ids of all volumes related to this drive + var currFqdd = hardware.data.storage.physicalDisks[driveIndex].fqdd; + for(var i = 0; i < hardware.data.storage.virtualDisks.length; i++){ + if (hardware.data.storage.virtualDisks[i].physicalDiskIds.indexOf(currFqdd) > -1){ + options.volumeIds.push(i); + } + } + return redfish.render('redfish.2016.3.drive.1.1.1.json', + 'Drive.v1_1_1.json#/definitions/Drive', + options); }).catch(function(error) { return redfish.handleError(error, res); }); - // } else { - // } + } else { + return redfish.handleError(new Error("Not implemented for non-Dell hardware.", res)); + } }); }); @@ -708,31 +659,27 @@ var listVolume = controller(function(req, res) { options.identifier = identifier; options.index = index; - return waterline.nodes.getNodeById(identifier) - .then(function(node){ - var dellFound = false; - for(var i=0; i= hardware.data.storage.physicalDisks.length){ throw "No drive exists with id " + driveIndices[i]; } - graphOptions.defaults.drives += hardware.data.storage.physicalDisks[driveIndices[i]].fqdd; + graphOptions.defaults.drives += hardware.data.storage.physicalDisks[driveIndices[i]].fqdd; if (i+1 < driveIndices.length){ graphOptions.defaults.drives += ','; } - } - var raidLevel = payload.volume.VolumeType; - switch(raidLevel) - { - case "NonRedundant": - graphOptions.defaults.raidLevel = 'r0'; - break; - case "Mirrored": - graphOptions.defaults.raidLevel = 'r1'; - break; - case "StripedWithParity": - graphOptions.defaults.raidLevel = 'r5'; - break; - case "SpannedMirrors": - graphOptions.defaults.raidLevel = 'r10'; - break; - case "SpannedStripesWithParity": - graphOptions.defaults.raidLevel = 'r50'; - break; - default: - throw "Invalid Raid Level for creating volume"; - } + } + var raidLevel = payload.volume.VolumeType; + switch(raidLevel) + { + case "NonRedundant": + graphOptions.defaults.raidLevel = 'r0'; + break; + case "Mirrored": + graphOptions.defaults.raidLevel = 'r1'; + break; + case "StripedWithParity": + graphOptions.defaults.raidLevel = 'r5'; + break; + case "SpannedMirrors": + graphOptions.defaults.raidLevel = 'r10'; + break; + case "SpannedStripesWithParity": + graphOptions.defaults.raidLevel = 'r50'; + break; + default: + throw "Invalid Raid Level for creating volume"; + } }).then(function(){ - return nodeApi.setNodeWorkflowById({ name: graphName, options: graphOptions }, identifier); + return nodeApi.setNodeWorkflowById({ name: graphName, options: graphOptions }, identifier); }).then(function reportTask(data) { return { '@odata.id': options.basepath + '/TaskService/Tasks/' + data.instanceId @@ -1171,8 +1264,9 @@ var addVolume = controller(function(req,res) { }).catch(function(error) { return redfish.handleError(error, res); }); - - // } + } else { + return redfish.handleError(new Error("Not implemented for non-Dell hardware.", res)); + } }); }); @@ -1181,7 +1275,6 @@ var addHotspare = controller(function(req,res) { var options = redfish.makeOptions(req, res, identifier); var driveIndex = req.swagger.params.driveIndex.value; var payload = req.swagger.params.payload.value; - console.log(" type: " + payload.hotspareType); /* payload looks like for dhs: { @@ -1191,29 +1284,14 @@ var addHotspare = controller(function(req,res) { } */ - if(payload.hotspareType == 'dhs'){ - console.log("username: " + payload.username + " password: " + payload.password + " volumeId " + payload.volumeId); - - } - else{ - console.log("username: " + payload.username + " password: " + payload.password); - - } - console.log("reached add hotspare method"); - var graphName = 'Graph.Add.Hotspare'; var graphOptions = { defaults: payload }; - return waterline.nodes.getNodeById(identifier) - .then(function(node){ - var dellFound = false; - for(var i=0; i + Defines a collection of SEL entries for the system described by + identifier. + operationId: getLcLogService + tags: [ "/redfish/v1" ] + parameters: + - name: identifier + in: path + required: true + type: string + x-param-handler: sku + responses: + 200: + description: Success + schema: + $ref: "#/definitions/LogService.1.0.0_LogService" + 400: + $ref: "#/responses/status_400" + 401: + $ref: "#/responses/status_401" + 403: + $ref: "#/responses/status_403" + 404: + $ref: "#/responses/status_404" + 500: + description: Error + schema: + $ref: "#/definitions/ErrorResponse" + /Systems/{identifier}/LogServices/lc/Entries: + x-swagger-router-controller: systems + get: + x-privileges: [ 'Login' ] + x-authentication-type: [ 'redfish', 'basic' ] + summary: retrieve list of the logs entries for associated for log service + description: > + Defines a collection of entries for the system described by identifier + operationId: listLcLogServiceEntries + tags: [ "/redfish/v1" ] + parameters: + - name: identifier + in: path + required: true + type: string + x-param-handler: sku + responses: + 200: + description: Success + schema: + $ref: "#/definitions/LogEntryCollection_LogEntryCollection" + 400: + $ref: "#/responses/status_400" + 401: + $ref: "#/responses/status_401" + 403: + $ref: "#/responses/status_403" + 404: + $ref: "#/responses/status_404" + 500: + description: Error + schema: + $ref: "#/definitions/ErrorResponse" + /Systems/{identifier}/LogServices/lc/Entries/{entryId}: + x-swagger-router-controller: systems + get: + x-privileges: [ 'Login' ] + x-authentication-type: [ 'redfish', 'basic' ] + summary: retrieve log entry by logId associated for log service + description: > + Defines a log entry specified by entryId within the LogService of the + specified type for the system described by identifier + operationId: getLcLogServiceEntry + tags: [ "/redfish/v1" ] + parameters: + - name: identifier + in: path + required: true + type: string + x-param-handler: sku + - name: entryId + in: path + required: true + type: string + responses: + 200: + description: Success + schema: + $ref: "#/definitions/LogEntry.1.0.0_LogEntry" + 400: + $ref: "#/responses/status_400" + 401: + $ref: "#/responses/status_401" + 403: + $ref: "#/responses/status_403" + 404: + $ref: "#/responses/status_404" + 500: + description: Error + schema: + $ref: "#/definitions/ErrorResponse" /Systems/{identifier}/Actions/ComputerSystem.Reset: x-swagger-router-controller: systems get: