public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	Dominik Csapak <d.csapak@proxmox.com>
Subject: [pbs-devel] applied: [PATCH proxmox-backup v3 2/7] api2/types: add TAPE_RESTORE_SNAPSHOT_SCHEMA
Date: Fri, 7 May 2021 12:51:08 +0200	[thread overview]
Message-ID: <32c1f939-9634-5a16-f504-1d17972eef76@proxmox.com> (raw)
In-Reply-To: <20210506122008.11297-3-d.csapak@proxmox.com>

applied with a cleanup on top:

I moved all api related type/regx definition from backup_info.rs to 
src/api2/types/mod.rs

On 5/6/21 2:20 PM, Dominik Csapak wrote:
> which is 'store:type/id/time'
>
> needed to refactor SNAPSHOT_PATH_REGEX_STR from backup_info
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>   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




  reply	other threads:[~2021-05-07 10:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 12:20 [pbs-devel] [PATCH proxmox-backup v3 0/7] tape: single snapshot restore Dominik Csapak
2021-05-06 12:20 ` [pbs-devel] [PATCH proxmox-backup v3 1/7] api2/tape/restore: return backup manifest in try_restore_snapshot_archive Dominik Csapak
2021-05-07 10:49   ` [pbs-devel] applied: " Dietmar Maurer
2021-05-06 12:20 ` [pbs-devel] [PATCH proxmox-backup v3 2/7] api2/types: add TAPE_RESTORE_SNAPSHOT_SCHEMA Dominik Csapak
2021-05-07 10:51   ` Dietmar Maurer [this message]
2021-05-06 12:20 ` [pbs-devel] [PATCH proxmox-backup v3 3/7] api2/tape/restore: add optional snapshots to 'restore' Dominik Csapak
2021-05-06 12:20 ` [pbs-devel] [PATCH proxmox-backup v3 4/7] tape/inventory: add completion helper for tape snapshots Dominik Csapak
2021-05-06 12:20 ` [pbs-devel] [PATCH proxmox-backup v3 5/7] bin/proxmox-tape: add optional snapshots to restore command Dominik Csapak
2021-05-06 12:20 ` [pbs-devel] [PATCH proxmox-backup v3 6/7] ui: tape: add single snapshot restore Dominik Csapak
2021-05-06 12:20 ` [pbs-devel] [PATCH proxmox-backup v3 7/7] docs/api-viewer: improve rendering of array format Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32c1f939-9634-5a16-f504-1d17972eef76@proxmox.com \
    --to=dietmar@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal