proxmox-backup-manager: add garbage collection cli

This commit is contained in:
Dietmar Maurer
2019-01-04 11:33:58 +01:00
parent 133b3a4a81
commit 691c89a0fb
2 changed files with 53 additions and 7 deletions

View File

@ -22,6 +22,32 @@ fn start_garbage_collection(param: Value, _info: &ApiMethod) -> Result<Value, Er
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> {
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"))
}
pub fn router() -> Router {
let datastore_info = Router::new()
@ -43,12 +70,8 @@ pub fn router() -> Router {
.subdir(
"gc",
Router::new()
.post(ApiMethod::new(
start_garbage_collection,
ObjectSchema::new("Start garbage collection.")
.required("name", StringSchema::new("Datastore name."))
)
));
.get(api_method_garbage_collection_status())
.post(api_method_start_garbage_collection()));