From 698573201261163097add79eb9fd96b9782e71da Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Tue, 10 Oct 2023 13:37:47 +0200 Subject: [PATCH] cli: add option to remove systemd mount unit add commandline option for api function: DELETE /api2/json/nodes/{node}/disks/directory/{name} $ proxmox-backup-manager disk fs delete Signed-off-by: Markus Frank Reviewed-by: Lukas Wagner Tested-by: Lukas Wagner --- src/bin/proxmox_backup_manager/disk.rs | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/bin/proxmox_backup_manager/disk.rs b/src/bin/proxmox_backup_manager/disk.rs index c3259b655..73cb95e68 100644 --- a/src/bin/proxmox_backup_manager/disk.rs +++ b/src/bin/proxmox_backup_manager/disk.rs @@ -317,6 +317,31 @@ async fn create_datastore_disk( Ok(Value::Null) } +#[api( + input: { + properties: { + name: { + schema: DATASTORE_SCHEMA, + }, + }, + }, +)] +/// Remove a Filesystem mounted under '/mnt/datastore/'. +async fn delete_datastore_disk( + mut param: Value, + rpcenv: &mut dyn RpcEnvironment, +) -> Result { + param["node"] = "localhost".into(); + + let info = &api2::node::disks::directory::API_METHOD_DELETE_DATASTORE_DISK; + let _result = match info.handler { + ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, + _ => unreachable!(), + }; + + Ok(Value::Null) +} + pub fn filesystem_commands() -> CommandLineInterface { let cmd_def = CliCommandMap::new() .insert("list", CliCommand::new(&API_METHOD_LIST_DATASTORE_MOUNTS)) @@ -325,6 +350,10 @@ pub fn filesystem_commands() -> CommandLineInterface { CliCommand::new(&API_METHOD_CREATE_DATASTORE_DISK) .arg_param(&["name"]) .completion_cb("disk", complete_disk_name), + ).insert( + "delete", + CliCommand::new(&API_METHOD_DELETE_DATASTORE_DISK) + .arg_param(&["name"]), ); cmd_def.into()