From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 22D4A7543B for ; Wed, 13 Oct 2021 10:25:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 39C6CE795 for ; Wed, 13 Oct 2021 10:25:06 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 9838CE53A for ; Wed, 13 Oct 2021 10:24:58 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7002C4451C; Wed, 13 Oct 2021 10:24:58 +0200 (CEST) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Wed, 13 Oct 2021 10:24:44 +0200 Message-Id: <20211013082452.619406-8-dietmar@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211013082452.619406-1-dietmar@proxmox.com> References: <20211013082452.619406-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.540 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [status.rs, lib.rs, rrd.rs, datastore.rs] Subject: [pbs-devel] [PATCH proxmox-backup 07/15] remove proxmox-rrd-api-types crate, s/RRDTimeFrameResolution/RRDTimeFrame/ X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Oct 2021 08:25:37 -0000 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 "] -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 { 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 { @@ -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 { 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>)>, 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