From bfcef26a992d5ecdfa7aae7648ddac7a3bbc7863 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Fri, 10 Jul 2020 10:51:12 +0200 Subject: [PATCH] api2/node/status: add fingerprint and rename get_usage to get_status (since its not usage only anymore) Signed-off-by: Dominik Csapak --- src/api2/node/status.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/api2/node/status.rs b/src/api2/node/status.rs index 970c1367..14d4b587 100644 --- a/src/api2/node/status.rs +++ b/src/api2/node/status.rs @@ -10,6 +10,7 @@ use proxmox::api::{api, ApiMethod, Router, RpcEnvironment, Permission}; use crate::api2::types::*; use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_POWER_MANAGEMENT}; +use crate::tools::cert::CertInfo; #[api( input: { @@ -46,14 +47,24 @@ use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_POWER_MANAGEMENT}; description: "Total CPU usage since last query.", optional: true, }, - } + info: { + type: Object, + description: "contains node information", + properties: { + fingerprint: { + description: "The SSL Fingerprint", + type: String, + }, + }, + }, + }, }, access: { permission: &Permission::Privilege(&["system", "status"], PRIV_SYS_AUDIT, false), }, )] /// Read node memory, CPU and (root) disk usage -fn get_usage( +fn get_status( _param: Value, _info: &ApiMethod, _rpcenv: &mut dyn RpcEnvironment, @@ -63,6 +74,10 @@ fn get_usage( let kstat: procfs::ProcFsStat = procfs::read_proc_stat()?; let disk_usage = crate::tools::disks::disk_usage(Path::new("/"))?; + // get fingerprint + let cert = CertInfo::new()?; + let fp = cert.fingerprint()?; + Ok(json!({ "memory": { "total": meminfo.memtotal, @@ -74,7 +89,10 @@ fn get_usage( "total": disk_usage.total, "used": disk_usage.used, "free": disk_usage.avail, - } + }, + "info": { + "fingerprint": fp, + }, })) } @@ -122,5 +140,5 @@ fn reboot_or_shutdown(command: NodePowerCommand) -> Result<(), Error> { } pub const ROUTER: Router = Router::new() - .get(&API_METHOD_GET_USAGE) + .get(&API_METHOD_GET_STATUS) .post(&API_METHOD_REBOOT_OR_SHUTDOWN);