From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E08B67A11C for ; Thu, 28 Oct 2021 15:02:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D762620DC2 for ; Thu, 28 Oct 2021 15:01:47 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 338DA20DB7 for ; Thu, 28 Oct 2021 15:01:47 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0A1EF4699B for ; Thu, 28 Oct 2021 15:01:47 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Thu, 28 Oct 2021 15:00:54 +0200 Message-Id: <20211028130058.1308810-9-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211028130058.1308810-1-f.gruenbichler@proxmox.com> References: <20211028130058.1308810-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.330 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pull.rs, jobs.rs, sync.rs] Subject: [pbs-devel] [PATCH v3 proxmox-backup 07/11] sync: add group filtering X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Oct 2021 13:02:17 -0000 like for manual pulls, but persisted in the sync job config and visible in the relevant GUI parts. GUI is read-only for now (and defaults to no filtering on creation), as this is a rather advanced feature that requires a complex GUI to be user-friendly (regex-freeform, type-combobox, remote group scanning + selector with additional freeform input). Signed-off-by: Fabian Grünbichler --- Notes: v2->v3: - use Vec / GROUP_FILTER_LIST_SCHEMA - simplify renderer I did test the API manually though to see whether it works as expected, and updating the filter list by overwriting with a new one passed in as multiple parameters works as expected. if we want to make this configurable over the GUI, we probably want to switch the job edit window to a tabpanel and add a second grid tab for selecting the groups. pbs-api-types/src/jobs.rs | 6 ++++++ src/api2/config/sync.rs | 5 +++++ src/api2/pull.rs | 2 +- www/config/SyncView.js | 13 ++++++++++++- www/window/SyncJobEdit.js | 12 ++++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs index eda4ef95..c5d3bafe 100644 --- a/pbs-api-types/src/jobs.rs +++ b/pbs-api-types/src/jobs.rs @@ -403,6 +403,10 @@ pub const GROUP_FILTER_LIST_SCHEMA: Schema = ArraySchema::new("List of group fil optional: true, schema: SYNC_SCHEDULE_SCHEMA, }, + groups: { + schema: GROUP_FILTER_LIST_SCHEMA, + optional: true, + }, } )] #[derive(Serialize,Deserialize,Clone,Updater)] @@ -422,6 +426,8 @@ pub struct SyncJobConfig { pub comment: Option, #[serde(skip_serializing_if="Option::is_none")] pub schedule: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub groups: Option>, } #[api( diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs index fba476da..890221e6 100644 --- a/src/api2/config/sync.rs +++ b/src/api2/config/sync.rs @@ -192,6 +192,8 @@ pub enum DeletableProperty { schedule, /// Delete the remove-vanished flag. remove_vanished, + /// Delete the groups property. + groups, } #[api( @@ -254,6 +256,7 @@ pub fn update_sync_job( DeletableProperty::comment => { data.comment = None; }, DeletableProperty::schedule => { data.schedule = None; }, DeletableProperty::remove_vanished => { data.remove_vanished = None; }, + DeletableProperty::groups => { data.groups = None; }, } } } @@ -271,6 +274,7 @@ pub fn update_sync_job( if let Some(remote) = update.remote { data.remote = remote; } if let Some(remote_store) = update.remote_store { data.remote_store = remote_store; } if let Some(owner) = update.owner { data.owner = Some(owner); } + if let Some(groups) = update.groups { data.groups = Some(groups); } let schedule_changed = data.schedule != update.schedule; if update.schedule.is_some() { data.schedule = update.schedule; } @@ -390,6 +394,7 @@ acl:1:/remote/remote1/remotestore1:write@pbs:RemoteSyncOperator owner: Some(write_auth_id.clone()), comment: None, remove_vanished: None, + groups: None, schedule: None, }; diff --git a/src/api2/pull.rs b/src/api2/pull.rs index d4a14f10..3d644202 100644 --- a/src/api2/pull.rs +++ b/src/api2/pull.rs @@ -50,7 +50,7 @@ impl TryFrom<&SyncJobConfig> for PullParameters { &sync_job.remote_store, sync_job.owner.as_ref().unwrap_or_else(|| Authid::root_auth_id()).clone(), sync_job.remove_vanished, - None, + sync_job.groups.clone(), ) } } diff --git a/www/config/SyncView.js b/www/config/SyncView.js index 7d7e751c..d2a3954f 100644 --- a/www/config/SyncView.js +++ b/www/config/SyncView.js @@ -1,7 +1,7 @@ Ext.define('pbs-sync-jobs-status', { extend: 'Ext.data.Model', fields: [ - 'id', 'owner', 'remote', 'remote-store', 'store', 'schedule', + 'id', 'owner', 'remote', 'remote-store', 'store', 'schedule', 'groups', 'next-run', 'last-run-upid', 'last-run-state', 'last-run-endtime', { name: 'duration', @@ -214,6 +219,12 @@ Ext.define('PBS.config.SyncJobView', { flex: 2, sortable: true, }, + { + header: gettext('Backup Groups'), + dataIndex: 'groups', + renderer: v => v ? Ext.String.htmlEncode(v) : gettext('All'), + width: 80, + }, { header: gettext('Schedule'), dataIndex: 'schedule', diff --git a/www/window/SyncJobEdit.js b/www/window/SyncJobEdit.js index 47e65ae3..2399f11f 100644 --- a/www/window/SyncJobEdit.js +++ b/www/window/SyncJobEdit.js @@ -199,6 +199,15 @@ Ext.define('PBS.window.SyncJobEdit', { ], columnB: [ + { + fieldLabel: gettext('Backup Groups'), + xtype: 'displayfield', + name: 'groups', + renderer: v => v ? Ext.String.htmlEncode(v) : gettext('All'), + cbind: { + hidden: '{isCreate}', + }, + }, { fieldLabel: gettext('Comment'), xtype: 'proxmoxtextfield', -- 2.30.2