traffic-controls: add API/CLI to show current traffic
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
@ -7,6 +7,7 @@ use proxmox_schema::api;
|
||||
use pbs_api_types::TRAFFIC_CONTROL_ID_SCHEMA;
|
||||
|
||||
use proxmox_backup::api2;
|
||||
use proxmox_backup::client_helpers::connect_to_localhost;
|
||||
|
||||
|
||||
#[api(
|
||||
@ -75,10 +76,44 @@ fn show_traffic_control(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
"output-format": {
|
||||
schema: OUTPUT_FORMAT,
|
||||
optional: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
)]
|
||||
/// Show current traffic for all rules.
|
||||
async fn show_current_traffic(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
|
||||
let mut result = client.get(&"api2/json/admin/traffic-control", Some(param)).await?;
|
||||
|
||||
let mut data = result["data"].take();
|
||||
|
||||
let info = &api2::admin::traffic_control::API_METHOD_SHOW_CURRENT_TRAFFIC;
|
||||
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("name"))
|
||||
.column(ColumnConfig::new("rate-in"))
|
||||
.column(ColumnConfig::new("rate-out"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
pub fn traffic_control_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_TRAFFIC_CONTROLS))
|
||||
.insert("traffic", CliCommand::new(&API_METHOD_SHOW_CURRENT_TRAFFIC))
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_TRAFFIC_CONTROL)
|
||||
|
Reference in New Issue
Block a user