split out RRD api types into proxmox-rrd-api-types crate

This commit is contained in:
Dietmar Maurer 2021-10-06 09:49:51 +02:00
parent a97301350f
commit d1c3bc5350
13 changed files with 61 additions and 41 deletions

View File

@ -27,6 +27,7 @@ members = [
"pbs-fuse-loop",
"pbs-runtime",
"proxmox-rest-server",
"proxmox-rrd-api-types",
"proxmox-rrd",
"proxmox-systemd",
"pbs-tape",
@ -108,6 +109,7 @@ 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" }

View File

@ -40,6 +40,7 @@ SUBCRATES := \
pbs-fuse-loop \
pbs-runtime \
proxmox-rest-server \
proxmox-rrd-api-types \
proxmox-rrd \
proxmox-systemd \
pbs-tape \

View File

@ -16,5 +16,6 @@ serde = { version = "1.0", features = ["derive"] }
proxmox = { version = "0.13.5", default-features = false, features = [ "api-macro" ] }
proxmox-rrd-api-types = { path = "../proxmox-rrd-api-types" }
proxmox-systemd = { path = "../proxmox-systemd" }
pbs-tools = { path = "../pbs-tools" }

View File

@ -423,3 +423,5 @@ pub const NODE_TASKS_LIST_TASKS_RETURN_TYPE: ReturnType = ReturnType {
&TaskListItem::API_SCHEMA,
).schema(),
};
pub use proxmox_rrd_api_types::{RRDMode, RRDTimeFrameResolution};

View File

@ -0,0 +1,11 @@
[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 = [] }
proxmox = { version = "0.13.5", features = ["api-macro"] }

View File

@ -0,0 +1,31 @@
use serde::{Deserialize, Serialize};
use proxmox::api::api;
#[api()]
#[derive(Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
/// RRD consolidation mode
pub enum RRDMode {
/// Maximum
Max,
/// Average
Average,
}
#[api()]
#[repr(u64)]
#[derive(Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
/// RRD time frame resolution
pub enum RRDTimeFrameResolution {
/// 1 min => last 70 minutes
Hour = 60,
/// 30 min => last 35 hours
Day = 60*30,
/// 3 hours => about 8 days
Week = 60*180,
/// 12 hours => last 35 days
Month = 60*720,
/// 1 week => last 490 days
Year = 60*10080,
}

View File

@ -1,7 +1,7 @@
[package]
name = "proxmox-rrd"
version = "0.1.0"
authors = ["Dietmar Maurer <dietmar@proxmox.com>"]
authors = ["Proxmox Support Team <support@proxmox.com>"]
edition = "2018"
description = "Simple RRD database implementation."
@ -11,3 +11,5 @@ bitflags = "1.2.1"
serde = { version = "1.0", features = [] }
proxmox = { version = "0.13.5", features = ["api-macro"] }
proxmox-rrd-api-types = { path = "../proxmox-rrd-api-types" }

View File

@ -6,7 +6,7 @@ use anyhow::{format_err, Error};
use proxmox::tools::fs::{create_path, CreateOptions};
use crate::{RRDMode, RRDTimeFrameResolution};
use proxmox_rrd_api_types::{RRDMode, RRDTimeFrameResolution};
use super::*;

View File

@ -3,35 +3,3 @@ pub use rrd::*;
mod cache;
pub use cache::*;
use serde::{Deserialize, Serialize};
use proxmox::api::api;
#[api()]
#[derive(Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
/// RRD consolidation mode
pub enum RRDMode {
/// Maximum
Max,
/// Average
Average,
}
#[api()]
#[repr(u64)]
#[derive(Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
/// RRD time frame resolution
pub enum RRDTimeFrameResolution {
/// 1 min => last 70 minutes
Hour = 60,
/// 30 min => last 35 hours
Day = 60*30,
/// 3 hours => about 8 days
Week = 60*180,
/// 12 hours => last 35 days
Month = 60*720,
/// 1 week => last 490 days
Year = 60*10080,
}

View File

@ -5,7 +5,7 @@ use anyhow::Error;
use proxmox::tools::{fs::replace_file, fs::CreateOptions};
use crate::{RRDMode, RRDTimeFrameResolution};
use proxmox_rrd_api_types::{RRDMode, RRDTimeFrameResolution};
/// The number of data entries per RRA
pub const RRD_DATA_ENTRIES: usize = 70;

View File

@ -26,11 +26,10 @@ use proxmox::{http_err, identity, list_subdirs_api_method, sortable};
use pxar::accessor::aio::Accessor;
use pxar::EntryKind;
use proxmox_rrd::{RRDMode, RRDTimeFrameResolution};
use pbs_api_types::{ Authid, BackupContent, Counts, CryptMode,
DataStoreListItem, GarbageCollectionStatus, GroupListItem,
SnapshotListItem, SnapshotVerifyState, PruneOptions,
DataStoreStatus,
DataStoreStatus, RRDMode, RRDTimeFrameResolution,
BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA, BACKUP_TIME_SCHEMA,
BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA,
IGNORE_VERIFIED_BACKUPS_SCHEMA, UPID_SCHEMA,

View File

@ -3,8 +3,11 @@ use serde_json::{Value, json};
use proxmox::api::{api, Permission, Router};
use pbs_api_types::{NODE_SCHEMA, PRIV_SYS_AUDIT};
use proxmox_rrd::{RRDMode, RRDTimeFrameResolution, RRD_DATA_ENTRIES};
use pbs_api_types::{
NODE_SCHEMA, RRDMode, RRDTimeFrameResolution, PRIV_SYS_AUDIT,
};
use proxmox_rrd::RRD_DATA_ENTRIES;
use crate::RRD_CACHE;

View File

@ -15,9 +15,9 @@ use proxmox::api::{
};
use pbs_api_types::{
Authid, DATASTORE_SCHEMA, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP,
Authid, DATASTORE_SCHEMA, RRDMode, RRDTimeFrameResolution,
PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP,
};
use proxmox_rrd::{RRDMode, RRDTimeFrameResolution};
use pbs_datastore::DataStore;
use pbs_config::CachedUserInfo;