worker_state: move tasktype() code to src/api2/node/tasks.rs
Because this is API related code, and only used there. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
e678a50ea1
commit
fd18775ac1
|
@ -116,6 +116,15 @@ fn check_task_access(auth_id: &Authid, upid: &UPID) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn tasktype(state: &TaskState) -> TaskStateType {
|
||||||
|
match state {
|
||||||
|
TaskState::OK { .. } => TaskStateType::OK,
|
||||||
|
TaskState::Unknown { .. } => TaskStateType::Unknown,
|
||||||
|
TaskState::Error { .. } => TaskStateType::Error,
|
||||||
|
TaskState::Warning { .. } => TaskStateType::Warning,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
input: {
|
input: {
|
||||||
properties: {
|
properties: {
|
||||||
|
@ -492,7 +501,7 @@ pub fn list_tasks(
|
||||||
(Some(_), _) if running => continue,
|
(Some(_), _) if running => continue,
|
||||||
(Some(crate::server::TaskState::OK { .. }), _) if errors => continue,
|
(Some(crate::server::TaskState::OK { .. }), _) if errors => continue,
|
||||||
(Some(state), Some(filters)) => {
|
(Some(state), Some(filters)) => {
|
||||||
if !filters.contains(&state.tasktype()) {
|
if !filters.contains(&tasktype(state)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -18,7 +18,7 @@ use proxmox::tools::fs::{create_path, replace_file, CreateOptions};
|
||||||
|
|
||||||
use pbs_buildcfg;
|
use pbs_buildcfg;
|
||||||
use pbs_tools::logrotate::{LogRotate, LogRotateFiles};
|
use pbs_tools::logrotate::{LogRotate, LogRotateFiles};
|
||||||
use pbs_api_types::{Authid, TaskStateType, UPID};
|
use pbs_api_types::{Authid, UPID};
|
||||||
use pbs_config::{open_backup_lockfile, BackupLockGuard};
|
use pbs_config::{open_backup_lockfile, BackupLockGuard};
|
||||||
use proxmox_rest_server::{CommandoSocket, FileLogger, FileLogOptions};
|
use proxmox_rest_server::{CommandoSocket, FileLogger, FileLogOptions};
|
||||||
|
|
||||||
|
@ -243,15 +243,6 @@ impl TaskState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tasktype(&self) -> TaskStateType {
|
|
||||||
match self {
|
|
||||||
TaskState::OK { .. } => TaskStateType::OK,
|
|
||||||
TaskState::Unknown { .. } => TaskStateType::Unknown,
|
|
||||||
TaskState::Error { .. } => TaskStateType::Error,
|
|
||||||
TaskState::Warning { .. } => TaskStateType::Warning,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn result_text(&self) -> String {
|
fn result_text(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
TaskState::Error { message, .. } => format!("TASK ERROR: {}", message),
|
TaskState::Error { message, .. } => format!("TASK ERROR: {}", message),
|
||||||
|
|
Loading…
Reference in New Issue