From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pdm-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 4F0261FF15C for <inbox@lore.proxmox.com>; Wed, 19 Feb 2025 13:29:01 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A89682879B; Wed, 19 Feb 2025 13:28:57 +0100 (CET) From: Dominik Csapak <d.csapak@proxmox.com> To: pdm-devel@lists.proxmox.com Date: Wed, 19 Feb 2025 13:28:19 +0100 Message-Id: <20250219122824.2043990-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250219122824.2043990-1-d.csapak@proxmox.com> References: <20250219122824.2043990-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.020 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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 v2 2/7] server: api: remote tasks: add 'remote' filter option X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion <pdm-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/> List-Post: <mailto:pdm-devel@lists.proxmox.com> List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Datacenter Manager development discussion <pdm-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com> so we can filter the tasks by remote Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> --- server/src/api/remote_tasks.rs | 17 +++++++++++++---- server/src/task_cache.rs | 11 ++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/server/src/api/remote_tasks.rs b/server/src/api/remote_tasks.rs index 57b59fd..d327272 100644 --- a/server/src/api/remote_tasks.rs +++ b/server/src/api/remote_tasks.rs @@ -1,5 +1,6 @@ use anyhow::Error; -use pdm_api_types::{TaskFilters, TaskListItem}; + +use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, TaskFilters, TaskListItem}; use proxmox_router::{list_subdirs_api_method, Permission, Router, SubdirMap}; use proxmox_schema::api; use proxmox_sortable_macro::sortable; @@ -31,13 +32,21 @@ const SUBDIRS: SubdirMap = &sorted!([("list", &Router::new().get(&API_METHOD_LIS filters: { type: TaskFilters, flatten: true, - } + }, + remote: { + schema: REMOTE_ID_SCHEMA, + optional: true, + }, }, }, )] /// Get the list of tasks for all remotes. -async fn list_tasks(max_age: i64, filters: TaskFilters) -> Result<Vec<TaskListItem>, Error> { - let tasks = task_cache::get_tasks(max_age, filters).await?; +async fn list_tasks( + max_age: i64, + filters: TaskFilters, + remote: Option<String>, +) -> Result<Vec<TaskListItem>, Error> { + let tasks = task_cache::get_tasks(max_age, filters, remote).await?; Ok(tasks) } diff --git a/server/src/task_cache.rs b/server/src/task_cache.rs index 4c34827..c5e8956 100644 --- a/server/src/task_cache.rs +++ b/server/src/task_cache.rs @@ -20,7 +20,11 @@ use crate::{api::pve, task_utils}; /// Get tasks for all remotes // FIXME: filter for privileges -pub async fn get_tasks(max_age: i64, filters: TaskFilters) -> Result<Vec<TaskListItem>, Error> { +pub async fn get_tasks( + max_age: i64, + filters: TaskFilters, + remote_filter: Option<String>, +) -> Result<Vec<TaskListItem>, Error> { let (remotes, _) = pdm_config::remotes::config()?; let mut all_tasks = Vec::new(); @@ -37,6 +41,11 @@ pub async fn get_tasks(max_age: i64, filters: TaskFilters) -> Result<Vec<TaskLis invalidate_cache_for_finished_tasks(&mut cache); for (remote_name, remote) in &remotes.sections { + if let Some(remote_filter) = &remote_filter { + if remote_name != remote_filter { + continue; + } + } let now = proxmox_time::epoch_i64(); if let Some(tasks) = cache.get_tasks(remote_name.as_str(), now, max_age) { -- 2.39.5 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel