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 883597A106 for ; Thu, 6 May 2021 14:20:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7DF132075B for ; Thu, 6 May 2021 14:20:13 +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 5E72E20752 for ; Thu, 6 May 2021 14:20:12 +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 396A8409FD for ; Thu, 6 May 2021 14:20:12 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Thu, 6 May 2021 14:20:03 +0200 Message-Id: <20210506122008.11297-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210506122008.11297-1-d.csapak@proxmox.com> References: <20210506122008.11297-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.018 Adjusted score from AWL reputation of From: address 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. [backup.rs, mod.rs] Subject: [pbs-devel] [PATCH proxmox-backup v3 2/7] api2/types: add TAPE_RESTORE_SNAPSHOT_SCHEMA 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, 06 May 2021 12:20:43 -0000 which is 'store:type/id/time' needed to refactor SNAPSHOT_PATH_REGEX_STR from backup_info Signed-off-by: Dominik Csapak --- src/api2/types/mod.rs | 11 +++++++++++ src/backup.rs | 1 + src/backup/backup_info.rs | 9 ++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/api2/types/mod.rs b/src/api2/types/mod.rs index e829f207..21b5eade 100644 --- a/src/api2/types/mod.rs +++ b/src/api2/types/mod.rs @@ -114,6 +114,8 @@ const_regex!{ pub UUID_REGEX = r"^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$"; pub DATASTORE_MAP_REGEX = concat!(r"(:?", PROXMOX_SAFE_ID_REGEX_STR!(), r"=)?", PROXMOX_SAFE_ID_REGEX_STR!()); + + pub TAPE_RESTORE_SNAPSHOT_REGEX = concat!(r"^", PROXMOX_SAFE_ID_REGEX_STR!(), r":", SNAPSHOT_PATH_REGEX_STR!(), r"$"); } pub const SYSTEMD_DATETIME_FORMAT: ApiStringFormat = @@ -185,6 +187,9 @@ pub const BLOCKDEVICE_NAME_FORMAT: ApiStringFormat = pub const DATASTORE_MAP_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&DATASTORE_MAP_REGEX); +pub const TAPE_RESTORE_SNAPSHOT_FORMAT: ApiStringFormat = + ApiStringFormat::Pattern(&TAPE_RESTORE_SNAPSHOT_REGEX); + pub const PASSWORD_SCHEMA: Schema = StringSchema::new("Password.") .format(&PASSWORD_FORMAT) .min_length(1) @@ -396,6 +401,12 @@ pub const DATASTORE_MAP_LIST_SCHEMA: Schema = StringSchema::new( .format(&ApiStringFormat::PropertyString(&DATASTORE_MAP_ARRAY_SCHEMA)) .schema(); +pub const TAPE_RESTORE_SNAPSHOT_SCHEMA: Schema = StringSchema::new( + "A snapshot in the format: 'store:type/id/time") + .format(&TAPE_RESTORE_SNAPSHOT_FORMAT) + .type_text("store:type/id/time") + .schema(); + pub const MEDIA_SET_UUID_SCHEMA: Schema = StringSchema::new("MediaSet Uuid (We use the all-zero Uuid to reseve an empty media for a specific pool).") .format(&UUID_FORMAT) diff --git a/src/backup.rs b/src/backup.rs index cca43881..ae937be0 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -238,6 +238,7 @@ pub use fixed_index::*; mod dynamic_index; pub use dynamic_index::*; +#[macro_use] mod backup_info; pub use backup_info::*; diff --git a/src/backup/backup_info.rs b/src/backup/backup_info.rs index b0f6e31c..f39f2ed4 100644 --- a/src/backup/backup_info.rs +++ b/src/backup/backup_info.rs @@ -25,6 +25,13 @@ macro_rules! BACKUP_TIME_RE { }; } +#[macro_export] +macro_rules! SNAPSHOT_PATH_REGEX_STR { + () => ( + concat!(r"(", BACKUP_TYPE_RE!(), ")/(", BACKUP_ID_RE!(), ")/(", BACKUP_TIME_RE!(), r")") + ); +} + const_regex! { BACKUP_FILE_REGEX = r"^.*\.([fd]idx|blob)$"; @@ -37,7 +44,7 @@ const_regex! { GROUP_PATH_REGEX = concat!(r"^(", BACKUP_TYPE_RE!(), ")/(", BACKUP_ID_RE!(), r")$"); SNAPSHOT_PATH_REGEX = concat!( - r"^(", BACKUP_TYPE_RE!(), ")/(", BACKUP_ID_RE!(), ")/(", BACKUP_TIME_RE!(), r")$"); + r"^", SNAPSHOT_PATH_REGEX_STR!(), r"$"); } /// BackupGroup is a directory containing a list of BackupDir -- 2.20.1