src/api2/node/tasks.rs: new filter "store" to filter tasks for one store
This commit is contained in:
parent
d3dbe52f37
commit
567d3e00fb
@ -126,6 +126,8 @@ fn list_tasks(
|
|||||||
let errors = param["errors"].as_bool().unwrap_or(false);
|
let errors = param["errors"].as_bool().unwrap_or(false);
|
||||||
let running = param["running"].as_bool().unwrap_or(false);
|
let running = param["running"].as_bool().unwrap_or(false);
|
||||||
|
|
||||||
|
let store = param["store"].as_str();
|
||||||
|
|
||||||
let userfilter = param["userfilter"].as_str();
|
let userfilter = param["userfilter"].as_str();
|
||||||
|
|
||||||
let list = server::read_task_list()?;
|
let list = server::read_task_list()?;
|
||||||
@ -150,6 +152,23 @@ fn list_tasks(
|
|||||||
if !info.upid.username.contains(username) { continue; }
|
if !info.upid.username.contains(username) { continue; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(store) = store {
|
||||||
|
// Note: useful to select all tasks spawned by proxmox-backup-client
|
||||||
|
let worker_id = match &info.upid.worker_id {
|
||||||
|
Some(w) => w,
|
||||||
|
None => continue, // skip
|
||||||
|
};
|
||||||
|
|
||||||
|
if info.upid.worker_type == "backup" || info.upid.worker_type == "restore" {
|
||||||
|
let prefix = format!("{}_", store);
|
||||||
|
if !worker_id.starts_with(&prefix) { continue; }
|
||||||
|
} else if info.upid.worker_type == "prune" || info.upid.worker_type == "garbage_collection" {
|
||||||
|
if worker_id != store { continue; }
|
||||||
|
} else {
|
||||||
|
continue; // skip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref state) = info.state {
|
if let Some(ref state) = info.state {
|
||||||
if running { continue; }
|
if running { continue; }
|
||||||
if errors && state.1 == "OK" {
|
if errors && state.1 == "OK" {
|
||||||
@ -261,6 +280,7 @@ pub const ROUTER: Router = Router::new()
|
|||||||
.default(50)
|
.default(50)
|
||||||
.schema()
|
.schema()
|
||||||
),
|
),
|
||||||
|
("store", true, &StringSchema::new("Only lists tasks for datastore name.").schema()),
|
||||||
("running", true, &BooleanSchema::new("Only list running tasks.").schema()),
|
("running", true, &BooleanSchema::new("Only list running tasks.").schema()),
|
||||||
("errors", true, &BooleanSchema::new("Only list erroneous tasks.").schema()),
|
("errors", true, &BooleanSchema::new("Only list erroneous tasks.").schema()),
|
||||||
("userfilter", true, &StringSchema::new("Only list tasks from this user.").schema()),
|
("userfilter", true, &StringSchema::new("Only list tasks from this user.").schema()),
|
||||||
|
@ -1980,7 +1980,13 @@ fn task_list(param: Value) -> Result<Value, Error> {
|
|||||||
|
|
||||||
let limit = param["limit"].as_u64().unwrap_or(50) as usize;
|
let limit = param["limit"].as_u64().unwrap_or(50) as usize;
|
||||||
|
|
||||||
let args = json!({ "running": true, "start": 0, "limit": limit, "userfilter": repo.user()});
|
let args = json!({
|
||||||
|
"running": true,
|
||||||
|
"start": 0,
|
||||||
|
"limit": limit,
|
||||||
|
"userfilter": repo.user(),
|
||||||
|
"store": repo.store(),
|
||||||
|
});
|
||||||
let result = client.get("api2/json/nodes/localhost/tasks", Some(args)).await?;
|
let result = client.get("api2/json/nodes/localhost/tasks", Some(args)).await?;
|
||||||
|
|
||||||
let data = &result["data"];
|
let data = &result["data"];
|
||||||
|
Loading…
Reference in New Issue
Block a user