MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / stop_container

Method stop_container

crates/openshell-driver-podman/src/client.rs:425–446  ·  view source on GitHub ↗

Stop a container with a grace period in seconds.

(
        &self,
        name: &str,
        timeout_secs: u32,
    )

Source from the content-addressed store, hash-verified

423
424 /// Stop a container with a grace period in seconds.
425 pub async fn stop_container(
426 &self,
427 name: &str,
428 timeout_secs: u32,
429 ) -> Result<(), PodmanApiError> {
430 validate_name(name)?;
431 let http_timeout = Duration::from_secs(u64::from(timeout_secs) + 5);
432 let (status, bytes) = self
433 .request(
434 hyper::Method::POST,
435 &format!("/libpod/containers/{name}/stop?timeout={timeout_secs}"),
436 None,
437 http_timeout,
438 )
439 .await?;
440 let code = status.as_u16();
441 if status.is_success() || code == 304 {
442 Ok(())
443 } else {
444 Err(error_from_response(code, &bytes))
445 }
446 }
447
448 /// Force-remove a container and its anonymous volumes.
449 pub async fn remove_container(&self, name: &str) -> Result<(), PodmanApiError> {

Callers 4

stop_sandboxMethod · 0.80
delete_sandboxMethod · 0.80
stop_sandbox_innerMethod · 0.80

Calls 3

validate_nameFunction · 0.85
error_from_responseFunction · 0.85
requestMethod · 0.80

Tested by

no test coverage detected