2018-12-20 09:32:49 +00:00
|
|
|
extern crate proxmox_backup;
|
2018-12-09 10:59:32 +00:00
|
|
|
|
2019-01-22 11:10:38 +00:00
|
|
|
//use proxmox_backup::api2;
|
2018-12-20 09:32:49 +00:00
|
|
|
use proxmox_backup::cli::command::*;
|
2018-12-10 12:28:38 +00:00
|
|
|
|
2018-12-10 12:40:10 +00:00
|
|
|
fn datastore_commands() -> CommandLineInterface {
|
2018-12-09 10:59:32 +00:00
|
|
|
|
2019-01-04 09:49:52 +00:00
|
|
|
use proxmox_backup::config;
|
2019-01-22 11:10:38 +00:00
|
|
|
use proxmox_backup::api2;
|
2018-12-11 10:12:13 +00:00
|
|
|
|
2018-12-11 10:31:36 +00:00
|
|
|
let cmd_def = CliCommandMap::new()
|
2019-01-22 11:10:38 +00:00
|
|
|
.insert("list", CliCommand::new(api2::config::datastore::get()).into())
|
2018-12-11 10:31:36 +00:00
|
|
|
.insert("create",
|
2019-01-22 11:10:38 +00:00
|
|
|
CliCommand::new(api2::config::datastore::post())
|
2018-12-11 10:31:36 +00:00
|
|
|
.arg_param(vec!["name", "path"])
|
|
|
|
.into())
|
|
|
|
.insert("remove",
|
2019-01-22 11:10:38 +00:00
|
|
|
CliCommand::new(api2::config::datastore::delete())
|
2018-12-11 10:31:36 +00:00
|
|
|
.arg_param(vec!["name"])
|
2019-01-04 09:49:52 +00:00
|
|
|
.completion_cb("name", config::datastore::complete_datastore_name)
|
2018-12-11 10:31:36 +00:00
|
|
|
.into());
|
2018-12-10 12:28:38 +00:00
|
|
|
|
2018-12-10 12:51:10 +00:00
|
|
|
cmd_def.into()
|
2018-12-10 12:28:38 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 10:33:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
fn garbage_collection_commands() -> CommandLineInterface {
|
|
|
|
|
|
|
|
use proxmox_backup::config;
|
2019-01-22 11:10:38 +00:00
|
|
|
use proxmox_backup::api2;
|
2019-01-04 10:33:58 +00:00
|
|
|
|
|
|
|
let cmd_def = CliCommandMap::new()
|
|
|
|
.insert("status",
|
2019-01-22 11:10:38 +00:00
|
|
|
CliCommand::new(api2::admin::datastore::api_method_garbage_collection_status())
|
2019-02-12 09:08:23 +00:00
|
|
|
.arg_param(vec!["store"])
|
|
|
|
.completion_cb("store", config::datastore::complete_datastore_name)
|
2019-01-04 10:33:58 +00:00
|
|
|
.into())
|
|
|
|
.insert("start",
|
2019-01-22 11:10:38 +00:00
|
|
|
CliCommand::new(api2::admin::datastore::api_method_start_garbage_collection())
|
2019-02-12 09:08:23 +00:00
|
|
|
.arg_param(vec!["store"])
|
|
|
|
.completion_cb("store", config::datastore::complete_datastore_name)
|
2019-01-04 10:33:58 +00:00
|
|
|
.into());
|
|
|
|
|
|
|
|
cmd_def.into()
|
|
|
|
}
|
|
|
|
|
2018-12-10 12:28:38 +00:00
|
|
|
fn main() {
|
|
|
|
|
2018-12-11 10:31:36 +00:00
|
|
|
let cmd_def = CliCommandMap::new()
|
2019-01-04 10:33:58 +00:00
|
|
|
.insert("datastore".to_owned(), datastore_commands())
|
|
|
|
.insert("garbage-collection".to_owned(), garbage_collection_commands());
|
2018-12-09 15:52:32 +00:00
|
|
|
|
2018-12-11 10:31:36 +00:00
|
|
|
if let Err(err) = run_cli_command(&cmd_def.into()) {
|
2018-12-09 10:59:32 +00:00
|
|
|
eprintln!("Error: {}", err);
|
|
|
|
print_cli_usage();
|
|
|
|
std::process::exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|