[pbs-devel] [PATCH proxmox-backup 07/15] remove proxmox-rrd-api-types crate, s/RRDTimeFrameResolution/RRDTimeFrame/
Dietmar Maurer
dietmar at proxmox.com
Wed Oct 13 10:24:44 CEST 2021
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
---
Cargo.toml | 2 --
Makefile | 1 -
pbs-api-types/Cargo.toml | 1 -
pbs-api-types/src/lib.rs | 30 ++++++++++++++++++++++++++++-
proxmox-rrd-api-types/Cargo.toml | 11 -----------
proxmox-rrd-api-types/src/lib.rs | 33 --------------------------------
proxmox-rrd/src/rrd_v1.rs | 2 +-
src/api2/admin/datastore.rs | 6 +++---
src/api2/node/rrd.rs | 8 ++++----
src/api2/status.rs | 4 ++--
src/lib.rs | 16 ++++++++--------
11 files changed, 47 insertions(+), 67 deletions(-)
delete mode 100644 proxmox-rrd-api-types/Cargo.toml
delete mode 100644 proxmox-rrd-api-types/src/lib.rs
diff --git a/Cargo.toml b/Cargo.toml
index d2e3fa1f..772588f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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" }
diff --git a/Makefile b/Makefile
index 6b098aa1..d6951c9a 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,6 @@ SUBCRATES := \
pbs-fuse-loop \
pbs-runtime \
proxmox-rest-server \
- proxmox-rrd-api-types \
proxmox-rrd \
proxmox-systemd \
pbs-tape \
diff --git a/pbs-api-types/Cargo.toml b/pbs-api-types/Cargo.toml
index 2a51bd3a..11644399 100644
--- a/pbs-api-types/Cargo.toml
+++ b/pbs-api-types/Cargo.toml
@@ -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" }
diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs
index cdf765a1..96ac657b 100644
--- a/pbs-api-types/src/lib.rs
+++ b/pbs-api-types/src/lib.rs
@@ -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,
+}
diff --git a/proxmox-rrd-api-types/Cargo.toml b/proxmox-rrd-api-types/Cargo.toml
deleted file mode 100644
index 816f7fde..00000000
--- a/proxmox-rrd-api-types/Cargo.toml
+++ /dev/null
@@ -1,11 +0,0 @@
-[package]
-name = "proxmox-rrd-api-types"
-version = "0.1.0"
-authors = ["Proxmox Support Team <support at 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"] }
diff --git a/proxmox-rrd-api-types/src/lib.rs b/proxmox-rrd-api-types/src/lib.rs
deleted file mode 100644
index 32601477..00000000
--- a/proxmox-rrd-api-types/src/lib.rs
+++ /dev/null
@@ -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,
-}
diff --git a/proxmox-rrd/src/rrd_v1.rs b/proxmox-rrd/src/rrd_v1.rs
index 919896f0..511b510b 100644
--- a/proxmox-rrd/src/rrd_v1.rs
+++ b/proxmox-rrd/src/rrd_v1.rs
@@ -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,
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index 7e98b4a9..fb5647ce 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -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> {
diff --git a/src/api2/node/rrd.rs b/src/api2/node/rrd.rs
index 21a55bb7..9b6780b7 100644
--- a/src/api2/node/rrd.rs
+++ b/src/api2/node/rrd.rs
@@ -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> {
diff --git a/src/api2/status.rs b/src/api2/status.rs
index 9a72ce52..a3456ad4 100644
--- a/src/api2/status.rs
+++ b/src/api2/status.rs
@@ -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,
);
diff --git a/src/lib.rs b/src/lib.rs
index 6745627a..a5a28190 100644
--- a/src/lib.rs
+++ b/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 {
--
2.30.2
More information about the pbs-devel
mailing list