From 1c6ad6ef909811d6caa0262c3a70afe18d7ba567 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 9 Dec 2019 13:07:25 +0100 Subject: [PATCH] src/bin/proxmox-backup-client.rs: impl. catalog sub command catalog dump catalog shell --- src/bin/proxmox-backup-client.rs | 90 +++++++++++++++++--------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index ef2c976c..8a01de2b 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -1761,15 +1761,15 @@ async fn mount_do(param: Value, pipe: Option) -> Result { Ok(Value::Null) } -fn shell( +fn catalog_shell( param: Value, _info: &ApiMethod, _rpcenv: &mut dyn RpcEnvironment, ) -> Result { - async_main(catalog_shell(param)) + async_main(catalog_shell_async(param)) } -async fn catalog_shell(param: Value) -> Result { +async fn catalog_shell_async(param: Value) -> Result { let repo = extract_repository_from_value(¶m)?; let client = HttpClient::new(repo.host(), repo.user(), None)?; let path = tools::required_string_param(¶m, "snapshot")?; @@ -1876,6 +1876,51 @@ async fn catalog_shell(param: Value) -> Result { Ok(Value::Null) } +fn catalog_mgmt_cli() -> CliCommandMap { + + #[sortable] + const API_METHOD_SHELL: ApiMethod = ApiMethod::new( + &ApiHandler::Sync(&catalog_shell), + &ObjectSchema::new( + "Shell to interactively inspect and restore snapshots.", + &sorted!([ + ("snapshot", false, &StringSchema::new("Group/Snapshot path.").schema()), + ("archive-name", false, &StringSchema::new("Backup archive name.").schema()), + ("repository", true, &REPO_URL_SCHEMA), + ("keyfile", true, &StringSchema::new("Path to encryption key.").schema()), + ]), + ) + ); + + let catalog_shell_cmd_def = CliCommand::new(&API_METHOD_SHELL) + .arg_param(&["snapshot", "archive-name"]) + .completion_cb("repository", complete_repository) + .completion_cb("archive-name", complete_archive_name) + .completion_cb("snapshot", complete_group_or_snapshot); + + #[sortable] + const API_METHOD_DUMP_CATALOG: ApiMethod = ApiMethod::new( + &ApiHandler::Sync(&dump_catalog), + &ObjectSchema::new( + "Dump catalog.", + &sorted!([ + ("snapshot", false, &StringSchema::new("Snapshot path.").schema()), + ("repository", true, &REPO_URL_SCHEMA), + ]), + ) + ); + + let catalog_dump_cmd_def = CliCommand::new(&API_METHOD_DUMP_CATALOG) + .arg_param(&["snapshot"]) + .completion_cb("repository", complete_repository) + .completion_cb("snapshot", complete_backup_snapshot); + + CliCommandMap::new() + .insert("dump".to_owned(), catalog_dump_cmd_def.into()) + .insert("shell".to_owned(), catalog_shell_cmd_def.into()) +} + + fn main() { const BACKUP_SOURCE_SCHEMA: Schema = StringSchema::new("Backup source specification ([