proxmox-backup-manager: add garbage collection cli
This commit is contained in:
parent
133b3a4a81
commit
691c89a0fb
|
@ -22,6 +22,32 @@ fn start_garbage_collection(param: Value, _info: &ApiMethod) -> Result<Value, Er
|
||||||
Ok(json!(null))
|
Ok(json!(null))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn api_method_start_garbage_collection() -> ApiMethod {
|
||||||
|
ApiMethod::new(
|
||||||
|
start_garbage_collection,
|
||||||
|
ObjectSchema::new("Start garbage collection.")
|
||||||
|
.required("name", StringSchema::new("Datastore name."))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn garbage_collection_status(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||||
|
|
||||||
|
let name = param["name"].as_str().unwrap();
|
||||||
|
|
||||||
|
println!("Garbage collection status on store {}", name);
|
||||||
|
|
||||||
|
Ok(json!(null))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn api_method_garbage_collection_status() -> ApiMethod {
|
||||||
|
ApiMethod::new(
|
||||||
|
garbage_collection_status,
|
||||||
|
ObjectSchema::new("Garbage collection status.")
|
||||||
|
.required("name", StringSchema::new("Datastore name."))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn get_datastore_list(_param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
fn get_datastore_list(_param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||||
|
|
||||||
let config = datastore::config()?;
|
let config = datastore::config()?;
|
||||||
|
@ -29,6 +55,7 @@ fn get_datastore_list(_param: Value, _info: &ApiMethod) -> Result<Value, Error>
|
||||||
Ok(config.convert_to_array("name"))
|
Ok(config.convert_to_array("name"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn router() -> Router {
|
pub fn router() -> Router {
|
||||||
|
|
||||||
let datastore_info = Router::new()
|
let datastore_info = Router::new()
|
||||||
|
@ -43,12 +70,8 @@ pub fn router() -> Router {
|
||||||
.subdir(
|
.subdir(
|
||||||
"gc",
|
"gc",
|
||||||
Router::new()
|
Router::new()
|
||||||
.post(ApiMethod::new(
|
.get(api_method_garbage_collection_status())
|
||||||
start_garbage_collection,
|
.post(api_method_start_garbage_collection()));
|
||||||
ObjectSchema::new("Start garbage collection.")
|
|
||||||
.required("name", StringSchema::new("Datastore name."))
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,33 @@ fn datastore_commands() -> CommandLineInterface {
|
||||||
cmd_def.into()
|
cmd_def.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fn garbage_collection_commands() -> CommandLineInterface {
|
||||||
|
|
||||||
|
use proxmox_backup::config;
|
||||||
|
use proxmox_backup::api3;
|
||||||
|
|
||||||
|
let cmd_def = CliCommandMap::new()
|
||||||
|
.insert("status",
|
||||||
|
CliCommand::new(api3::admin::datastore::api_method_garbage_collection_status())
|
||||||
|
.arg_param(vec!["name"])
|
||||||
|
.completion_cb("name", config::datastore::complete_datastore_name)
|
||||||
|
.into())
|
||||||
|
.insert("start",
|
||||||
|
CliCommand::new(api3::admin::datastore::api_method_start_garbage_collection())
|
||||||
|
.arg_param(vec!["name"])
|
||||||
|
.completion_cb("name", config::datastore::complete_datastore_name)
|
||||||
|
.into());
|
||||||
|
|
||||||
|
cmd_def.into()
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
let cmd_def = CliCommandMap::new()
|
let cmd_def = CliCommandMap::new()
|
||||||
.insert("datastore".to_owned(), datastore_commands());
|
.insert("datastore".to_owned(), datastore_commands())
|
||||||
|
.insert("garbage-collection".to_owned(), garbage_collection_commands());
|
||||||
|
|
||||||
if let Err(err) = run_cli_command(&cmd_def.into()) {
|
if let Err(err) = run_cli_command(&cmd_def.into()) {
|
||||||
eprintln!("Error: {}", err);
|
eprintln!("Error: {}", err);
|
||||||
|
|
Loading…
Reference in New Issue