rrd: move creation of serde value into api

there is now a 'extract_cached_data' which just returns
the data of the specified field, and an api function that converts
a list of fields to the correct serde value

this way we do not have to create a serde value in rrd/cache.rs
(makes for a better interface)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Dominik Csapak
2020-06-10 12:02:57 +02:00
committed by Wolfgang Bumiller
parent e693818afc
commit 431cc7b185
4 changed files with 51 additions and 38 deletions

View File

@ -18,6 +18,7 @@ use proxmox::try_block;
use proxmox::{http_err, identity, list_subdirs_api_method, sortable};
use crate::api2::types::*;
use crate::api2::node::rrd::create_value_from_rrd;
use crate::backup::*;
use crate::config::datastore;
use crate::config::cached_user_info::CachedUserInfo;
@ -855,10 +856,8 @@ fn get_rrd_stats(
_param: Value,
) -> Result<Value, Error> {
let rrd_dir = format!("datastore/{}", store);
crate::rrd::extract_data(
&rrd_dir,
create_value_from_rrd(
&format!("datastore/{}", store),
&[
"total", "used",
"read_ios", "read_bytes",