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

Function run_ip

crates/openshell-supervisor-process/src/netns/mod.rs:471–491  ·  view source on GitHub ↗

Run an `ip` command on the host.

(args: &[&str])

Source from the content-addressed store, hash-verified

469
470/// Run an `ip` command on the host.
471fn run_ip(args: &[&str]) -> Result<()> {
472 let ip_path = find_trusted_binary("ip", IP_SEARCH_PATHS)?;
473
474 debug!(command = %format!("{ip_path} {}", args.join(" ")), "Running ip command");
475
476 let output = Command::new(ip_path)
477 .args(args)
478 .output()
479 .into_diagnostic()?;
480
481 if !output.status.success() {
482 let stderr = String::from_utf8_lossy(&output.stderr);
483 return Err(miette::miette!(
484 "{ip_path} {} failed: {}",
485 args.join(" "),
486 stderr.trim()
487 ));
488 }
489
490 Ok(())
491}
492
493/// Run an `ip` command inside a network namespace via `nsenter --net=`.
494///

Callers 2

createMethod · 0.85
dropMethod · 0.85

Calls 2

find_trusted_binaryFunction · 0.85
successMethod · 0.45

Tested by

no test coverage detected