all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema
@ 2023-11-28 15:25 Christian Ebner
  2023-11-28 17:49 ` Thomas Lamprecht
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Ebner @ 2023-11-28 15:25 UTC (permalink / raw)
  To: pbs-devel

Introduce a dedicated datastore disk schema for disks, to semantically
distinguish between datastore name and datastore disk name.

Further, adapt the systemd mount unit description accordingly.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-api-types/src/datastore.rs         |  6 ++++++
 src/api2/node/disks/directory.rs       |  8 ++++----
 src/api2/node/disks/zfs.rs             |  4 ++--
 src/bin/proxmox_backup_manager/disk.rs | 10 +++++-----
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
index 1f619c9d..4150c6c6 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 DATASTORE_DISK_SCHEMA: Schema = StringSchema::new("Datastore disk name.")
+    .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..c43eb125 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, DATASTORE_DISK_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: DATASTORE_DISK_SCHEMA,
             },
             disk: {
                 schema: BLOCKDEVICE_NAME_SCHEMA,
@@ -227,7 +227,7 @@ pub fn create_datastore_disk(
                 schema: NODE_SCHEMA,
             },
             name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
         }
     },
@@ -296,7 +296,7 @@ fn create_datastore_mount_unit(
 
     let unit = SystemdUnitSection {
         Description: format!(
-            "Mount datatstore '{}' under '{}'",
+            "Mount datastore disk '{}' under '{}'",
             datastore_name, mount_point
         ),
         ..Default::default()
diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
index 673dc1bf..52c011db 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, DATASTORE_DISK_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: DATASTORE_DISK_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 fae8829f..4c040c4a 100644
--- a/src/bin/proxmox_backup_manager/disk.rs
+++ b/src/bin/proxmox_backup_manager/disk.rs
@@ -5,8 +5,8 @@ use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
 use proxmox_schema::api;
 
 use pbs_api_types::{
-    ZfsCompressionType, ZfsRaidLevel, BLOCKDEVICE_NAME_SCHEMA, DATASTORE_SCHEMA, DISK_LIST_SCHEMA,
-    ZFS_ASHIFT_SCHEMA,
+    ZfsCompressionType, ZfsRaidLevel, BLOCKDEVICE_NAME_SCHEMA, DATASTORE_DISK_SCHEMA,
+    DISK_LIST_SCHEMA, ZFS_ASHIFT_SCHEMA,
 };
 use proxmox_backup::tools::disks::{complete_disk_name, FileSystemType, SmartAttribute};
 
@@ -141,7 +141,7 @@ async fn initialize_disk(
    input: {
         properties: {
            name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
             devices: {
                 schema: DISK_LIST_SCHEMA,
@@ -282,7 +282,7 @@ fn list_datastore_mounts(
    input: {
         properties: {
             name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
             disk: {
                 schema: BLOCKDEVICE_NAME_SCHEMA,
@@ -321,7 +321,7 @@ async fn create_datastore_disk(
    input: {
         properties: {
             name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
         },
    },
-- 
2.39.2





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-29  9:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-28 15:25 [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema Christian Ebner
2023-11-28 17:49 ` Thomas Lamprecht
2023-11-29  8:24   ` Christian Ebner
2023-11-29  8:56     ` Thomas Lamprecht
2023-11-29  9:13       ` Christian Ebner
2023-11-29  9:21         ` Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal