@@ -33,6 +33,7 @@ type DiskOps interface {
3333 DiskCreate (context.Context , * rpc.DiskCreateRequest ) (* rpc.Disk , error )
3434 DiskDelete (* rpc.DiskDeleteRequest ) (* emptypb.Empty , error )
3535 DiskGet (req * rpc.DiskGetRequest ) (* rpc.Disk , error )
36+ DiskHealthGet (req * rpc.DiskHealthGetRequest ) (* rpc.DiskHealthGetResponse , error )
3637 DiskReplicaInstanceList (* rpc.DiskReplicaInstanceListRequest ) (* rpc.DiskReplicaInstanceListResponse , error )
3738 DiskReplicaInstanceDelete (* rpc.DiskReplicaInstanceDeleteRequest ) (* emptypb.Empty , error )
3839 MetricsGet (* rpc.DiskGetRequest ) (* rpc.DiskMetricsGetReply , error )
@@ -202,6 +203,53 @@ func (ops BlockDiskOps) DiskGet(req *rpc.DiskGetRequest) (*rpc.Disk, error) {
202203 return spdkDiskToDisk (ret ), nil
203204}
204205
206+ func (s * Server ) DiskHealthGet (ctx context.Context , req * rpc.DiskHealthGetRequest ) (* rpc.DiskHealthGetResponse , error ) {
207+ if req .DiskName == "" {
208+ return nil , grpcstatus .Error (grpccodes .InvalidArgument , "disk name is required" )
209+ }
210+
211+ ops , ok := s .ops [req .DiskType ]
212+ if ! ok {
213+ return nil , grpcstatus .Errorf (grpccodes .Unimplemented , "unsupported disk type %v" , req .DiskType )
214+ }
215+ return ops .DiskHealthGet (req )
216+ }
217+
218+ func (op FilesystemDiskOps ) DiskHealthGet (req * rpc.DiskHealthGetRequest ) (* rpc.DiskHealthGetResponse , error ) {
219+ return nil , grpcstatus .Errorf (grpccodes .Unimplemented , "unsupported disk type %v" , req .DiskType )
220+ }
221+
222+ func (op BlockDiskOps ) DiskHealthGet (req * rpc.DiskHealthGetRequest ) (* rpc.DiskHealthGetResponse , error ) {
223+ health , err := op .spdkClient .DiskHealthGet (req .DiskName , req .DiskPath , req .DiskDriver )
224+ if err != nil {
225+ return nil , grpcstatus .Error (grpccodes .Internal , err .Error ())
226+ }
227+
228+ return & rpc.DiskHealthGetResponse {
229+ ModelNumber : health .ModelNumber ,
230+ SerialNumber : health .SerialNumber ,
231+ FirmwareRevision : health .FirmwareRevision ,
232+ Traddr : health .Traddr ,
233+ CriticalWarning : health .CriticalWarning ,
234+ TemperatureCelsius : health .TemperatureCelsius ,
235+ AvailableSparePercentage : health .AvailableSparePercentage ,
236+ AvailableSpareThresholdPercentage : health .AvailableSpareThresholdPercentage ,
237+ PercentageUsed : health .PercentageUsed ,
238+ DataUnitsRead : health .DataUnitsRead ,
239+ DataUnitsWritten : health .DataUnitsWritten ,
240+ HostReadCommands : health .HostReadCommands ,
241+ HostWriteCommands : health .HostWriteCommands ,
242+ ControllerBusyTime : health .ControllerBusyTime ,
243+ PowerCycles : health .PowerCycles ,
244+ PowerOnHours : health .PowerOnHours ,
245+ UnsafeShutdowns : health .UnsafeShutdowns ,
246+ MediaErrors : health .MediaErrors ,
247+ NumErrLogEntries : health .NumErrLogEntries ,
248+ WarningTemperatureTimeMinutes : health .WarningTemperatureTimeMinutes ,
249+ CriticalCompositeTemperatureTimeMinutes : health .CriticalCompositeTemperatureTimeMinutes ,
250+ }, nil
251+ }
252+
205253func (s * Server ) DiskReplicaInstanceList (ctx context.Context , req * rpc.DiskReplicaInstanceListRequest ) (* rpc.DiskReplicaInstanceListResponse , error ) {
206254 log := logrus .WithFields (logrus.Fields {
207255 "diskType" : req .DiskType ,
0 commit comments