From: Dominik Csapak <d.csapak@proxmox.com>
To: Proxmox Datacenter Manager development discussion
	<pdm-devel@lists.proxmox.com>,
	Shannon Sterz <s.sterz@proxmox.com>
Subject: Re: [pdm-devel] [PATCH datacenter-manager 1/3] api-types/api: add endpoints for querying the node's status
Date: Mon, 3 Nov 2025 14:11:40 +0100	[thread overview]
Message-ID: <0e2e2745-9a0d-482b-9895-94c6518937b4@proxmox.com> (raw)
In-Reply-To: <20251028164435.576642-5-s.sterz@proxmox.com>
one comment inline
On 10/28/25 5:44 PM, Shannon Sterz wrote:
> Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
> ---
>   Cargo.toml                                    |  2 ++
>   lib/pdm-api-types/src/acl.rs                  |  2 ++
>   server/Cargo.toml                             |  1 +
>   server/src/api/nodes/mod.rs                   |  2 ++
>   server/src/api/nodes/status.rs                | 18 ++++++++++++++++++
>   server/src/bin/proxmox-datacenter-api/main.rs |  2 ++
>   6 files changed, 27 insertions(+)
>   create mode 100644 server/src/api/nodes/status.rs
> 
> diff --git a/Cargo.toml b/Cargo.toml
> index 49c7583..3252ccb 100644
> --- a/Cargo.toml
> +++ b/Cargo.toml
> @@ -78,6 +78,7 @@ proxmox-time-api = "1"
>   proxmox-network-api = "1"
>   proxmox-syslog-api = "1"
>   proxmox-acme-api = "1"
> +proxmox-node-status = "1"
>   
>   # API types for PVE (and later PMG?)
>   pve-api-types = "8.0.5"
> @@ -163,6 +164,7 @@ zstd = { version = "0.13" }
>   # proxmox-log = { path = "../proxmox/proxmox-log" }
>   # proxmox-metrics = { path = "../proxmox/proxmox-metrics" }
>   # proxmox-network-api = { path = "../proxmox/proxmox-network-api" }
> +# proxmox-node-status = { path = "../proxmox/proxmox-node-status" }
>   # proxmox-notify = { path = "../proxmox/proxmox-notify" }
>   # proxmox-openid = { path = "../proxmox/proxmox-openid" }
>   # proxmox-product-config = { path = "../proxmox/proxmox-product-config" }
> diff --git a/lib/pdm-api-types/src/acl.rs b/lib/pdm-api-types/src/acl.rs
> index 9e69c2f..5592102 100644
> --- a/lib/pdm-api-types/src/acl.rs
> +++ b/lib/pdm-api-types/src/acl.rs
> @@ -26,6 +26,8 @@ constnamedbitmap! {
>           PRIV_SYS_MODIFY("System.Modify");
>           /// `Sys.Console` allows access to the system's console
>           PRIV_SYS_CONSOLE("Sys.Console");
> +        /// `Sys.PowerManagement` allows powering off or rebooting the system.
> +        PRIV_SYS_POWER_MANAGEMENT("Sys.PowerManagement");
>   
>           /// `Resource.Audit` allows auditing guests, storages and other resources.
>           PRIV_RESOURCE_AUDIT("Resource.Audit");
> diff --git a/server/Cargo.toml b/server/Cargo.toml
> index 94420b4..88e3802 100644
> --- a/server/Cargo.toml
> +++ b/server/Cargo.toml
> @@ -72,6 +72,7 @@ proxmox-time-api = { workspace = true, features = [ "impl" ] }
>   proxmox-network-api = { workspace = true, features = [ "impl" ] }
>   proxmox-syslog-api = { workspace = true, features = [ "impl" ] }
>   proxmox-acme-api = { workspace = true, features = [ "impl" ] }
> +proxmox-node-status = { workspace = true }
>   
features = [ "api" ]
is missing here, otherwise it doesn't compile due to it not finding
the api functions
>   pdm-api-types.workspace = true
>   pdm-buildcfg.workspace = true
> diff --git a/server/src/api/nodes/mod.rs b/server/src/api/nodes/mod.rs
> index 6f30ba7..f70fcaf 100644
> --- a/server/src/api/nodes/mod.rs
> +++ b/server/src/api/nodes/mod.rs
> @@ -10,6 +10,7 @@ pub mod dns;
>   pub mod journal;
>   pub mod network;
>   pub mod rrddata;
> +pub mod status;
>   pub mod syslog;
>   pub mod tasks;
>   pub mod termproxy;
> @@ -45,6 +46,7 @@ pub const SUBDIRS: SubdirMap = &sorted!([
>       ("journal", &journal::ROUTER),
>       ("network", &network::ROUTER),
>       ("rrdata", &rrddata::ROUTER),
> +    ("status", &status::ROUTER),
>       ("syslog", &syslog::ROUTER),
>       ("tasks", &tasks::ROUTER),
>       ("termproxy", &termproxy::ROUTER),
> diff --git a/server/src/api/nodes/status.rs b/server/src/api/nodes/status.rs
> new file mode 100644
> index 0000000..b3bbed5
> --- /dev/null
> +++ b/server/src/api/nodes/status.rs
> @@ -0,0 +1,18 @@
> +use pdm_api_types::{PRIV_SYS_AUDIT, PRIV_SYS_POWER_MANAGEMENT};
> +use proxmox_router::{ApiMethod, Permission, Router};
> +
> +const API_METHOD_GET_STATUS_WITH_ACCESS: ApiMethod = proxmox_node_status::API_METHOD_GET_STATUS
> +    .access(
> +        None,
> +        &Permission::Privilege(&["system", "status"], PRIV_SYS_AUDIT, false),
> +    );
> +
> +const API_METHOD_REBOOT_OR_SHUTDOWN_WITH_ACCESS: ApiMethod =
> +    proxmox_node_status::API_METHOD_REBOOT_OR_SHUTDOWN.access(
> +        None,
> +        &Permission::Privilege(&["system", "status"], PRIV_SYS_POWER_MANAGEMENT, false),
> +    );
> +
> +pub const ROUTER: Router = Router::new()
> +    .get(&API_METHOD_GET_STATUS_WITH_ACCESS)
> +    .post(&API_METHOD_REBOOT_OR_SHUTDOWN_WITH_ACCESS);
> diff --git a/server/src/bin/proxmox-datacenter-api/main.rs b/server/src/bin/proxmox-datacenter-api/main.rs
> index 420a3b4..860612c 100644
> --- a/server/src/bin/proxmox-datacenter-api/main.rs
> +++ b/server/src/bin/proxmox-datacenter-api/main.rs
> @@ -391,6 +391,8 @@ fn make_tls_acceptor() -> Result<SslAcceptor, Error> {
>       let key_path = configdir!("/auth/api.key");
>       let cert_path = configdir!("/auth/api.pem");
>   
> +    proxmox_node_status::init_node_status_api(cert_path);
> +
>       proxmox_rest_server::connection::TlsAcceptorBuilder::new()
>           .certificate_paths_pem(key_path, cert_path)
>           .build()
_______________________________________________
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-11-03 13:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28 16:44 [pdm-devel] [PATCH datacenter-manager/proxmox/yew-comp 0/6] add node status panel to proxmox datacenter manager Shannon Sterz
2025-10-28 16:44 ` [pdm-devel] [PATCH proxmox 1/1] node-status: add node status crate Shannon Sterz
2025-11-03 12:50   ` Dominik Csapak
2025-10-28 16:44 ` [pdm-devel] [PATCH yew-comp 1/2] node info: extend NodeStatus enum to include NodeStatus from proxmox-rs Shannon Sterz
2025-11-03 12:52   ` Dominik Csapak
2025-10-28 16:44 ` [pdm-devel] [PATCH yew-comp 2/2] node status panel: add a panel that show the current status of a node Shannon Sterz
2025-10-28 16:44 ` [pdm-devel] [PATCH datacenter-manager 1/3] api-types/api: add endpoints for querying the node's status Shannon Sterz
2025-11-03 13:11   ` Dominik Csapak [this message]
2025-10-28 16:44 ` [pdm-devel] [RFC PATCH datacenter-manager 2/3] ui: add NodeStatusPanel to the administration menu Shannon Sterz
2025-10-28 16:44 ` [pdm-devel] [RFC PATCH datacenter-manager 3/3] nodes: remove unnecessary rustfmt::skip macro Shannon Sterz
2025-11-03 13:15 ` [pdm-devel] [PATCH datacenter-manager/proxmox/yew-comp 0/6] add node status panel to proxmox datacenter manager Dominik Csapak
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=0e2e2745-9a0d-482b-9895-94c6518937b4@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    --cc=s.sterz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.