From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 4/7] server: api: pve: add nodes/storage api for status and rrddata
Date: Mon, 8 Sep 2025 16:04:15 +0200 [thread overview]
Message-ID: <20250908140424.3376082-9-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250908140424.3376082-1-d.csapak@proxmox.com>
just tunnels through the pve api
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
server/src/api/pve/mod.rs | 1 +
server/src/api/pve/node.rs | 8 +++++-
server/src/api/pve/storage.rs | 46 +++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 1 deletion(-)
create mode 100644 server/src/api/pve/storage.rs
diff --git a/server/src/api/pve/mod.rs b/server/src/api/pve/mod.rs
index 0768083..edafdde 100644
--- a/server/src/api/pve/mod.rs
+++ b/server/src/api/pve/mod.rs
@@ -36,6 +36,7 @@ mod lxc;
mod node;
mod qemu;
mod rrddata;
+mod storage;
pub mod tasks;
pub const ROUTER: Router = Router::new()
diff --git a/server/src/api/pve/node.rs b/server/src/api/pve/node.rs
index 99539d1..1924e25 100644
--- a/server/src/api/pve/node.rs
+++ b/server/src/api/pve/node.rs
@@ -7,6 +7,8 @@ use proxmox_sortable_macro::sortable;
use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, NODE_SCHEMA, PRIV_RESOURCE_AUDIT};
use pve_api_types::StorageContent;
+use crate::api::pve::storage;
+
pub const ROUTER: Router = Router::new()
.get(&list_subdirs_api_method!(SUBDIRS))
.subdirs(SUBDIRS);
@@ -16,10 +18,14 @@ const SUBDIRS: SubdirMap = &sorted!([
("apt", &super::apt::ROUTER),
("rrddata", &super::rrddata::NODE_RRD_ROUTER),
("network", &Router::new().get(&API_METHOD_GET_NETWORK)),
- ("storage", &Router::new().get(&API_METHOD_GET_STORAGES)),
+ ("storage", &STORAGE_ROUTER),
("status", &Router::new().get(&API_METHOD_GET_STATUS)),
]);
+const STORAGE_ROUTER: Router = Router::new()
+ .get(&API_METHOD_GET_STORAGES)
+ .match_all("storage", &storage::ROUTER);
+
#[api(
input: {
properties: {
diff --git a/server/src/api/pve/storage.rs b/server/src/api/pve/storage.rs
new file mode 100644
index 0000000..e337d06
--- /dev/null
+++ b/server/src/api/pve/storage.rs
@@ -0,0 +1,46 @@
+use anyhow::Error;
+
+use proxmox_router::{list_subdirs_api_method, Permission, Router, SubdirMap};
+use proxmox_schema::api;
+use proxmox_sortable_macro::sortable;
+
+use pdm_api_types::remotes::REMOTE_ID_SCHEMA;
+use pdm_api_types::{NODE_SCHEMA, PRIV_RESOURCE_AUDIT, PVE_STORAGE_ID_SCHEMA};
+
+use super::connect_to_remote;
+
+pub const ROUTER: Router = Router::new()
+ .get(&list_subdirs_api_method!(STORAGE_SUBDIR))
+ .subdirs(STORAGE_SUBDIR);
+#[sortable]
+const STORAGE_SUBDIR: SubdirMap = &sorted!([
+ ("rrddata", &super::rrddata::STORAGE_RRD_ROUTER),
+ ("status", &Router::new().get(&API_METHOD_GET_STATUS)),
+]);
+
+#[api(
+ input: {
+ properties: {
+ remote: { schema: REMOTE_ID_SCHEMA },
+ node: { schema: NODE_SCHEMA, },
+ storage: { schema: PVE_STORAGE_ID_SCHEMA, },
+ },
+ },
+ returns: { type: pve_api_types::QemuStatus },
+ access: {
+ permission: &Permission::Privilege(&["resource", "{remote}", "storage", "{storage}"], PRIV_RESOURCE_AUDIT, false),
+ },
+)]
+/// Get the status of a qemu VM from a remote. If a node is provided, the VM must be on that
+/// node, otherwise the node is determined automatically.
+pub async fn get_status(
+ remote: String,
+ node: String,
+ storage: String,
+) -> Result<pve_api_types::StorageStatus, Error> {
+ let (remotes, _) = pdm_config::remotes::config()?;
+
+ let pve = connect_to_remote(&remotes, &remote)?;
+
+ Ok(pve.storage_status(&node, &storage).await?)
+}
--
2.47.2
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-09-08 14:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 14:04 [pdm-devel] [PATCH datacenter-manager/proxmox-api-types/storage 00/11] add Dominik Csapak
2025-09-08 14:04 ` [pdm-devel] [PATCH storage 1/1] api: status: document return types Dominik Csapak
2025-09-08 14:44 ` [pdm-devel] applied: " Wolfgang Bumiller
2025-09-08 14:04 ` [pdm-devel] [PATCH proxmox-api-types 1/3] regenerate pve-api.json Dominik Csapak
2025-09-08 14:04 ` [pdm-devel] [PATCH proxmox-api-types 2/3] node: storage: add status api Dominik Csapak
2025-09-08 14:04 ` [pdm-devel] [PATCH proxmox-api-types 3/3] regenerate with new node storage " Dominik Csapak
2025-09-08 14:04 ` [pdm-devel] [PATCH datacenter-manager 1/7] pdm-api-types: add pve storage id schema Dominik Csapak
2025-09-08 14:04 ` [pdm-devel] [PATCH datacenter-manager 2/7] pdm-api-types: add PVE storage data point for RRD Dominik Csapak
2025-09-08 14:04 ` [pdm-devel] [PATCH datacenter-manager 3/7] server: api: add rrddata endpoint for pve storages Dominik Csapak
2025-09-08 14:04 ` Dominik Csapak [this message]
2025-09-08 14:04 ` [pdm-devel] [PATCH datacenter-manager 5/7] pdm-client: add pve storage status/rrddata methods Dominik Csapak
2025-09-08 14:04 ` [pdm-devel] [PATCH datacenter-manager 6/7] ui: pve: add storage to tree and show basic panel Dominik Csapak
2025-09-08 14:04 ` [pdm-devel] [PATCH datacenter-manager 7/7] ui: enable navigation to pve storage Dominik Csapak
2025-09-08 14:59 ` [pdm-devel] applied-series: [PATCH datacenter-manager/proxmox-api-types/storage 00/11] add Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250908140424.3376082-9-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox