remove proxmox-rrd-api-types crate, s/RRDTimeFrameResolution/RRDTimeFrame/
Because the types used inside the RRD have other requirements than the API types: - other serialization format - the API may not support all RRD features Signed-off-by: Dietmar Maurer <dietmar@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
426dda0730
commit
c68fa58a59
@ -27,7 +27,6 @@ members = [
|
||||
"pbs-fuse-loop",
|
||||
"pbs-runtime",
|
||||
"proxmox-rest-server",
|
||||
"proxmox-rrd-api-types",
|
||||
"proxmox-rrd",
|
||||
"proxmox-systemd",
|
||||
"pbs-tape",
|
||||
@ -119,7 +118,6 @@ pbs-config = { path = "pbs-config" }
|
||||
pbs-datastore = { path = "pbs-datastore" }
|
||||
pbs-runtime = { path = "pbs-runtime" }
|
||||
proxmox-rest-server = { path = "proxmox-rest-server" }
|
||||
proxmox-rrd-api-types = { path = "proxmox-rrd-api-types" }
|
||||
proxmox-rrd = { path = "proxmox-rrd" }
|
||||
proxmox-systemd = { path = "proxmox-systemd" }
|
||||
pbs-tools = { path = "pbs-tools" }
|
||||
|
1
Makefile
1
Makefile
@ -40,7 +40,6 @@ SUBCRATES := \
|
||||
pbs-fuse-loop \
|
||||
pbs-runtime \
|
||||
proxmox-rest-server \
|
||||
proxmox-rrd-api-types \
|
||||
proxmox-rrd \
|
||||
proxmox-systemd \
|
||||
pbs-tape \
|
||||
|
@ -20,6 +20,5 @@ proxmox-schema = { version = "1.0.0", features = [ "api-macro" ] }
|
||||
proxmox-time = "1.0.0"
|
||||
proxmox-uuid = { version = "1.0.0", features = [ "serde" ] }
|
||||
|
||||
proxmox-rrd-api-types = { path = "../proxmox-rrd-api-types" }
|
||||
proxmox-systemd = { path = "../proxmox-systemd" }
|
||||
pbs-tools = { path = "../pbs-tools" }
|
||||
|
@ -424,4 +424,32 @@ pub const NODE_TASKS_LIST_TASKS_RETURN_TYPE: ReturnType = ReturnType {
|
||||
).schema(),
|
||||
};
|
||||
|
||||
pub use proxmox_rrd_api_types::{RRDMode, RRDTimeFrameResolution};
|
||||
#[api()]
|
||||
#[derive(Copy, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "UPPERCASE")]
|
||||
/// RRD consolidation mode
|
||||
pub enum RRDMode {
|
||||
/// Maximum
|
||||
Max,
|
||||
/// Average
|
||||
Average,
|
||||
}
|
||||
|
||||
#[api()]
|
||||
#[derive(Copy, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
/// RRD time frame
|
||||
pub enum RRDTimeFrame {
|
||||
/// Hour
|
||||
Hour,
|
||||
/// Day
|
||||
Day,
|
||||
/// Week
|
||||
Week,
|
||||
/// Month
|
||||
Month,
|
||||
/// Year
|
||||
Year,
|
||||
/// Decade (10 years)
|
||||
Decade,
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
[package]
|
||||
name = "proxmox-rrd-api-types"
|
||||
version = "0.1.0"
|
||||
authors = ["Proxmox Support Team <support@proxmox.com>"]
|
||||
edition = "2018"
|
||||
description = "API type definitions for proxmox-rrd crate."
|
||||
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
proxmox-schema = { version = "1", features = ["api-macro"] }
|
@ -1,33 +0,0 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox_schema::api;
|
||||
|
||||
#[api()]
|
||||
#[derive(Copy, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "UPPERCASE")]
|
||||
/// RRD consolidation mode
|
||||
pub enum RRDMode {
|
||||
/// Maximum
|
||||
Max,
|
||||
/// Average
|
||||
Average,
|
||||
}
|
||||
|
||||
#[api()]
|
||||
#[derive(Copy, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
/// RRD time frame resolution
|
||||
pub enum RRDTimeFrameResolution {
|
||||
/// Hour
|
||||
Hour,
|
||||
/// Day
|
||||
Day,
|
||||
/// Week
|
||||
Week,
|
||||
/// Month
|
||||
Month,
|
||||
/// Year
|
||||
Year,
|
||||
/// Decade (10 years)
|
||||
Decade,
|
||||
}
|
@ -36,7 +36,7 @@ bitflags!{
|
||||
pub struct RRAv1 {
|
||||
/// Defined the data soure type and consolidation function
|
||||
pub flags: RRAFlags,
|
||||
/// Resulution (seconds) from [RRDTimeFrameResolution]
|
||||
/// Resulution (seconds)
|
||||
pub resolution: u64,
|
||||
/// Last update time (epoch)
|
||||
pub last_update: f64,
|
||||
|
@ -28,7 +28,7 @@ use pxar::EntryKind;
|
||||
use pbs_api_types::{ Authid, BackupContent, Counts, CryptMode,
|
||||
DataStoreListItem, GarbageCollectionStatus, GroupListItem,
|
||||
SnapshotListItem, SnapshotVerifyState, PruneOptions,
|
||||
DataStoreStatus, RRDMode, RRDTimeFrameResolution,
|
||||
DataStoreStatus, RRDMode, RRDTimeFrame,
|
||||
BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA, BACKUP_TIME_SCHEMA,
|
||||
BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA,
|
||||
IGNORE_VERIFIED_BACKUPS_SCHEMA, UPID_SCHEMA,
|
||||
@ -1537,7 +1537,7 @@ pub fn pxar_file_download(
|
||||
schema: DATASTORE_SCHEMA,
|
||||
},
|
||||
timeframe: {
|
||||
type: RRDTimeFrameResolution,
|
||||
type: RRDTimeFrame,
|
||||
},
|
||||
cf: {
|
||||
type: RRDMode,
|
||||
@ -1551,7 +1551,7 @@ pub fn pxar_file_download(
|
||||
/// Read datastore stats
|
||||
pub fn get_rrd_stats(
|
||||
store: String,
|
||||
timeframe: RRDTimeFrameResolution,
|
||||
timeframe: RRDTimeFrame,
|
||||
cf: RRDMode,
|
||||
_param: Value,
|
||||
) -> Result<Value, Error> {
|
||||
|
@ -6,7 +6,7 @@ use proxmox_router::{Permission, Router};
|
||||
use proxmox_schema::api;
|
||||
|
||||
use pbs_api_types::{
|
||||
NODE_SCHEMA, RRDMode, RRDTimeFrameResolution, PRIV_SYS_AUDIT,
|
||||
NODE_SCHEMA, RRDMode, RRDTimeFrame, PRIV_SYS_AUDIT,
|
||||
};
|
||||
|
||||
use crate::extract_rrd_data;
|
||||
@ -14,7 +14,7 @@ use crate::extract_rrd_data;
|
||||
pub fn create_value_from_rrd(
|
||||
basedir: &str,
|
||||
list: &[&str],
|
||||
timeframe: RRDTimeFrameResolution,
|
||||
timeframe: RRDTimeFrame,
|
||||
mode: RRDMode,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
@ -63,7 +63,7 @@ pub fn create_value_from_rrd(
|
||||
schema: NODE_SCHEMA,
|
||||
},
|
||||
timeframe: {
|
||||
type: RRDTimeFrameResolution,
|
||||
type: RRDTimeFrame,
|
||||
},
|
||||
cf: {
|
||||
type: RRDMode,
|
||||
@ -76,7 +76,7 @@ pub fn create_value_from_rrd(
|
||||
)]
|
||||
/// Read node stats
|
||||
fn get_node_stats(
|
||||
timeframe: RRDTimeFrameResolution,
|
||||
timeframe: RRDTimeFrame,
|
||||
cf: RRDMode,
|
||||
_param: Value,
|
||||
) -> Result<Value, Error> {
|
||||
|
@ -14,7 +14,7 @@ use proxmox_router::{
|
||||
use proxmox_router::list_subdirs_api_method;
|
||||
|
||||
use pbs_api_types::{
|
||||
Authid, DATASTORE_SCHEMA, RRDMode, RRDTimeFrameResolution,
|
||||
Authid, DATASTORE_SCHEMA, RRDMode, RRDTimeFrame,
|
||||
PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP,
|
||||
};
|
||||
|
||||
@ -125,7 +125,7 @@ pub fn datastore_status(
|
||||
let get_rrd = |what: &str| extract_rrd_data(
|
||||
&rrd_dir,
|
||||
what,
|
||||
RRDTimeFrameResolution::Month,
|
||||
RRDTimeFrame::Month,
|
||||
RRDMode::Average,
|
||||
);
|
||||
|
||||
|
16
src/lib.rs
16
src/lib.rs
@ -10,7 +10,7 @@ use anyhow::{format_err, Error};
|
||||
|
||||
use proxmox::tools::fs::CreateOptions;
|
||||
|
||||
use pbs_api_types::{RRDMode, RRDTimeFrameResolution};
|
||||
use pbs_api_types::{RRDMode, RRDTimeFrame};
|
||||
use pbs_buildcfg::configdir;
|
||||
use pbs_tools::cert::CertInfo;
|
||||
use proxmox_rrd::{rrd::CF, RRDCache};
|
||||
@ -84,19 +84,19 @@ pub fn initialize_rrd_cache() -> Result<&'static RRDCache, Error> {
|
||||
pub fn extract_rrd_data(
|
||||
basedir: &str,
|
||||
name: &str,
|
||||
timeframe: RRDTimeFrameResolution,
|
||||
timeframe: RRDTimeFrame,
|
||||
mode: RRDMode,
|
||||
) -> Result<Option<(u64, u64, Vec<Option<f64>>)>, Error> {
|
||||
|
||||
let end = proxmox_time::epoch_f64() as u64;
|
||||
|
||||
let (start, resolution) = match timeframe {
|
||||
RRDTimeFrameResolution::Hour => (end - 3600, 60),
|
||||
RRDTimeFrameResolution::Day => (end - 3600*24, 60),
|
||||
RRDTimeFrameResolution::Week => (end - 3600*24*7, 30*60),
|
||||
RRDTimeFrameResolution::Month => (end - 3600*24*30, 30*60),
|
||||
RRDTimeFrameResolution::Year => (end - 3600*24*365, 6*60*60),
|
||||
RRDTimeFrameResolution::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 {
|
||||
|
Loading…
Reference in New Issue
Block a user