From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 1460C1FF173 for ; Mon, 13 Jan 2025 16:46:15 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F02244E23; Mon, 13 Jan 2025 16:45:55 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Mon, 13 Jan 2025 16:45:41 +0100 Message-Id: <20250113154550.3462139-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250113154550.3462139-1-d.csapak@proxmox.com> References: <20250113154550.3462139-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.134 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH proxmox-api-types 2/2] add cluster status api call X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" Signed-off-by: Dominik Csapak --- pve-api-types/generate.pl | 7 ++ pve-api-types/src/generated/code.rs | 12 ++- pve-api-types/src/generated/types.rs | 114 +++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 1 deletion(-) diff --git a/pve-api-types/generate.pl b/pve-api-types/generate.pl index 4c8e164..8be737b 100644 --- a/pve-api-types/generate.pl +++ b/pve-api-types/generate.pl @@ -279,6 +279,13 @@ Schema2Rust::register_api_extensions('ClusterJoinInfo', { }); api(GET => '/cluster/config/join', 'cluster_config_join', 'return-name' => 'ClusterJoinInfo'); +# cluster status info +Schema2Rust::register_api_extensions('ClusterNodeStatus', { + '/properties/id' => { description => sq("FIXME: Missing description in PVE.") }, + '/properties/name' => { description => sq("FIXME: Missing description in PVE.") }, +}); +api(GET => '/cluster/status', 'cluster_status', 'return-name' => 'ClusterNodeStatus'); + # api(GET => '/storage', 'list_storages', 'return-name' => 'StorageList'); Schema2Rust::register_api_extensions('ListRealm', { '/properties/realm' => { description => sq("FIXME: Missing description in PVE.") }, diff --git a/pve-api-types/src/generated/code.rs b/pve-api-types/src/generated/code.rs index dc17cd9..d05b519 100644 --- a/pve-api-types/src/generated/code.rs +++ b/pve-api-types/src/generated/code.rs @@ -127,7 +127,6 @@ /// - /cluster/sdn/vnets/{vnet}/subnets/{subnet} /// - /cluster/sdn/zones /// - /cluster/sdn/zones/{zone} -/// - /cluster/status /// - /cluster/tasks /// - /nodes/{node} /// - /nodes/{node}/aplinfo @@ -395,6 +394,11 @@ pub trait PveClient { Err(Error::Other("cluster_resources not implemented")) } + /// Get cluster status information. + async fn cluster_status(&self) -> Result, Error> { + Err(Error::Other("cluster_status not implemented")) + } + /// Generate a new API token for a specific user. NOTE: returns API token /// value, which needs to be stored as it cannot be retrieved afterwards! async fn create_token( @@ -688,6 +692,12 @@ where Ok(self.0.get(&url).await?.expect_json()?.data) } + /// Get cluster status information. + async fn cluster_status(&self) -> Result, Error> { + let url = format!("/api2/extjs/cluster/status"); + Ok(self.0.get(&url).await?.expect_json()?.data) + } + /// Generate a new API token for a specific user. NOTE: returns API token /// value, which needs to be stored as it cannot be retrieved afterwards! async fn create_token( diff --git a/pve-api-types/src/generated/types.rs b/pve-api-types/src/generated/types.rs index ebbb4a0..b6a3d20 100644 --- a/pve-api-types/src/generated/types.rs +++ b/pve-api-types/src/generated/types.rs @@ -405,6 +405,120 @@ pub enum ClusterNodeIndexResponseStatus { serde_plain::derive_display_from_serialize!(ClusterNodeIndexResponseStatus); serde_plain::derive_fromstr_from_deserialize!(ClusterNodeIndexResponseStatus); +#[api( + properties: { + id: { + type: String, + description: "FIXME: Missing description in PVE.", + }, + ip: { + optional: true, + type: String, + }, + level: { + optional: true, + type: String, + }, + local: { + default: false, + optional: true, + }, + name: { + type: String, + description: "FIXME: Missing description in PVE.", + }, + nodeid: { + optional: true, + type: Integer, + }, + nodes: { + optional: true, + type: Integer, + }, + online: { + default: false, + optional: true, + }, + quorate: { + default: false, + optional: true, + }, + type: { + type: ClusterNodeStatusType, + }, + version: { + optional: true, + type: Integer, + }, + }, +)] +/// Object. +#[derive(Debug, serde::Deserialize, serde::Serialize)] +pub struct ClusterNodeStatus { + pub id: String, + + /// [node] IP of the resolved nodename. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ip: Option, + + /// [node] Proxmox VE Subscription level, indicates if eligible for + /// enterprise support as well as access to the stable Proxmox VE Enterprise + /// Repository. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub level: Option, + + /// [node] Indicates if this is the responding node. + #[serde(deserialize_with = "proxmox_login::parse::deserialize_bool")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub local: Option, + + pub name: String, + + /// [node] ID of the node from the corosync configuration. + #[serde(deserialize_with = "proxmox_login::parse::deserialize_i64")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub nodeid: Option, + + /// [cluster] Nodes count, including offline nodes. + #[serde(deserialize_with = "proxmox_login::parse::deserialize_i64")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub nodes: Option, + + /// [node] Indicates if the node is online or offline. + #[serde(deserialize_with = "proxmox_login::parse::deserialize_bool")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub online: Option, + + /// [cluster] Indicates if there is a majority of nodes online to make + /// decisions + #[serde(deserialize_with = "proxmox_login::parse::deserialize_bool")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub quorate: Option, + + #[serde(rename = "type")] + pub ty: ClusterNodeStatusType, + + /// [cluster] Current version of the corosync configuration file. + #[serde(deserialize_with = "proxmox_login::parse::deserialize_i64")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub version: Option, +} + +#[api] +/// Indicates the type, either cluster or node. The type defines the object +/// properties e.g. quorate available for type cluster. +#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +pub enum ClusterNodeStatusType { + #[serde(rename = "cluster")] + /// cluster. + Cluster, + #[serde(rename = "node")] + /// node. + Node, +} +serde_plain::derive_display_from_serialize!(ClusterNodeStatusType); +serde_plain::derive_fromstr_from_deserialize!(ClusterNodeStatusType); + const_regex! { CLUSTER_RESOURCE_NODE_RE = r##"^(?i:[a-z0-9](?i:[a-z0-9\-]*[a-z0-9])?)$"##; -- 2.39.5 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel