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 CDECEB390B for ; Wed, 29 Nov 2023 11:13:03 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B056639CA for ; Wed, 29 Nov 2023 11:13:03 +0100 (CET) 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 for ; Wed, 29 Nov 2023 11:13:02 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6EEC441AFB for ; Wed, 29 Nov 2023 11:13:02 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Wed, 29 Nov 2023 11:12:48 +0100 Message-Id: <20231129101248.111647-1-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.051 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH v2 proxmox-backup] api: add dedicated storage name 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: Wed, 29 Nov 2023 10:13:03 -0000 Introduce a dedicated storage name schema to semantically distinguish between datastore name and storage name. Further, adapt the systemd mount unit description accordingly. Signed-off-by: Christian Ebner --- changes since version 1: - s/DATASTORE_DISK_SCHEMA/STORAGE_NAME_SCHEMA/ - Adapt schema and systemd mount unit description - s/datastore_name/storage_name/ for `create_datastore_mount_unit` pbs-api-types/src/datastore.rs | 6 ++++++ src/api2/node/disks/directory.rs | 13 +++++-------- src/api2/node/disks/zfs.rs | 4 ++-- src/bin/proxmox_backup_manager/disk.rs | 8 ++++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 1f619c9d..227aa2e3 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -102,6 +102,12 @@ pub const DATASTORE_SCHEMA: Schema = StringSchema::new("Datastore name.") .max_length(32) .schema(); +pub const STORAGE_NAME_SCHEMA: Schema = StringSchema::new("Storage name. Implies the datastore name, if part of a transaction.") + .format(&PROXMOX_SAFE_ID_FORMAT) + .min_length(3) + .max_length(32) + .schema(); + pub const CHUNK_DIGEST_SCHEMA: Schema = StringSchema::new("Chunk digest (SHA256).") .format(&CHUNK_DIGEST_FORMAT) .schema(); diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs index 5e1cb124..af2e1a14 100644 --- a/src/api2/node/disks/directory.rs +++ b/src/api2/node/disks/directory.rs @@ -8,7 +8,7 @@ use proxmox_section_config::SectionConfigData; use proxmox_sys::task_log; use pbs_api_types::{ - DataStoreConfig, BLOCKDEVICE_NAME_SCHEMA, DATASTORE_SCHEMA, NODE_SCHEMA, PRIV_SYS_AUDIT, + DataStoreConfig, BLOCKDEVICE_NAME_SCHEMA, STORAGE_NAME_SCHEMA, NODE_SCHEMA, PRIV_SYS_AUDIT, PRIV_SYS_MODIFY, UPID_SCHEMA, }; @@ -112,7 +112,7 @@ pub fn list_datastore_mounts() -> Result, Error> { schema: NODE_SCHEMA, }, name: { - schema: DATASTORE_SCHEMA, + schema: STORAGE_NAME_SCHEMA, }, disk: { schema: BLOCKDEVICE_NAME_SCHEMA, @@ -227,7 +227,7 @@ pub fn create_datastore_disk( schema: NODE_SCHEMA, }, name: { - schema: DATASTORE_SCHEMA, + schema: STORAGE_NAME_SCHEMA, }, } }, @@ -284,7 +284,7 @@ pub const ROUTER: Router = Router::new() .match_all("name", &ITEM_ROUTER); fn create_datastore_mount_unit( - datastore_name: &str, + storage_name: &str, mount_point: &str, fs_type: FileSystemType, what: &str, @@ -295,10 +295,7 @@ fn create_datastore_mount_unit( let mount_unit_path = format!("/etc/systemd/system/{}", mount_unit_name); let unit = SystemdUnitSection { - Description: format!( - "Mount datatstore '{}' under '{}'", - datastore_name, mount_point - ), + Description: format!("Mount storage '{}' under '{}'", storage_name, mount_point), ..Default::default() }; diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs index 673dc1bf..e225b9a7 100644 --- a/src/api2/node/disks/zfs.rs +++ b/src/api2/node/disks/zfs.rs @@ -6,7 +6,7 @@ use proxmox_schema::api; use proxmox_sys::{task_error, task_log}; use pbs_api_types::{ - DataStoreConfig, ZfsCompressionType, ZfsRaidLevel, ZpoolListItem, DATASTORE_SCHEMA, + DataStoreConfig, ZfsCompressionType, ZfsRaidLevel, ZpoolListItem, STORAGE_NAME_SCHEMA, DISK_ARRAY_SCHEMA, DISK_LIST_SCHEMA, NODE_SCHEMA, PRIV_SYS_AUDIT, PRIV_SYS_MODIFY, UPID_SCHEMA, ZFS_ASHIFT_SCHEMA, ZPOOL_NAME_SCHEMA, }; @@ -117,7 +117,7 @@ pub fn zpool_details(name: String) -> Result { schema: NODE_SCHEMA, }, name: { - schema: DATASTORE_SCHEMA, + schema: STORAGE_NAME_SCHEMA, }, devices: { schema: DISK_LIST_SCHEMA, diff --git a/src/bin/proxmox_backup_manager/disk.rs b/src/bin/proxmox_backup_manager/disk.rs index 7a292098..ce0d8994 100644 --- a/src/bin/proxmox_backup_manager/disk.rs +++ b/src/bin/proxmox_backup_manager/disk.rs @@ -6,7 +6,7 @@ use proxmox_schema::api; use pbs_api_types::{ ZfsCompressionType, ZfsRaidLevel, BLOCKDEVICE_DISK_AND_PARTITION_NAME_SCHEMA, - BLOCKDEVICE_NAME_SCHEMA, DATASTORE_SCHEMA, DISK_LIST_SCHEMA, ZFS_ASHIFT_SCHEMA, + BLOCKDEVICE_NAME_SCHEMA, DISK_LIST_SCHEMA, STORAGE_NAME_SCHEMA, ZFS_ASHIFT_SCHEMA, }; use proxmox_backup::tools::disks::{ complete_disk_name, complete_partition_name, FileSystemType, SmartAttribute, @@ -167,7 +167,7 @@ async fn wipe_disk(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result< input: { properties: { name: { - schema: DATASTORE_SCHEMA, + schema: STORAGE_NAME_SCHEMA, }, devices: { schema: DISK_LIST_SCHEMA, @@ -308,7 +308,7 @@ fn list_datastore_mounts( input: { properties: { name: { - schema: DATASTORE_SCHEMA, + schema: STORAGE_NAME_SCHEMA, }, disk: { schema: BLOCKDEVICE_NAME_SCHEMA, @@ -347,7 +347,7 @@ async fn create_datastore_disk( input: { properties: { name: { - schema: DATASTORE_SCHEMA, + schema: STORAGE_NAME_SCHEMA, }, }, }, -- 2.39.2