src/bin/proxmox-backup-manager.rs: implement cli sync command
This commit is contained in:
parent
a575320657
commit
0eb0e02451
@ -353,13 +353,69 @@ fn cert_mgmt_cli() -> CommandLineInterface {
|
||||
cmd_def.into()
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
store: {
|
||||
schema: DATASTORE_SCHEMA,
|
||||
},
|
||||
remote: {
|
||||
description: "Remote name.", // fixme: remote ID schema
|
||||
type: String,
|
||||
},
|
||||
"remote-store": {
|
||||
schema: DATASTORE_SCHEMA,
|
||||
},
|
||||
"output-format": {
|
||||
schema: OUTPUT_FORMAT,
|
||||
optional: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
)]
|
||||
/// Start datastore sync
|
||||
async fn start_datastore_sync(
|
||||
store: String,
|
||||
remote: String,
|
||||
remote_store: String,
|
||||
output_format: Option<String>,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let output_format = output_format.unwrap_or("text".to_string());
|
||||
|
||||
let mut client = connect()?;
|
||||
|
||||
let remote = proxmox_backup::config::remotes::lookup(&remote)?;
|
||||
|
||||
let args = json!({
|
||||
"store": store,
|
||||
"remote-host": remote.host,
|
||||
"remote-user": remote.userid,
|
||||
"remote-store": remote_store,
|
||||
"remote-password": remote.password,
|
||||
});
|
||||
|
||||
let result = client.post("api2/json/sync", Some(args)).await?;
|
||||
|
||||
view_task_result(client, result, &output_format).await?;
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("datastore", datastore_commands())
|
||||
.insert("garbage-collection", garbage_collection_commands())
|
||||
.insert("cert", cert_mgmt_cli())
|
||||
.insert("task", task_mgmt_cli());
|
||||
.insert("task", task_mgmt_cli())
|
||||
.insert(
|
||||
"sync",
|
||||
CliCommand::new(&API_METHOD_START_DATASTORE_SYNC)
|
||||
.arg_param(&["store", "remote", "remote-store"])
|
||||
.completion_cb("store", config::datastore::complete_datastore_name)
|
||||
.completion_cb("remote", config::remotes::complete_remote_name)
|
||||
);
|
||||
|
||||
run_cli_command(cmd_def);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user