diff --git a/Cargo.toml b/Cargo.toml index 4668baffe..fc1409d66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ proxmox-rest-server = { version = "0.8", features = [ "templates" ] } # some use "cli", some use "cli" and "server", pbs-config uses nothing proxmox-router = { version = "3.0.0", default-features = false } proxmox-rrd = "0.4" -proxmox-rrd-api-types = "1" +proxmox-rrd-api-types = "1.0.2" # everything but pbs-config and pbs-client use "api-macro" proxmox-schema = "3" proxmox-section-config = "2" diff --git a/debian/control b/debian/control index 902d1d609..5329ae53d 100644 --- a/debian/control +++ b/debian/control @@ -83,7 +83,7 @@ Build-Depends: bash-completion, librust-proxmox-router-3+cli-dev, librust-proxmox-router-3+server-dev, librust-proxmox-rrd-0.4+default-dev, - librust-proxmox-rrd-api-types-1+default-dev, + librust-proxmox-rrd-api-types-1+default-dev (>= 1.0.2-~~), librust-proxmox-schema-3+api-macro-dev, librust-proxmox-schema-3+default-dev, librust-proxmox-section-config-2+default-dev, diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 0fd89760f..5dcbc850d 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -22,7 +22,7 @@ use proxmox_router::{ http_err, list_subdirs_api_method, ApiHandler, ApiMethod, ApiResponseFuture, Permission, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap, }; -use proxmox_rrd_api_types::{RRDMode, RRDTimeFrame}; +use proxmox_rrd_api_types::{RrdMode, RrdTimeframe}; use proxmox_schema::*; use proxmox_sortable_macro::sortable; use proxmox_sys::fs::{ @@ -1925,10 +1925,10 @@ pub fn pxar_file_download( schema: DATASTORE_SCHEMA, }, timeframe: { - type: RRDTimeFrame, + type: RrdTimeframe, }, cf: { - type: RRDMode, + type: RrdMode, }, }, }, @@ -1940,8 +1940,8 @@ pub fn pxar_file_download( /// Read datastore stats pub fn get_rrd_stats( store: String, - timeframe: RRDTimeFrame, - cf: RRDMode, + timeframe: RrdTimeframe, + cf: RrdMode, _param: Value, ) -> Result { let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; diff --git a/src/api2/node/rrd.rs b/src/api2/node/rrd.rs index 88b753e7e..95a2816e8 100644 --- a/src/api2/node/rrd.rs +++ b/src/api2/node/rrd.rs @@ -3,7 +3,7 @@ use serde_json::{json, Value}; use std::collections::BTreeMap; use proxmox_router::{Permission, Router}; -use proxmox_rrd_api_types::{RRDMode, RRDTimeFrame}; +use proxmox_rrd_api_types::{RrdMode, RrdTimeframe}; use proxmox_schema::api; use pbs_api_types::{NODE_SCHEMA, PRIV_SYS_AUDIT}; @@ -13,8 +13,8 @@ use crate::rrd_cache::extract_rrd_data; pub fn create_value_from_rrd( basedir: &str, list: &[&str], - timeframe: RRDTimeFrame, - mode: RRDMode, + timeframe: RrdTimeframe, + mode: RrdMode, ) -> Result { let mut result: Vec = Vec::new(); @@ -65,10 +65,10 @@ pub fn create_value_from_rrd( schema: NODE_SCHEMA, }, timeframe: { - type: RRDTimeFrame, + type: RrdTimeframe, }, cf: { - type: RRDMode, + type: RrdMode, }, }, }, @@ -77,7 +77,7 @@ pub fn create_value_from_rrd( }, )] /// Read node stats -fn get_node_stats(timeframe: RRDTimeFrame, cf: RRDMode, _param: Value) -> Result { +fn get_node_stats(timeframe: RrdTimeframe, cf: RrdMode, _param: Value) -> Result { create_value_from_rrd( "host", &[ diff --git a/src/api2/status.rs b/src/api2/status.rs index 9fcc55c67..0b0b9444f 100644 --- a/src/api2/status.rs +++ b/src/api2/status.rs @@ -5,7 +5,7 @@ use serde_json::Value; use proxmox_router::list_subdirs_api_method; use proxmox_router::{ApiMethod, Permission, Router, RpcEnvironment, SubdirMap}; -use proxmox_rrd_api_types::{RRDMode, RRDTimeFrame}; +use proxmox_rrd_api_types::{RrdMode, RrdTimeframe}; use proxmox_schema::api; use pbs_api_types::{ @@ -82,7 +82,7 @@ pub async fn datastore_status( let rrd_dir = format!("datastore/{}", store); let get_rrd = - |what: &str| extract_rrd_data(&rrd_dir, what, RRDTimeFrame::Month, RRDMode::Average); + |what: &str| extract_rrd_data(&rrd_dir, what, RrdTimeframe::Month, RrdMode::Average); let total_res = get_rrd("total")?; let used_res = get_rrd("used")?; diff --git a/src/rrd_cache.rs b/src/rrd_cache.rs index c1a193427..32e0b5c53 100644 --- a/src/rrd_cache.rs +++ b/src/rrd_cache.rs @@ -14,7 +14,7 @@ use proxmox_rrd::Cache; use proxmox_sys::fs::CreateOptions; use pbs_buildcfg::PROXMOX_BACKUP_STATE_DIR_M; -use proxmox_rrd_api_types::{RRDMode, RRDTimeFrame}; +use proxmox_rrd_api_types::{RrdMode, RrdTimeframe}; const RRD_CACHE_BASEDIR: &str = concat!(PROXMOX_BACKUP_STATE_DIR_M!(), "/rrdb"); @@ -94,23 +94,23 @@ fn create_callback(dst: DataSourceType) -> Database { pub fn extract_rrd_data( basedir: &str, name: &str, - timeframe: RRDTimeFrame, - mode: RRDMode, + timeframe: RrdTimeframe, + mode: RrdMode, ) -> Result, Error> { let end = proxmox_time::epoch_f64() as u64; let (start, resolution) = match timeframe { - RRDTimeFrame::Hour => (end - 3600, 60), - RRDTimeFrame::Day => (end - 3600 * 24, 60), - RRDTimeFrame::Week => (end - 3600 * 24 * 7, 30 * 60), - RRDTimeFrame::Month => (end - 3600 * 24 * 30, 30 * 60), - RRDTimeFrame::Year => (end - 3600 * 24 * 365, 6 * 60 * 60), - RRDTimeFrame::Decade => (end - 10 * 3600 * 24 * 366, 7 * 86400), + RrdTimeframe::Hour => (end - 3600, 60), + RrdTimeframe::Day => (end - 3600 * 24, 60), + RrdTimeframe::Week => (end - 3600 * 24 * 7, 30 * 60), + RrdTimeframe::Month => (end - 3600 * 24 * 30, 30 * 60), + RrdTimeframe::Year => (end - 3600 * 24 * 365, 6 * 60 * 60), + RrdTimeframe::Decade => (end - 10 * 3600 * 24 * 366, 7 * 86400), }; let cf = match mode { - RRDMode::Max => AggregationFn::Maximum, - RRDMode::Average => AggregationFn::Average, + RrdMode::Max => AggregationFn::Maximum, + RrdMode::Average => AggregationFn::Average, }; let rrd_cache = get_rrd_cache()?;