agent: add get volume stats handler in agent

retrieve the stats of direct-assigned volumes from the guest

Fixes: #3454

Signed-off-by: shuochen0311 <shuo.chen@databricks.com>
This commit is contained in:
shuochen0311
2022-01-19 09:02:18 -08:00
committed by Feng Wang
parent ea51ef1c40
commit 27fb490228
4 changed files with 189 additions and 2 deletions

View File

@@ -171,6 +171,11 @@ static AGENT_CMDS: &[AgentCmd] = &[
st: ServiceType::Agent,
fp: agent_cmd_sandbox_get_oom_event,
},
AgentCmd {
name: "GetVolumeStats",
st: ServiceType::Agent,
fp: agent_cmd_sandbox_get_volume_stats,
},
AgentCmd {
name: "ListInterfaces",
st: ServiceType::Agent,
@@ -1641,6 +1646,29 @@ fn agent_cmd_sandbox_get_oom_event(
Ok(())
}
fn agent_cmd_sandbox_get_volume_stats(
ctx: &Context,
client: &AgentServiceClient,
_health: &HealthClient,
_options: &mut Options,
args: &str,
) -> Result<()> {
let req: VolumeStatsRequest = utils::make_request(args)?;
let ctx = clone_context(ctx);
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
let reply = client
.get_volume_stats(ctx, &req)
.map_err(|e| anyhow!(e).context(ERR_API_FAILED))?;
info!(sl!(), "response received";
"response" => format!("{:?}", reply));
Ok(())
}
fn agent_cmd_sandbox_copy_file(
ctx: &Context,
client: &AgentServiceClient,