diff --git a/gateway-cli/src/main.rs b/gateway-cli/src/main.rs index 8a01c2b9d9..662f98d5c0 100644 --- a/gateway-cli/src/main.rs +++ b/gateway-cli/src/main.rs @@ -435,8 +435,10 @@ async fn main() -> Result<()> { .into_inner(); dumper.dump(&info)?; } - Command::ComponentClearStatus { .. } => { - todo!("missing MGS endpoint"); + Command::ComponentClearStatus { sp, component } => { + client + .sp_component_clear_status(sp.type_, sp.slot, &component) + .await?; } Command::UsartAttach { sp, diff --git a/gateway/src/http_entrypoints.rs b/gateway/src/http_entrypoints.rs index 336236a710..5a25bf7f6e 100644 --- a/gateway/src/http_entrypoints.rs +++ b/gateway/src/http_entrypoints.rs @@ -621,6 +621,28 @@ async fn sp_component_get( Ok(HttpResponseOk(details.entries.into_iter().map(Into::into).collect())) } +/// Clear status of a component +/// +/// For components that maintain event counters (e.g., the sidecar `monorail`), +/// this will reset the event counters to zero. +#[endpoint { + method = POST, + path = "/sp/{type}/{slot}/component/{component}/clear-status", +}] +async fn sp_component_clear_status( + rqctx: RequestContext>, + path: Path, +) -> Result { + let apictx = rqctx.context(); + let PathSpComponent { sp, component } = path.into_inner(); + let sp = apictx.mgmt_switch.sp(sp.into())?; + let component = component_from_str(&component)?; + + sp.component_clear_status(component).await.map_err(SpCommsError::from)?; + + Ok(HttpResponseUpdatedNoContent {}) +} + /// Get the currently-active slot for an SP component /// /// Note that the meaning of "current" in "currently-active" may vary depending @@ -1052,6 +1074,7 @@ pub fn api() -> GatewayApiDescription { api.register(sp_power_state_set)?; api.register(sp_component_list)?; api.register(sp_component_get)?; + api.register(sp_component_clear_status)?; api.register(sp_component_active_slot_get)?; api.register(sp_component_active_slot_set)?; api.register(sp_component_serial_console_attach)?; diff --git a/openapi/gateway.json b/openapi/gateway.json index 9211662d7f..2e7cf580ce 100644 --- a/openapi/gateway.json +++ b/openapi/gateway.json @@ -452,6 +452,53 @@ } } }, + "/sp/{type}/{slot}/component/{component}/clear-status": { + "post": { + "summary": "Clear status of a component", + "description": "For components that maintain event counters (e.g., the sidecar `monorail`), this will reset the event counters to zero.", + "operationId": "sp_component_clear_status", + "parameters": [ + { + "in": "path", + "name": "component", + "description": "ID for the component of the SP; this is the internal identifier used by the SP itself to identify its components.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "slot", + "required": true, + "schema": { + "type": "integer", + "format": "uint32", + "minimum": 0 + } + }, + { + "in": "path", + "name": "type", + "required": true, + "schema": { + "$ref": "#/components/schemas/SpType" + } + } + ], + "responses": { + "204": { + "description": "resource updated" + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, "/sp/{type}/{slot}/component/{component}/serial-console/attach": { "get": { "summary": "Upgrade into a websocket connection attached to the given SP component's",