From 9e165b5cad247b5aa011e5bf12da26aa65c2eefa Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 30 Jan 2020 17:57:37 +0100 Subject: [PATCH] src/bin/proxmox-backup-manager.rs - list remotes: do not use client, call directly --- src/bin/proxmox-backup-manager.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs index 11ceaa27..3aff023f 100644 --- a/src/bin/proxmox-backup-manager.rs +++ b/src/bin/proxmox-backup-manager.rs @@ -5,7 +5,7 @@ use failure::*; use serde_json::{json, Value}; use chrono::{Local, TimeZone}; -use proxmox::api::{api, cli::*}; +use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler}; use proxmox_backup::configdir; use proxmox_backup::tools; @@ -84,16 +84,15 @@ fn connect() -> Result { } )] /// List configured remotes. -async fn list_remotes(param: Value) -> Result { +fn list_remotes(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result { let output_format = param["output-format"].as_str().unwrap_or("text").to_owned(); - let client = connect()?; - - let mut result = client.get("api2/json/config/remote", None).await?; - - let mut data = result["data"].take(); - let schema = api2::config::remote::API_RETURN_SCHEMA_LIST_REMOTES; + let info = &api2::config::remote::API_METHOD_LIST_REMOTES; + let mut data = match info.handler { + ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, + _ => unreachable!(), + }; let mut column_config = Vec::new(); column_config.push(ColumnConfig::new("name")); @@ -108,7 +107,7 @@ async fn list_remotes(param: Value) -> Result { .column_config(column_config); - format_and_print_result_full(&mut data, schema, &output_format, &options); + format_and_print_result_full(&mut data, info.returns, &output_format, &options); Ok(Value::Null) }