[pbs-devel] [PATCH proxmox-backup v2 6/7] api2: nodes: add missing node list api call

Dominik Csapak d.csapak at proxmox.com
Mon Sep 13 16:18:28 CEST 2021


to have an api call for api path traversal

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/api2/mod.rs      |  4 +---
 src/api2/node/mod.rs | 12 +++++++++++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/api2/mod.rs b/src/api2/mod.rs
index 132e2c2a..0ede4165 100644
--- a/src/api2/mod.rs
+++ b/src/api2/mod.rs
@@ -18,14 +18,12 @@ use proxmox::api::router::SubdirMap;
 use proxmox::api::Router;
 use proxmox::list_subdirs_api_method;
 
-const NODES_ROUTER: Router = Router::new().match_all("node", &node::ROUTER);
-
 const SUBDIRS: SubdirMap = &[
     ("access", &access::ROUTER),
     ("admin", &admin::ROUTER),
     ("backup", &backup::ROUTER),
     ("config", &config::ROUTER),
-    ("nodes", &NODES_ROUTER),
+    ("nodes", &node::ROUTER),
     ("ping", &ping::ROUTER),
     ("pull", &pull::ROUTER),
     ("reader", &reader::ROUTER),
diff --git a/src/api2/node/mod.rs b/src/api2/node/mod.rs
index f1a17934..194ec920 100644
--- a/src/api2/node/mod.rs
+++ b/src/api2/node/mod.rs
@@ -315,6 +315,12 @@ fn upgrade_to_websocket(
     .boxed()
 }
 
+#[api]
+/// List Nodes (only for compatiblity)
+fn list_nodes() -> Result<Value, Error> {
+    Ok(json!([ { "node": proxmox::tools::nodename().to_string() } ]))
+}
+
 pub const SUBDIRS: SubdirMap = &[
     ("apt", &apt::ROUTER),
     ("certificates", &certificates::ROUTER),
@@ -338,6 +344,10 @@ pub const SUBDIRS: SubdirMap = &[
     ),
 ];
 
-pub const ROUTER: Router = Router::new()
+pub const ITEM_ROUTER: Router = Router::new()
     .get(&list_subdirs_api_method!(SUBDIRS))
     .subdirs(SUBDIRS);
+
+pub const ROUTER: Router = Router::new()
+    .get(&API_METHOD_LIST_NODES)
+    .match_all("node", &ITEM_ROUTER);
-- 
2.30.2






More information about the pbs-devel mailing list