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 A6DBD1FF17E for ; Thu, 27 Nov 2025 11:45:14 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 05E13E5; Thu, 27 Nov 2025 11:45:35 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Date: Thu, 27 Nov 2025 11:44:40 +0100 Message-ID: <20251127104447.162951-12-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251127104447.162951-1-l.wagner@proxmox.com> References: <20251127104447.162951-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1764240257541 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.032 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 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 datacenter-manager 06/13] api: pve/pbs: add passthrough endpoint for APT repo configuration 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" This enables us to read the APT repository configuration of a remote node. Signed-off-by: Lukas Wagner --- lib/pdm-api-types/src/lib.rs | 1 + server/src/api/remote_updates.rs | 53 ++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs index 5bce1b07..1ca573ae 100644 --- a/lib/pdm-api-types/src/lib.rs +++ b/lib/pdm-api-types/src/lib.rs @@ -32,6 +32,7 @@ pub use proxy::HTTP_PROXY_SCHEMA; mod translation; pub use translation::Translation; +pub use proxmox_apt_api_types::APTRepositoriesResult; pub use proxmox_apt_api_types::APTUpdateInfo; pub use proxmox_auth_api::types::{Authid, Userid}; diff --git a/server/src/api/remote_updates.rs b/server/src/api/remote_updates.rs index bea2d864..591200b0 100644 --- a/server/src/api/remote_updates.rs +++ b/server/src/api/remote_updates.rs @@ -2,10 +2,11 @@ use anyhow::Error; -use pdm_api_types::remotes::Remote; +use pdm_api_types::remotes::{Remote, RemoteType}; +use pdm_api_types::PRIV_RESOURCE_AUDIT; use pdm_api_types::{ - remote_updates::UpdateSummary, remotes::REMOTE_ID_SCHEMA, RemoteUpid, NODE_SCHEMA, - PRIV_RESOURCE_MODIFY, UPID, + remote_updates::UpdateSummary, remotes::REMOTE_ID_SCHEMA, APTRepositoriesResult, RemoteUpid, + NODE_SCHEMA, PRIV_RESOURCE_MODIFY, UPID, }; use proxmox_access_control::CachedUserInfo; use proxmox_apt_api_types::{APTGetChangelogOptions, APTUpdateInfo}; @@ -16,7 +17,7 @@ use proxmox_router::{ use proxmox_schema::api; use proxmox_sortable_macro::sortable; -use crate::remote_updates; +use crate::{connection, remote_updates}; use super::remotes::get_remote; @@ -204,18 +205,58 @@ async fn apt_get_changelog( remote_updates::get_changelog(remote, &node, options.name).await } -const APT_SUBDIRS: SubdirMap = &[ +#[api( + input: { + properties: { + remote: { + schema: REMOTE_ID_SCHEMA, + }, + node: { + schema: NODE_SCHEMA, + }, + }, + }, + access: { + permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_AUDIT, false), + }, +)] +/// Get configured APT repositories. +async fn get_apt_repositories( + remote: String, + node: String, +) -> Result { + let (config, _digest) = pdm_config::remotes::config()?; + let remote = get_remote(&config, &remote)?; + + Ok(match remote.ty { + RemoteType::Pve => { + let client = connection::make_pve_client(remote)?; + client.get_apt_repositories(&node).await? + } + RemoteType::Pbs => { + let client = connection::make_pbs_client(remote)?; + client.get_apt_repositories().await? + } + }) +} + +#[sortable] +const APT_SUBDIRS: SubdirMap = &sorted!([ ( "changelog", &Router::new().get(&API_METHOD_APT_GET_CHANGELOG), ), + ( + "repositories", + &Router::new().get(&API_METHOD_GET_APT_REPOSITORIES), + ), ( "update", &Router::new() .get(&API_METHOD_APT_UPDATE_AVAILABLE) .post(&API_METHOD_APT_UPDATE_DATABASE), ), -]; +]); pub const APT_ROUTER: Router = Router::new() .get(&list_subdirs_api_method!(APT_SUBDIRS)) -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel