@@ -533,8 +533,34 @@ func (cs *controllerServer) GetCapacity(ctx context.Context, req *csi.GetCapacit
533
533
return nil , status .Error (codes .Unimplemented , fmt .Sprintf ("GetCapacity is not yet implemented" ))
534
534
}
535
535
536
- func (cs * controllerServer ) ControllerGetVolume (context.Context , * csi.ControllerGetVolumeRequest ) (* csi.ControllerGetVolumeResponse , error ) {
537
- return nil , status .Error (codes .Unimplemented , fmt .Sprintf ("ControllerGetVolume is not yet implemented" ))
536
+ func (cs * controllerServer ) ControllerGetVolume (ctx context.Context , req * csi.ControllerGetVolumeRequest ) (* csi.ControllerGetVolumeResponse , error ) {
537
+ volumeID := req .GetVolumeId ()
538
+ if len (volumeID ) == 0 {
539
+ return nil , status .Error (codes .InvalidArgument , "Volume ID not provided" )
540
+ }
541
+
542
+ volume , err := cs .Cloud .GetVolume (volumeID )
543
+ if err != nil {
544
+ if cpoerrors .IsNotFound (err ) {
545
+ return nil , status .Error (codes .NotFound , "Volume not found" )
546
+ }
547
+ return nil , status .Error (codes .Internal , fmt .Sprintf ("ControllerGetVolume failed with error %v" , err ))
548
+ }
549
+
550
+ ventry := csi.ControllerGetVolumeResponse {
551
+ Volume : & csi.Volume {
552
+ VolumeId : volumeID ,
553
+ CapacityBytes : int64 (volume .Size * 1024 * 1024 * 1024 ),
554
+ },
555
+ }
556
+
557
+ status := & csi.ControllerGetVolumeResponse_VolumeStatus {}
558
+ for _ , attachment := range volume .Attachments {
559
+ status .PublishedNodeIds = append (status .PublishedNodeIds , attachment .ServerID )
560
+ }
561
+ ventry .Status = status
562
+
563
+ return & ventry , nil
538
564
}
539
565
540
566
func (cs * controllerServer ) ControllerExpandVolume (ctx context.Context , req * csi.ControllerExpandVolumeRequest ) (* csi.ControllerExpandVolumeResponse , error ) {
0 commit comments