proxmox-rrd: remove dependency to proxmox-rrd-api-types

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dietmar Maurer
2021-10-13 10:24:42 +02:00
committed by Thomas Lamprecht
parent 1198f8d4e6
commit eb37d4ece2
6 changed files with 54 additions and 41 deletions

View File

@ -9,26 +9,23 @@ use pbs_api_types::{
NODE_SCHEMA, RRDMode, RRDTimeFrameResolution, PRIV_SYS_AUDIT,
};
use crate::get_rrd_cache;
use crate::extract_rrd_data;
pub fn create_value_from_rrd(
basedir: &str,
list: &[&str],
timeframe: RRDTimeFrameResolution,
cf: RRDMode,
mode: RRDMode,
) -> Result<Value, Error> {
let mut result: Vec<Value> = Vec::new();
let now = proxmox_time::epoch_f64();
let rrd_cache = get_rrd_cache()?;
let mut timemap = BTreeMap::new();
let mut last_resolution = None;
for name in list {
let (start, reso, data) = match rrd_cache.extract_cached_data(basedir, name, now, timeframe, cf)? {
let (start, reso, data) = match extract_rrd_data(basedir, name, timeframe, mode)? {
Some(result) => result,
None => continue,
};

View File

@ -22,7 +22,7 @@ use pbs_datastore::DataStore;
use pbs_config::CachedUserInfo;
use crate::tools::statistics::{linear_regression};
use crate::get_rrd_cache;
use crate::extract_rrd_data;
#[api(
returns: {
@ -90,8 +90,6 @@ pub fn datastore_status(
let mut list = Vec::new();
let rrd_cache = get_rrd_cache()?;
for (store, (_, _)) in &config.sections {
let user_privs = user_info.lookup_privs(&auth_id, &["datastore", &store]);
let allowed = (user_privs & (PRIV_DATASTORE_AUDIT| PRIV_DATASTORE_BACKUP)) != 0;
@ -123,13 +121,10 @@ pub fn datastore_status(
});
let rrd_dir = format!("datastore/{}", store);
let now = proxmox_time::epoch_f64();
let get_rrd = |what: &str| rrd_cache.extract_cached_data(
let get_rrd = |what: &str| extract_rrd_data(
&rrd_dir,
what,
now,
RRDTimeFrameResolution::Month,
RRDMode::Average,
);