@@ -43,6 +43,7 @@ use gateway_types::rot::RotCfpaSlot;
4343use gateway_types:: rot:: RotCmpa ;
4444use gateway_types:: rot:: RotState ;
4545use gateway_types:: sensor:: SpSensorReading ;
46+ use gateway_types:: task_dump:: TaskDump ;
4647use gateway_types:: update:: HostPhase2Progress ;
4748use gateway_types:: update:: HostPhase2RecoveryImageId ;
4849use gateway_types:: update:: InstallinatorImageId ;
@@ -655,6 +656,66 @@ impl GatewayApi for GatewayImpl {
655656 apictx. latencies . instrument_dropshot_handler ( & rqctx, handler) . await
656657 }
657658
659+ async fn sp_host_task_dump_count (
660+ rqctx : RequestContext < Self :: Context > ,
661+ path : Path < PathSp > ,
662+ ) -> Result < HttpResponseOk < u32 > , HttpError > {
663+ let apictx = rqctx. context ( ) ;
664+ let sp_id = path. into_inner ( ) . sp . into ( ) ;
665+
666+ let handler = async {
667+ let sp = apictx. mgmt_switch . sp ( sp_id) ?;
668+ let ct = sp. task_dump_count ( ) . await . map_err ( |err| {
669+ SpCommsError :: SpCommunicationFailed { sp : sp_id, err }
670+ } ) ?;
671+
672+ Ok ( HttpResponseOk ( ct) )
673+ } ;
674+ apictx. latencies . instrument_dropshot_handler ( & rqctx, handler) . await
675+ }
676+
677+ async fn sp_host_task_dump_get (
678+ rqctx : RequestContext < Self :: Context > ,
679+ path : Path < PathSpTaskDumpIndex > ,
680+ ) -> Result < HttpResponseOk < TaskDump > , HttpError > {
681+ let apictx = rqctx. context ( ) ;
682+ let path = path. into_inner ( ) ;
683+ let task_index = path. task_dump_index ;
684+ let sp_id = path. sp . into ( ) ;
685+
686+ let handler = async {
687+ let sp = apictx. mgmt_switch . sp ( sp_id) ?;
688+ let raw_dump =
689+ sp. task_dump_read ( task_index) . await . map_err ( |err| {
690+ SpCommsError :: SpCommunicationFailed { sp : sp_id, err }
691+ } ) ?;
692+
693+ let archive_id = hex:: encode ( raw_dump. archive_id ) ;
694+ let base64_memory = raw_dump
695+ . memory
696+ . into_iter ( )
697+ . map ( |( key, mem) | {
698+ let base64_mem =
699+ base64:: engine:: general_purpose:: STANDARD . encode ( mem) ;
700+ ( key, base64_mem)
701+ } )
702+ . collect ( ) ;
703+
704+ let dump = TaskDump {
705+ task_index : raw_dump. task_index ,
706+ timestamp : raw_dump. timestamp ,
707+ archive_id,
708+ bord : raw_dump. bord ,
709+ gitc : raw_dump. gitc ,
710+ vers : raw_dump. vers ,
711+ base64_memory,
712+ } ;
713+
714+ Ok ( HttpResponseOk ( dump) )
715+ } ;
716+ apictx. latencies . instrument_dropshot_handler ( & rqctx, handler) . await
717+ }
718+
658719 async fn ignition_list (
659720 rqctx : RequestContext < Self :: Context > ,
660721 ) -> Result < HttpResponseOk < Vec < SpIgnitionInfo > > , HttpError > {
0 commit comments