@@ -289,7 +289,6 @@ var listSystemProcessors = controller(function(req, res) {
289289
290290 return wsman . isDellSystem ( identifier )
291291 . then ( function ( result ) {
292- var node = result . node ;
293292 if ( result . isDell ) {
294293 return dataFactory ( identifier , 'hardware' ) . then ( function ( hardware ) {
295294 options . hardware = hardware ;
@@ -330,7 +329,6 @@ var getSystemProcessor = controller(function(req, res) {
330329
331330 return wsman . isDellSystem ( identifier )
332331 . then ( function ( result ) {
333- var node = result . node ;
334332 if ( result . isDell ) {
335333 return Promise . props ( {
336334 socketId : req . swagger . params . socket . value ,
@@ -375,7 +373,6 @@ var listSimpleStorage = controller(function(req, res) {
375373
376374 return wsman . isDellSystem ( identifier )
377375 . then ( function ( result ) {
378- var node = result . node ;
379376 if ( result . isDell ) {
380377 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
381378 . then ( function ( hardware ) {
@@ -443,7 +440,6 @@ var getSimpleStorage = controller(function(req, res) {
443440
444441 return wsman . isDellSystem ( identifier )
445442 . then ( function ( result ) {
446- var node = result . node ;
447443 if ( result . isDell ) {
448444 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
449445 . then ( function ( hardware ) {
@@ -515,7 +511,6 @@ var listStorage = controller(function(req, res) {
515511
516512 return wsman . isDellSystem ( identifier )
517513 . then ( function ( result ) {
518- var node = result . node ;
519514 if ( result . isDell ) {
520515 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
521516 . then ( function ( hardware ) {
@@ -541,7 +536,7 @@ var listStorage = controller(function(req, res) {
541536 return redfish . handleError ( error , res ) ;
542537 } ) ;
543538 } else {
544- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
539+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
545540 }
546541 } ) ;
547542} ) ;
@@ -560,7 +555,6 @@ var getStorage = controller(function(req, res) {
560555
561556 return wsman . isDellSystem ( identifier )
562557 . then ( function ( result ) {
563- var node = result . node ;
564558 if ( result . isDell ) {
565559 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
566560 . then ( function ( hardware ) {
@@ -604,7 +598,7 @@ var getStorage = controller(function(req, res) {
604598 return redfish . handleError ( error , res ) ;
605599 } ) ;
606600 } else {
607- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
601+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
608602 }
609603 } ) ;
610604} ) ;
@@ -626,7 +620,6 @@ var getDrive = controller(function(req, res) {
626620
627621 return wsman . isDellSystem ( identifier )
628622 . then ( function ( result ) {
629- var node = result . node ;
630623 if ( result . isDell ) {
631624 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
632625 . then ( function ( hardware ) {
@@ -647,7 +640,7 @@ var getDrive = controller(function(req, res) {
647640 return redfish . handleError ( error , res ) ;
648641 } ) ;
649642 } else {
650- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
643+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
651644 }
652645 } ) ;
653646} ) ;
@@ -661,7 +654,6 @@ var listVolume = controller(function(req, res) {
661654 options . index = index ;
662655 return wsman . isDellSystem ( identifier )
663656 . then ( function ( result ) {
664- var node = result . node ;
665657 if ( result . isDell ) {
666658 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
667659 . then ( function ( hardware ) {
@@ -678,7 +670,7 @@ var listVolume = controller(function(req, res) {
678670 return redfish . handleError ( error , res ) ;
679671 } ) ;
680672 } else {
681- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
673+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
682674 }
683675 } ) ;
684676} ) ;
@@ -700,7 +692,6 @@ var getVolume = controller(function(req, res) {
700692
701693 return wsman . isDellSystem ( identifier )
702694 . then ( function ( result ) {
703- var node = result . node ;
704695 if ( result . isDell ) {
705696 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
706697 . then ( function ( hardware ) {
@@ -723,7 +714,7 @@ var getVolume = controller(function(req, res) {
723714 return redfish . handleError ( error , res ) ;
724715 } ) ;
725716 } else {
726- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
717+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
727718 }
728719 } ) ;
729720} ) ;
@@ -737,12 +728,19 @@ var listLogService = controller(function(req, res) {
737728 var identifier = req . swagger . params . identifier . value ;
738729 var options = redfish . makeOptions ( req , res , identifier ) ;
739730
740- options . logSource = [ 'sel' , 'lc' ] ;
741- return redfish . render ( 'redfish.1.0.0.logservicecollection.json' ,
742- 'LogServiceCollection.json#/definitions/LogServiceCollection' ,
743- options )
744- . catch ( function ( error ) {
745- return redfish . handleError ( error , res ) ;
731+ return wsman . isDellSystem ( identifier )
732+ . then ( function ( result ) {
733+ if ( result . isDell ) {
734+ options . logSource = [ 'sel' , 'lc' ] ;
735+ } else {
736+ options . logSource = [ 'sel' ] ;
737+ }
738+ return redfish . render ( 'redfish.1.0.0.logservicecollection.json' ,
739+ 'LogServiceCollection.json#/definitions/LogServiceCollection' ,
740+ options )
741+ . catch ( function ( error ) {
742+ return redfish . handleError ( error , res ) ;
743+ } ) ;
746744 } ) ;
747745} ) ;
748746
@@ -766,10 +764,8 @@ var getSelLogService = controller(function(req, res) {
766764 return wsman . getLog ( node , options . type )
767765 . then ( function ( sel ) {
768766 options . log . size = sel . length || 0 ;
769- options . log . policy = sel . Overflow && sel . Overflow === 'false' ?
770- 'WrapsWhenFull' :
771- 'NeverOverWrites' ;
772- options . log . lastWriteDate = sel . creationTimeStamp || 'Unknown' ;
767+ options . log . policy = 'WrapsWhenFull' ;
768+ options . log . lastWriteDate = sel . length > 0 ? sel [ 0 ] . creationTimeStamp : 'Unknown' ;
773769 return redfish . render ( 'redfish.1.0.0.logservice.1.0.0.json' ,
774770 'LogService.v1_0_3.json#/definitions/LogService' ,
775771 options ) ;
@@ -921,18 +917,16 @@ var getLcLogService = controller(function(req, res) {
921917 return wsman . getLog ( node , options . type )
922918 . then ( function ( lc ) {
923919 options . log . size = lc . length || 0 ;
924- options . log . policy = lc . Overflow && lc . Overflow === 'false' ?
925- 'WrapsWhenFull' :
926- 'NeverOverWrites' ;
927- options . log . lastWriteDate = lc . creationTimeStamp || 'Unknown' ;
920+ options . log . policy = 'WrapsWhenFull' ;
921+ options . log . lastWriteDate = lc . length > 0 ? lc [ 0 ] . creationTimeStamp : 'Unknown' ;
928922 return redfish . render ( 'redfish.1.0.0.logservice.1.0.0.json' ,
929923 'LogService.v1_0_3.json#/definitions/LogService' ,
930924 options ) ;
931925 } ) . catch ( function ( error ) {
932926 return redfish . handleError ( error , res ) ;
933927 } ) ;
934928 } else {
935- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
929+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
936930 }
937931 } ) ;
938932} ) ;
@@ -962,7 +956,7 @@ var listLcLogServiceEntries = controller(function(req, res) {
962956 return redfish . handleError ( error , res ) ;
963957 } ) ;
964958 } else {
965- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
959+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
966960 }
967961 } ) ;
968962} ) ;
@@ -1003,7 +997,7 @@ var getLcLogServiceEntry = controller(function(req, res) {
1003997 return redfish . handleError ( error , res ) ;
1004998 } ) ;
1005999 } else {
1006- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
1000+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
10071001 }
10081002 } ) ;
10091003} ) ;
@@ -1163,11 +1157,9 @@ var deleteVolume = controller(function(req,res) {
11631157 } ;
11641158 return wsman . isDellSystem ( identifier )
11651159 . then ( function ( result ) {
1166- var node = result . node ;
11671160 if ( result . isDell ) {
11681161 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
11691162 . then ( function ( hardware ) {
1170- if ( ! dellFound ) { throw "Delete volume not implemented for non-Dell hardware" ; }
11711163 graphOptions . defaults . volumeId = hardware . data . storage . virtualDisks [ volumeIndex ] . fqdd ;
11721164 graphOptions . defaults . ipAddress = hardware . data . id ;
11731165 } ) . then ( function ( ) {
@@ -1183,7 +1175,7 @@ var deleteVolume = controller(function(req,res) {
11831175 return redfish . handleError ( error , res ) ;
11841176 } ) ;
11851177 } else {
1186- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
1178+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
11871179 }
11881180 } ) ;
11891181} ) ;
@@ -1203,33 +1195,34 @@ var addVolume = controller(function(req,res) {
12031195
12041196 return wsman . isDellSystem ( identifier )
12051197 . then ( function ( result ) {
1206- var node = result . node ;
12071198 if ( result . isDell ) {
12081199 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
12091200 . then ( function ( hardware ) {
1210- if ( ! dellFound ) { throw "Add Volume not implemented for non-Dell hardware." ; }
12111201 var driveIndices = [ ] ;
1212- for ( i = 0 ; i < payload . volume . Links . Drives . length ; i ++ )
1202+ for ( var i = 0 ; i < payload . volume . Links . Drives . length ; i ++ )
12131203 {
12141204 var odataId = payload . volume . Links . Drives [ i ] [ '@odata.id' ] . split ( '/' ) ;
12151205 var ind = odataId [ odataId . length - 1 ] ;
12161206 driveIndices . push ( ind ) ;
12171207 }
1218- if ( driveIndices . length === 0 ) { throw "No Drives specified for the Volume to use." ; }
1208+ if ( driveIndices . length === 0 ) {
1209+ throw new Error ( "No Drives specified for the Volume to use." ) ;
1210+ }
12191211 graphOptions . defaults . ipAddress = hardware . data . id ;
12201212 graphOptions . defaults . name = payload . volume . Name ;
1221- if ( graphOptions . defaults . name . indexOf ( " " ) !== - 1 ) { throw "Virtual disk name cannot have spaces" ; }
1213+ if ( graphOptions . defaults . name . indexOf ( " " ) !== - 1 ) {
1214+ throw new Error ( "Virtual disk name cannot have spaces" ) ;
1215+ }
12221216 graphOptions . defaults . sizeInBytes = payload . volume . CapacityBytes ;
12231217 graphOptions . defaults . drives = "" ;
1224- for ( i = 0 ; i < driveIndices . length ; i ++ )
1225- {
1226- if ( driveIndices [ i ] >= hardware . data . storage . physicalDisks . length ) {
1227- throw "No drive exists with id " + driveIndices [ i ] ;
1228- }
1218+ for ( var i = 0 ; i < driveIndices . length ; i ++ ) {
1219+ if ( driveIndices [ i ] >= hardware . data . storage . physicalDisks . length ) {
1220+ throw "No drive exists with id " + driveIndices [ i ] ;
1221+ }
12291222 graphOptions . defaults . drives += hardware . data . storage . physicalDisks [ driveIndices [ i ] ] . fqdd ;
1230- if ( i + 1 < driveIndices . length ) {
1231- graphOptions . defaults . drives += ',' ;
1232- }
1223+ if ( i + 1 < driveIndices . length ) {
1224+ graphOptions . defaults . drives += ',' ;
1225+ }
12331226 }
12341227 var raidLevel = payload . volume . VolumeType ;
12351228 switch ( raidLevel )
@@ -1265,7 +1258,7 @@ var addVolume = controller(function(req,res) {
12651258 return redfish . handleError ( error , res ) ;
12661259 } ) ;
12671260 } else {
1268- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
1261+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
12691262 }
12701263 } ) ;
12711264} ) ;
@@ -1290,11 +1283,9 @@ var addHotspare = controller(function(req,res) {
12901283 } ;
12911284 return wsman . isDellSystem ( identifier )
12921285 . then ( function ( result ) {
1293- var node = result . node ;
12941286 if ( result . isDell ) {
12951287 return Promise . resolve ( dataFactory ( identifier , 'hardware' ) )
12961288 . then ( function ( hardware ) {
1297- if ( ! dellFound ) { throw "Add hotspare not implemented for non-Dell hardware" ; }
12981289 graphOptions . defaults . driveId = hardware . data . storage . physicalDisks [ driveIndex ] . fqdd ;
12991290 graphOptions . defaults . ipAddress = hardware . data . id ;
13001291 if ( payload . hotspareType === 'dhs' ) {
@@ -1319,7 +1310,7 @@ var addHotspare = controller(function(req,res) {
13191310 return redfish . handleError ( error , res ) ;
13201311 } ) ;
13211312 } else {
1322- return redfish . handleError ( new Error ( "Not implemented for non-Dell hardware." , res ) ) ;
1313+ return redfish . handleError ( "Not implemented for non-Dell hardware." , res , null , 501 ) ;
13231314 }
13241315 } ) ;
13251316} ) ;
0 commit comments