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 4AD66A10E3 for ; Fri, 10 Nov 2023 14:50:32 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2A94C1772 for ; Fri, 10 Nov 2023 14:50:32 +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 ; Fri, 10 Nov 2023 14:50:31 +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 1159E47B33 for ; Fri, 10 Nov 2023 14:50:31 +0100 (CET) From: Markus Frank To: pbs-devel@lists.proxmox.com Date: Fri, 10 Nov 2023 14:50:08 +0100 Message-Id: <20231110135010.106015-4-m.frank@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231110135010.106015-1-m.frank@proxmox.com> References: <20231110135010.106015-1-m.frank@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.038 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 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [disk.rs] Subject: [pbs-devel] [PATCH proxmox-backup 4/6] feature #3690: cli: add function wipe_disk 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: Fri, 10 Nov 2023 13:50:32 -0000 Signed-off-by: Markus Frank --- 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..7505a42a 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_NAME_SCHEMA, BLOCKDEVICE_PARTITION_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_PARTITION_NAME_SCHEMA, + }, + }, + }, +)] +/// wipe disk +async fn wipe_disk(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result { + 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