[pbs-devel] [PATCH v2 proxmox-backup] api: add dedicated storage name schema
Christian Ebner
c.ebner at proxmox.com
Wed Nov 29 11:12:48 CET 2023
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 <c.ebner at proxmox.com>
---
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<Vec<DatastoreMountInfo>, 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<Value, Error> {
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
More information about the pbs-devel
mailing list