From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema
Date: Tue, 28 Nov 2023 16:25:19 +0100 [thread overview]
Message-ID: <20231128152519.34316-1-c.ebner@proxmox.com> (raw)
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
next reply other threads:[~2023-11-28 15:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 15:25 Christian Ebner [this message]
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
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=20231128152519.34316-1-c.ebner@proxmox.com \
--to=c.ebner@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