[pbs-devel] [PATCH proxmox-backup v2 4/6] fix #3690: cli: add function wipe_disk
Markus Frank
m.frank at proxmox.com
Tue Nov 28 11:39:57 CET 2023
Signed-off-by: Markus Frank <m.frank at proxmox.com>
---
src/bin/proxmox_backup_manager/disk.rs | 44 ++++++++++++++++++++++----
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/src/bin/proxmox_backup_manager/disk.rs b/src/bin/proxmox_backup_manager/disk.rs
index 73cb95e6..5514da4b 100644
--- a/src/bin/proxmox_backup_manager/disk.rs
+++ b/src/bin/proxmox_backup_manager/disk.rs
@@ -5,10 +5,12 @@ 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_DISK_AND_PARTITION_NAME_SCHEMA,
+ BLOCKDEVICE_NAME_SCHEMA, DATASTORE_SCHEMA, DISK_LIST_SCHEMA, ZFS_ASHIFT_SCHEMA,
+};
+use proxmox_backup::tools::disks::{
+ complete_disk_name, complete_partition_name, FileSystemType, SmartAttribute,
};
-use proxmox_backup::tools::disks::{complete_disk_name, FileSystemType, SmartAttribute};
use proxmox_backup::api2;
@@ -137,6 +139,30 @@ async fn initialize_disk(
Ok(Value::Null)
}
+#[api(
+ input: {
+ properties: {
+ disk: {
+ schema: BLOCKDEVICE_DISK_AND_PARTITION_NAME_SCHEMA,
+ },
+ },
+ },
+)]
+/// wipe disk
+async fn wipe_disk(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
+ param["node"] = "localhost".into();
+
+ let info = &api2::node::disks::API_METHOD_WIPE_DISK;
+ let result = match info.handler {
+ ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
+ _ => unreachable!(),
+ };
+
+ crate::wait_for_local_worker(result.as_str().unwrap()).await?;
+
+ Ok(Value::Null)
+}
+
#[api(
input: {
properties: {
@@ -350,10 +376,10 @@ pub fn filesystem_commands() -> CommandLineInterface {
CliCommand::new(&API_METHOD_CREATE_DATASTORE_DISK)
.arg_param(&["name"])
.completion_cb("disk", complete_disk_name),
- ).insert(
+ )
+ .insert(
"delete",
- CliCommand::new(&API_METHOD_DELETE_DATASTORE_DISK)
- .arg_param(&["name"]),
+ CliCommand::new(&API_METHOD_DELETE_DATASTORE_DISK).arg_param(&["name"]),
);
cmd_def.into()
@@ -375,6 +401,12 @@ pub fn disk_commands() -> CommandLineInterface {
CliCommand::new(&API_METHOD_INITIALIZE_DISK)
.arg_param(&["disk"])
.completion_cb("disk", complete_disk_name),
+ )
+ .insert(
+ "wipe",
+ CliCommand::new(&API_METHOD_WIPE_DISK)
+ .arg_param(&["disk"])
+ .completion_cb("disk", complete_partition_name),
);
cmd_def.into()
--
2.39.2
More information about the pbs-devel
mailing list