From 355c055e815e11742b076a11e8afc9a2539696ad Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 24 Jun 2020 13:34:45 +0200 Subject: [PATCH] src/bin/proxmox-backup-manager.rs: implement verify --- src/bin/proxmox-backup-manager.rs | 42 +++++++++++++++++++++ src/bin/proxmox_backup_manager/datastore.rs | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs index ae4607c2..7d6af956 100644 --- a/src/bin/proxmox-backup-manager.rs +++ b/src/bin/proxmox-backup-manager.rs @@ -319,6 +319,40 @@ async fn pull_datastore( Ok(Value::Null) } +#[api( + input: { + properties: { + "store": { + schema: DATASTORE_SCHEMA, + }, + "output-format": { + schema: OUTPUT_FORMAT, + optional: true, + }, + } + } +)] +/// Verify backups +async fn verify( + store: String, + param: Value, +) -> Result { + + let output_format = get_output_format(¶m); + + let mut client = connect()?; + + let args = json!({}); + + let path = format!("api2/json/admin/datastore/{}/verify", store); + + let result = client.post(&path, Some(args)).await?; + + view_task_result(client, result, &output_format).await?; + + Ok(Value::Null) +} + fn main() { proxmox_backup::tools::setup_safe_path_env(); @@ -342,8 +376,16 @@ fn main() { .completion_cb("local-store", config::datastore::complete_datastore_name) .completion_cb("remote", config::remote::complete_remote_name) .completion_cb("remote-store", complete_remote_datastore_name) + ) + .insert( + "verify", + CliCommand::new(&API_METHOD_VERIFY) + .arg_param(&["store"]) + .completion_cb("store", config::datastore::complete_datastore_name) ); + + let mut rpcenv = CliEnvironment::new(); rpcenv.set_user(Some(String::from("root@pam"))); diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs index 9087b44c..94590aaf 100644 --- a/src/bin/proxmox_backup_manager/datastore.rs +++ b/src/bin/proxmox_backup_manager/datastore.rs @@ -86,7 +86,7 @@ pub fn datastore_commands() -> CommandLineInterface { .completion_cb("name", config::datastore::complete_datastore_name) .completion_cb("gc-schedule", config::datastore::complete_calendar_event) .completion_cb("prune-schedule", config::datastore::complete_calendar_event) - ) + ) .insert("remove", CliCommand::new(&api2::config::datastore::API_METHOD_DELETE_DATASTORE) .arg_param(&["name"])